a user-overrides.js supplement intended to be appended to the 'ghacks' user.js for Firefox https://12bytes.org/articles/tech/firefox
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

157 lines
6.5 KiB

  1. #!/usr/bin/env bash
  2. #
  3. # NOTE TO SELF: DIST. set $sScriptVer value
  4. #
  5. ## SCRIPT INFORMATION
  6. # ------------------------------------------------------------------------------
  7. # Name : Firefox Config Update Notifier
  8. # Description : compare version of local 'arkenfox' user.js and, optionally,
  9. # : 12bytes.org user-overrides.js, to their remote counterparts
  10. # : and display a desktop notification containing version info
  11. # Version : 2020-09-16
  12. # Copyright : 12bytes.org, 2020
  13. # License : GNU General Public License, version 3+
  14. # Dependencies : notify-send, curl
  15. # Author : 12bytes.org
  16. # Website : 12bytes.org / Firefox-user.js-supplement
  17. # : https://codeberg.org/12bytes.org/Firefox-user.js-supplement
  18. # Website : arkenfox/user.js
  19. # : https://github.com/arkenfox/user.js
  20. # Website : The Firefox Privacy Guide For Dummies!
  21. # : https://12bytes.org/articles/tech/firefox/the-firefox-privacy-guide-for-dummies/ – 12Bytes.org
  22. # Website : Firefox Configuration Guide for Privacy Freaks and Performance Buffs – 12Bytes.org
  23. # : https://12bytes.org/articles/tech/firefox/firefoxgecko-configuration-guide-for-privacy-and-performance-buffs/
  24. # Comment : Developed on Manjaro (Arch) Linux, GNU bash version 5.x
  25. #
  26. ## LICENSE
  27. # ------------------------------------------------------------------------------
  28. # This program is free software: you can redistribute it and/or modify
  29. # it under the terms of the GNU General Public License as published by
  30. # the Free Software Foundation, either version 3 of the License, or
  31. # (at your option) any later version.
  32. #
  33. # This program is distributed in the hope that it will be useful,
  34. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  35. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  36. # GNU General Public License for more details.
  37. #
  38. # You should have received a copy of the GNU General Public License
  39. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  40. #
  41. ## USAGE
  42. # ------------------------------------------------------------------------------
  43. # Place this script in your Firefox profile directory along side the 'arkenfox'
  44. # user.js file and make it executable. To run this script automatically you can
  45. # add it to your startup programs, or as a CRON job, a systemd timer, etc.
  46. #
  47. ## BEGIN USER CONFIGURATION
  48. # ------------------------------------------------------------------------------
  49. # Firefox profile directory - replace '<user>' and '<profile_name>' (no trailing
  50. # slash)
  51. sFfProfileDir='/home/<user>/.mozilla/firefox/<profile_name>'
  52. # check for updated user-overrides.js by 12bytes.org? ('yes' or 'no')
  53. sChkOverridesJs='yes'
  54. # how many seconds to wait after log-on before performing an update check
  55. sleep 20
  56. # ------------------------------------------------------------------------------
  57. ## END USER CONFIGURATION
  58. sScriptVer='2020-09-16'
  59. cd "$sFfProfileDir" || { echo "Failed to change directory!"; exit 1; }
  60. func_err () {
  61. notify-send -i dialog-error 'Firefox Config Update Notifier' "<b>ERROR: ${sErr}</b>"
  62. exit 1
  63. }
  64. # check for updated version of this script
  65. if sRemoteScript="$( curl -sm 30 'https://codeberg.org/12bytes.org/Firefox-user.js-supplement/raw/branch/master/misc/user.js-notify.sh' )" ; then
  66. if sRemoteScriptVer="$( echo "$sRemoteScript" | grep -Pom 1 '^# Version : \K.*' )" ; then
  67. if [[ "$sRemoteScriptVer" != "$sScriptVer" ]] ; then
  68. notify-send 'Firefox Config Update Notifier' 'Please update the Firefox Config Update Notifier script:<a href="https://codeberg.org/12bytes.org/Firefox-user.js-supplement/raw/branch/master/misc/user.js-notify.sh">DOWNLOAD</a>'
  69. exit 0
  70. fi
  71. else
  72. sErr="Failed to get version of remote Firefox Config Update Notifier script."
  73. func_err
  74. fi
  75. else
  76. sErr="Failed to read remote Firefox Config Update Notifier script."
  77. func_err
  78. fi
  79. # get firefox version
  80. if sFfVer="$( firefox --version | grep -Eo '[0-9]+\..*' )" ; then
  81. sNotify="<b>Firefox:</b> v${sFfVer}<br/>"
  82. else
  83. sErr="Failed to get Firefox version."
  84. func_err
  85. fi
  86. # get local user.js version and date
  87. if sLocalJsVer="$( grep -Pom 1 '^\* version \K[0-9]+.*' 'user.js' )" ; then
  88. # get local user.js date string
  89. if sLocalJsDate="$( grep -Pom 1 '^\* date: \K.*' 'user.js' )" ; then
  90. sNotify+="<b>Local user.js:</b> v${sLocalJsVer}, ${sLocalJsDate}<br/>"
  91. else
  92. sErr="Failed to get local user.js date."
  93. func_err
  94. fi
  95. else
  96. sErr="Failed to get local user.js version."
  97. func_err
  98. fi
  99. # read remote user.js
  100. if sRemoteJs="$( curl -sm 30 'https://raw.githubusercontent.com/arkenfox/user.js/master/user.js' )" ; then
  101. # get remote version and date
  102. if sRemoteJsVer="$( echo "$sRemoteJs" | grep -Pom 1 '^\* version \K.*' )" ; then
  103. if sRemoteJsDate="$( echo "$sRemoteJs" | grep -Pom 1 '^\* date: \K.*' )" ; then
  104. sNotify+='<b><a href="https://github.com/arkenfox/user.js">Remote user.js:</a></b> v'"${sRemoteJsVer}, ${sRemoteJsDate}<br/>"
  105. else
  106. sErr="Failed to get remote user.js date."
  107. func_err
  108. fi
  109. else
  110. sErr="Failed to get remote user.js version."
  111. func_err
  112. fi
  113. else
  114. sErr="Failed to read remote user.js."
  115. func_err
  116. fi
  117. # check for user-overrides.js
  118. if [[ "$sChkOverridesJs" == 'yes' ]] ; then
  119. # get local user-overrides.js version string
  120. if sLocalOverridesJsVer="$( grep -Pom 1 '^ \* version : \K.*' 'user-overrides.js' )" ; then
  121. sNotify+="<b>Local user-overrides.js:</b> v${sLocalOverridesJsVer}<br/>"
  122. else
  123. sErr="Failed to get local user-overrides.js version."
  124. func_err
  125. fi
  126. # read remote user-overrides.js
  127. if sRemoteOverridesJs="$( curl -sm 30 'https://codeberg.org/12bytes.org/Firefox-user.js-supplement/raw/branch/master/user-overrides.js' )" ; then
  128. # get remote version
  129. if sRemoteOverridesJsVer="$( echo "$sRemoteOverridesJs" | grep -Pom 1 '^ \* version : \K.*' )" ; then
  130. sNotify+='<b><a href="https://codeberg.org/12bytes.org/Firefox-user.js-supplement">Remote user-overrides.js</a>:</b> v'"${sRemoteOverridesJsVer}<br/>"
  131. else
  132. sErr="Failed to get remote user-overrides.js version."
  133. func_err
  134. fi
  135. else
  136. sErr="Failed to read remote user-overrides.js."
  137. func_err
  138. fi
  139. fi
  140. # notify-send icons: https://specifications.freedesktop.org/icon-naming-spec/latest/ar01s04.html
  141. notify-send 'Firefox Config Update Notifier' "<br/>${sNotify}"