firefoxUpdateProfilesUserJs.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/sh
  2. # fail if any commands fails
  3. set -e
  4. # debug log
  5. #set -x
  6. apply_to_profiles() {
  7. if [ -n "$(ls ~/.mozilla/firefox/*.default* 2>/dev/null)" ];then
  8. for dir in ~/.mozilla/firefox/*.default*; do
  9. cp -v user.js.new "$dir"/user.js
  10. echo "Custom settings applied for profile in ${dir}."
  11. done
  12. fi
  13. if [ -n "$(ls ~/snap/firefox/common/.mozilla/firefox/*.default* 2>/dev/null)" ];then
  14. for dir in ~/snap/firefox/common/.mozilla/firefox/*.default*; do
  15. cp -v user.js.new "$dir"/user.js
  16. echo "Custom settings applied for profile in ${dir}."
  17. done
  18. fi
  19. rm -f user.js.new
  20. }
  21. apply_custom_settings() {
  22. # apply custom settings
  23. cp -v user.js user.js.new
  24. {
  25. echo ''
  26. echo '/** CUSTOM SETTINGS ***/'
  27. echo ''
  28. echo 'user_pref("media.peerconnection.enabled", false);'
  29. echo 'user_pref("media.navigator.enabled", false);'
  30. echo 'user_pref("extensions.pocket.enabled", false);'
  31. echo 'user_pref("privacy.query_stripping.enabled", true);'
  32. echo 'user_pref("privacy.trackingprotection.enabled", true);'
  33. echo 'user_pref("browser.safebrowsing.malware.enabled", false);'
  34. echo 'user_pref("browser.safebrowsing.phishing.enabled", false);'
  35. echo 'user_pref("javascript.options.wasm", false);'
  36. echo 'user_pref("browser.display.background_color", "#323232"'
  37. echo 'user_pref("browser.startup.homepage", "about:blank");'
  38. echo 'user_pref("security.fileuri.strict_origin_policy", false);'
  39. echo 'user_pref("media.autoplay.enabled", false);'
  40. echo 'user_pref("network.dnsCacheExpiration", 0);'
  41. echo ''
  42. echo '/** PERFORMANCE SETTINGS ***/'
  43. echo ''
  44. echo 'user_pref("layers.acceleration.force-enabled", true);'
  45. echo 'user_pref("gfx.webrender.enabled", true);'
  46. }>>user.js.new
  47. # Encrypted DNS - https://github.com/curl/curl/wiki/DNS-over-HTTPS#publicly-available-servers
  48. #{
  49. # echo 'user_pref("network.trr.mode", 3);'
  50. # echo 'user_pref("network.trr.uri", "https://dns.quad9.net/dns-query");'
  51. #}>>user.js.new
  52. }
  53. dir=user.js
  54. repo="https://github.com/arkenfox/${dir}.git"
  55. mkdir -p ~/src
  56. cd ~/src || return
  57. if [ ! -d "$dir" ]; then
  58. git clone $repo
  59. cd "$dir" || return
  60. apply_custom_settings
  61. apply_to_profiles
  62. else
  63. cd "$dir" || return
  64. git fetch
  65. LOCAL=$(git rev-parse HEAD)
  66. REMOTE=$(git rev-parse @{u})
  67. if [ ! $LOCAL = $REMOTE ]; then
  68. pwd
  69. echo "Need to pull"
  70. git pull
  71. apply_custom_settings
  72. apply_to_profiles
  73. else
  74. echo "no update needed"
  75. fi
  76. fi