Skip to content

Instantly share code, notes, and snippets.

@AaronMT
Created December 18, 2012 19:37
Show Gist options
  • Save AaronMT/4331189 to your computer and use it in GitHub Desktop.
Save AaronMT/4331189 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Script to change the B2G UA
# Based on Dave Hyland's script https://gist.github.com/2656232
# Options: default, fennec, android
LOCAL_PREFS_JS=C:\\prefs.js
PROFILE_DIR=$(adb shell echo -n "/data/b2g/mozilla/*.default")
REMOTE_PREFS_JS=${PROFILE_DIR}/prefs.js
rm -f ${LOCAL_PREFS_JS}
adb pull ${REMOTE_PREFS_JS} ${LOCAL_PREFS_JS}
ua=""
if [ "${1}" == "fennec" ]
then
echo "Changing UA to Fennec UA"
ua="Mozilla/5.0 (Android; Mobile; rv:20.0) Gecko/20.0 Firefox/20.0"
fi
if [ "${1}" == "android" ]
then
echo "Changing UA to Android Stock UA"
ua="Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19"
fi
grep -v general.useragent.override ${LOCAL_PREFS_JS} > ${LOCAL_PREFS_JS}.tmp
if [ "${ua}" != "" ]
then
echo 'user_pref("general.useragent.override", "'${ua}'");' >> ${LOCAL_PREFS_JS}.tmp
else
echo "Reseting B2G to default UA"
fi
set -x
adb push ${LOCAL_PREFS_JS}.tmp ${REMOTE_PREFS_JS}
adb shell stop b2g && adb shell start b2g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment