Created
September 5, 2009 21:07
-
-
Save nogweii/181515 to your computer and use it in GitHub Desktop.
Simple user agent switcher code for uzbl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Open dmenu to select a user agent | |
| bind ZU = spawn $XDG_DATA_HOME/uzbl/scripts/switch_useragent.sh | |
| # Immediately switch to the user agent, bypassing dmenu. | |
| bind ZI = spawn $XDG_DATA_HOME/uzbl/scripts/switch_useragent.sh "iPhone" | |
| bind ZA = spawn $XDG_DATA_HOME/uzbl/scripts/switch_useragent.sh "Android (G1) Browser" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| [ -d "${XDG_DATA_HOME:-$HOME/.local/share}/uzbl" ] || exit 1 | |
| file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/user_agents.txt | |
| COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030" | |
| if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]' | |
| then | |
| DMENU="dmenu -i -xs -rs -l 10" # vertical patch | |
| else | |
| DMENU="dmenu -i" # horizontal, oh well! | |
| fi | |
| if [ -z "$8" ] ; then | |
| new_agent=`grep -v '^[[:space:]#]' $file | $DMENU $COLORS | perl -p -e 's/^.*?: ?//'` | |
| else | |
| new_agent=`grep "^$8:" $file | perl -p -e 's/^.*?: ?//'` | |
| [ -z "$new_agent" ] && exit 1 | |
| fi | |
| echo "set useragent = $new_agent" > $4 | |
| echo "reload" > $4 # Reload the page so the new user agent is used. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Original user agent. All lines beginning with a '#' are ignored, as are blank lines. | |
| Uzbl: Uzbl (Webkit @WEBKIT_MAJOR.@WEBKIT_MINOR.@WEBKIT_MICRO) (@(uname -s)@ @(uname -n)@ @(uname -r)@ @(uname -v)@ @(uname -m)@ [@ARCH_UZBL]) (Commit @COMMIT) | |
| # ---------------------- | |
| # -- Major Browsers -- | |
| # ---------------------- | |
| Chrome: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.53 Safari/525.19 | |
| Firefox (Windows): Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 (.NET CLR 3.5.30729) | |
| Internet Explorer 7: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322) | |
| Opera: Opera/10.00 (X11; Linux i686 ; U; en) Presto/2.2.0 | |
| Safari: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/525.28.3 (KHTML, like Gecko) Version/3.2.3 Safari/525.28.3 | |
| Konqueror: Mozilla/5.0 (compatible; Konqueror/4.0; Linux) KHTML/4.0.5 (like Gecko) | |
| # ---------------------- | |
| # -- Mobile -- | |
| # ---------------------- | |
| iPhone: Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_1 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5F136 Safari/525.20 | |
| Android (G1) Browser: Mozilla/5.0 (Linux; U; Android 1.1; en-gb; dream) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2 | |
| # ---------------------- | |
| # -- Other / Misc -- | |
| # ---------------------- | |
| cURL: curl/7.7.2 (powerpc-apple-darwin6.0) libcurl 7.7.2 (OpenSSL 0.9.6b) | |
| Google Bot: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) | |
| # All these user agents were collected from http://www.zytrax.com/tech/web/browser_ids.htm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment