Skip to content

Instantly share code, notes, and snippets.

@marcocspc
Forked from leifj/ff_set
Last active January 24, 2023 14:12
Show Gist options
  • Select an option

  • Save marcocspc/39ae0d26760b881a828b95ffc14d4dcc to your computer and use it in GitHub Desktop.

Select an option

Save marcocspc/39ae0d26760b881a828b95ffc14d4dcc to your computer and use it in GitHub Desktop.
A simple cmdline to set firefox config in all profiles found in $HOME/.mozilla/firefox - useful to disable TRR
#!/bin/bash
#
# https://blog.ungleich.ch/en-us/cms/blog/2018/08/04/mozillas-new-dns-resolution-is-dangerous/
# https://askubuntu.com/questions/313483/how-do-i-change-firefoxs-aboutconfig-from-a-shell-script
#
# To completely disable sending your DNS queries to cloudflare:
#
# ff_set network.trr.mode 5
#
# Directories in which "find" command will search for
# config files. This value covers default
# firefox installation and snap one.
DIRS_LIST="$HOME/.mozilla/firefox $HOME/snap/firefox/common/.mozilla/firefox $HOME/snap/firefox/common/.cache/mozilla/firefox $HOME/.var/app/org.mozilla.firefox/.mozilla/firefox"
# You will need to restart firefox to apply the config.
# To do it run:
# killall firefox && nohup firefox > /dev/null &
################ Script ################
for profile in `find $DIRS_LIST -maxdepth 1 -type d -name \*.default*`; do
if [ -f $profile/prefs.js ]; then
echo "Setting option $* in $profile/prefs.js"
sed -i 's/user_pref("'$1'",.*);/user_pref("'$1'",'$2');/' $profile/prefs.js
grep -q $1 $profile/prefs.js || echo "user_pref(\"$1\",$2);" >> $profile/prefs.js
fi
done
@marcocspc
Copy link
Author

Update script to cover firefox snap installation and add a few more instructions on how this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment