Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to add/remove an UA override to B2G.
#!/bin/sh
# Script to add a UA override to B2G
# Based on Dave Hyland's script https://gist.github.com/2656232
# Options:
# remove - removes the override
# Usage:
# ./uaOverride.sh add example.com
# ./uaOverride.sh remove example.com
LOCAL_USER_JS=/tmp/user.js
PROFILE_DIR=/system/b2g/defaults/pref
REMOTE_USER_JS=${PROFILE_DIR}/user.js
rm -f ${LOCAL_USER_JS}
adb pull ${REMOTE_USER_JS} ${LOCAL_USER_JS}
if [ "${1}" == "remove" ]
then
echo "Removing UA override for ${2}"
ua=
else
echo "Adding fennec UA override for ${2}"
ua=fennec
fi
grep -v ${2} ${LOCAL_USER_JS} > ${LOCAL_USER_JS}.tmp
if [ "${ua}" != "" ]
then
echo 'pref("general.useragent.override.'${2}'", "\Mobile#(Android; Mobile");' >> ${LOCAL_USER_JS}.tmp
fi
set -x
adb shell mount -o rw,remount /system
adb push ${LOCAL_USER_JS}.tmp ${REMOTE_USER_JS}
adb shell mount -o ro,remount /system
#adb shell stop b2g && adb shell start b2g
adb reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.