a user-overrides.js supplement intended to be appended to the 'arkenfox' (formerly '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.
 
 

222 lines
9.6 KiB

#!/usr/bin/env bash
#
## SCRIPT INFORMATION
# ------------------------------------------------------------------------------
# Name : Firefox Config Update Notifier
# Version : 21-MAR-2021
# Description : * compare versions of local and remote 'arkenfox' user.js
# : * optionally, compare versions of local and remote
# : user-overrides.js from 12bytes.org
# : * optionally, check the last update date for The Firefox
# : Privacy Guide For Dummies! from 12bytes.org
# : * optionally, check the last update date for the Firefox
# : Configuration Guide for Privacy Freaks and Performance Buffs
# : from 12bytes.org
# : * display a desktop notification containing a compilation of
# : the information collected
# Copyright : 12bytes.org, 2021
# License : GNU General Public License, version 3+
# Requirements : Linux OS
# Dependencies : bash, notify-send, curl
# Author : 12bytes.org
# Website : 12bytes.org/Firefox-user.js-supplement - Codeberg
# : https://codeberg.org/12bytes.org/Firefox-user.js-supplement
# Website : arkenfox/user.js - GitHub
# : https://github.com/arkenfox/user.js
# Website : The Firefox Privacy Guide For Dummies! - 12bytes.org
# : https://12bytes.org/articles/tech/firefox/the-firefox-privacy-guide-for-dummies/ – 12Bytes.org
# Website : Firefox Configuration Guide for Privacy Freaks and Performance Buffs – 12Bytes.org
# : https://12bytes.org/articles/tech/firefox/firefoxgecko-configuration-guide-for-privacy-and-performance-buffs/
# Comment : Developed on Manjaro (Arch) Linux, GNU bash version 5.x
#
## LICENSE
# ------------------------------------------------------------------------------
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
## USAGE
# ------------------------------------------------------------------------------
# Edit the variables below then place this script somewhere, perhaps in your
# Home or Firefox profile directory, and make it executable. To run this script
# manually in a terminal (set 'iSec' to '0' for testing):
# ./user.js-notify.sh
# To run this script automatically you can add it to your startup programs, as a
# CRON job, a systemd timer, etc.
#
## EDIT THESE VARIABLES
# ------------------------------------------------------------------------------
# the path to your Firefox profile directory)
sFfProfileDir='/home/<user>/.mozilla/firefox/<profile>/'
# in addition to checling for an updated 'arkenfox' user.js, shall we check for
# an updated user-overrides.js by 12bytes.org as well? ('yes' or 'no')
sChkOverridesJs='yes'
# do you want to see the last update date for 'The Firefox Privacy Guide for
# Dummies!'? ('yes' or 'no')
sCheckDummyGuide='yes'
# do you want to see the last update date for the 'Firefox Configuration Guide
# for Privacy Freaks and Performance Buffs'? ('yes' or 'no')
sCheckProGuide='yes'
# how many seconds to wait after log-on before performing an update check
iSec=5
# ------------------------------------------------------------------------------
## STOP EDITING
sScriptVer='21-MAR-2021' # NOTICE update version string in description
sScriptUrl='https://codeberg.org/12bytes.org/Firefox-user.js-supplement/raw/branch/master/misc/user.js-notify.sh'
# NOTICE testing...
#sScriptUrl='https://codeberg.org/12bytes.org/Firefox-user.js-supplement/raw/branch/master/testing/user.js-notify.sh'
sUserJsUrl='https://raw.githubusercontent.com/arkenfox/user.js/master/user.js'
sUserJsRepoUrl='https://github.com/arkenfox/user.js'
sUserOverridesJsUrl='https://codeberg.org/12bytes.org/Firefox-user.js-supplement/raw/branch/master/user-overrides.js'
sUserOverridesJsRepoUrl='https://codeberg.org/12bytes.org/Firefox-user.js-supplement'
sDummyGuideUrl='https://12bytes.org/articles/tech/firefox/the-firefox-privacy-guide-for-dummies/'
sDummyGuideHistoryUrl='https://12bytes.org/articles/tech/firefox/the-firefox-privacy-guide-for-dummies/#Revisions'
sProGuideUrl='https://12bytes.org/articles/tech/firefox/firefoxgecko-configuration-guide-for-privacy-and-performance-buffs/'
sProGuideHistoryUrl='https://12bytes.org/articles/tech/firefox/firefoxgecko-configuration-guide-for-privacy-and-performance-buffs/#Revision_history'
sleep $iSec
func_err () {
# if $1 = 1 then exit, else return
notify-send -a 'Firefox' 'Config Update Notifier...' "$sErr"
if [[ "$1" -eq 1 ]] ; then
exit 1
fi
}
# CD to profile directory
cd "$sFfProfileDir" || {
sErr='<b>ERROR</b>: Failed to change to the Firefox profile directory! Please check the path specified for the "sFfProfileDir" option.'
func_err 1
}
# get local firefox version
if sFfVer="$( firefox --version | grep -Eo '[0-9]+\..*' )" ; then
sNotify="Firefox: $sFfVer"
else
sErr='<b>ERROR</b>: Failed to get local Firefox version!'
func_err 1
fi
# check for updated version of this script
if sRemoteScript="$( curl -sm 30 "$sScriptUrl" )" ; then
if sRemoteScriptVer="$( echo "$sRemoteScript" | grep -Pom 1 '^# Version : \K.*' )" ; then
if [[ "$sRemoteScriptVer" != "$sScriptVer" ]] ; then
sErr='<b>UPDATE</b>: Please <a href="'"$sScriptUrl"'">update</a> this user.js-notify.sh script!'
func_err 0
fi
else
sErr='<b>ERROR</b>: Failed to get version of remote user.js-notify.sh!'
func_err 1
fi
else
sErr='<b>ERROR</b>: Failed to read remote user.js-notify.sh!'
func_err 1
fi
# get local user.js version
if sLocalJsVer="$( grep -Pom 1 '^\* version \K[0-9]+.*' 'user.js' )" ; then
sNotify+="<br/>user.js: $sLocalJsVer"
else
sErr='<b>ERROR</b>: Failed to get local user.js version!'
func_err 1
fi
# get local and remote user-overrides.js versions
if [[ "$sChkOverridesJs" == 'yes' ]] ; then
# get local user-overrides.js version string
if sLocalOverridesJsVer="$( grep -Pom 1 '^ \* version : \K.*' 'user-overrides.js' )" ; then
sNotify+="<br/>user-overrides.js: $sLocalOverridesJsVer"
else
sErr='<b>ERROR</b>: Failed to get local user-overrides.js version!'
func_err 1
fi
# read remote user-overrides.js
if sRemoteOverridesJs="$( curl -sm 30 "$sUserOverridesJsUrl" )" ; then
# get remote version
if ! sRemoteOverridesJsVer="$( echo "$sRemoteOverridesJs" | grep -Pom 1 '^ \* version : \K.*' )" ; then
sErr='<b>ERROR</b>: Failed to get remote user-overrides.js version!'
func_err 1
fi
else
sErr='<b>ERROR</b>: Failed to read remote user-overrides.js!'
func_err 1
fi
fi
# read remote user.js
if sRemoteJs="$( curl -sm 30 "$sUserJsUrl" )" ; then
# get remote version
if ! sRemoteJsVer="$( echo "$sRemoteJs" | grep -Pom 1 '^\* version \K.*' )" ; then
sErr='<b>ERROR</b>: Failed to get remote user.js version!'
func_err 1
fi
else
sErr='<b>ERROR</b>: Failed to read remote user.js!'
func_err 1
fi
# compare local and remote user.js versions
if [ "$sLocalJsVer" == "$sRemoteJsVer" ] ; then
sNotify+='<br/>Local and <a href="'"$sUserJsRepoUrl"'">remote</a> user.js versions match!'
else
sNotify+='<br/><b>UPDATE</b>: <a href="'"$sUserJsRepoUrl"'">Remote user.js:</a>: '"$sRemoteJsVer"
fi
# compare local and remote user-overrides.js versions
if [ "$sLocalOverridesJsVer" == "$sRemoteOverridesJsVer" ] ; then
sNotify+='<br/>Local and <a href="'"$sUserOverridesJsRepoUrl"'">remote</a> user-overrides.js versions match!'
else
sNotify+='<br/><b>UPDATE</b>: <a href="'"$sUserOverridesJsRepoUrl"'">Remote user-overrides.js</a>: '"$sRemoteOverridesJsVer"
fi
# check last update date for Firefox 'dummy' guide at 12bytes.org
if [[ "$sCheckDummyGuide" == 'yes' ]] ; then
if sDummyGuide="$( curl -sm 30 "$sDummyGuideUrl" )" ; then
if sDummyGuideDate="$( echo "$sDummyGuide" | grep -Pom 1 'Last modified: \K[A-Za-z]*\s\d{1,2},\s20\d{2}' )" ; then
sNotify+='<br/><a href="'"$sDummyGuideUrl"'">Dummy guide</a> date: '"$sDummyGuideDate"' (<a href="'$sDummyGuideHistoryUrl'">history</a>)'
else
sErr='<b>ERROR</b>: Failed find the last modified date for the "Dummy" guide!'
func_err 0
fi
else
sErr='<b>ERROR</b>: Failed to fetch the "Dummy" guide!'
func_err 0
fi
fi
# check last update date for Firefox 'pro' guide at 12bytes.org
if [[ "$sCheckProGuide" == 'yes' ]] ; then
if sProGuide="$( curl -sm 30 "$sProGuideUrl" )" ; then
if sProGuideDate="$( echo "$sProGuide" | grep -Pom 1 'Last modified: \K[A-Za-z]*\s\d{1,2},\s20\d{2}' )" ; then
sNotify+='<br/><a href="'"$sProGuideUrl"'">Pro guide</a> date: '"$sProGuideDate"' (<a href="'"$sProGuideHistoryUrl"'">history</a>)'
else
sErr='<b>ERROR</b>: Failed find the last modified date for the "Pro" guide!'
func_err 0
fi
else
sErr='<b>ERROR</b>: Failed to fetch the "Pro" guide!'
func_err 0
fi
fi
# display accumulated messages
notify-send -a 'Firefox' 'Config Update Notifier...' "$sNotify"