mirror of
https://github.com/arkenfox/user.js.git
synced 2025-09-01 09:28:31 +02:00
Compare commits
91 Commits
v62.0-beta
...
63.0
Author | SHA1 | Date | |
---|---|---|---|
205c48d9d3 | |||
0e1b0a4b6e | |||
778dc89bb6 | |||
23733097a9 | |||
71a2d393f3 | |||
74ebacc0dd | |||
45e3b3a0e0 | |||
8172f730d3 | |||
5c85e61bb4 | |||
0a67cdec8b | |||
b85668c2cd | |||
786839ffc1 | |||
8313f2e01a | |||
0a87c99a0e | |||
91fed43fc7 | |||
74f029566e | |||
571be93ae0 | |||
11b16c9c6d | |||
c4ec4dbc77 | |||
67998eb4af | |||
834857b564 | |||
25923f1acd | |||
85eaba2571 | |||
51237f6889 | |||
74e753d0c5 | |||
db56940422 | |||
400d764a93 | |||
f3e2bfa76d | |||
d4907faa8e | |||
62351bfbf5 | |||
b182946ae4 | |||
2ae3a3e4e1 | |||
0ff610c056 | |||
661a314e28 | |||
106f46d053 | |||
643cba63cf | |||
b5c5d8e9d1 | |||
36b90cd5e6 | |||
299a03663f | |||
13550d18a1 | |||
c12eb0fdc6 | |||
acbf881b1f | |||
7351e561c4 | |||
4e42bad6a1 | |||
b85e748b53 | |||
0cc4007eda | |||
3003f2dd85 | |||
ce48306a0d | |||
3423d39fa9 | |||
4834472107 | |||
f214e4bc4e | |||
8fd6061bcc | |||
92acb6b2f7 | |||
b6b9733afa | |||
89bc0bee16 | |||
f8fc465d0a | |||
58fa4e9b6d | |||
afee555045 | |||
5a36b4e016 | |||
7b3e6f5143 | |||
452c717502 | |||
661af196d9 | |||
39a30d710b | |||
8f10300c15 | |||
806d047729 | |||
0efebe3e83 | |||
49d9314b0a | |||
b4b5e3a068 | |||
29d832e350 | |||
68e44285c5 | |||
e8bfa93696 | |||
1abe1fd4df | |||
24f7847f73 | |||
56206f77ba | |||
587194ce84 | |||
7aac6d476a | |||
9e073ea5d5 | |||
732c438148 | |||
58931bc15d | |||
21b18cbe49 | |||
cbcd293e68 | |||
aacf5d4a0b | |||
ec5fb6e3a1 | |||
b2fc9bc266 | |||
ca1cc2001f | |||
f88af1dac6 | |||
1c6c5ea2ff | |||
2d316ceedd | |||
36c791c4bc | |||
ee213f2bab | |||
01a978e33a |
20
README.md
20
README.md
@ -1,21 +1,27 @@
|
|||||||
###  user.js
|
### ![][b] user.js
|
||||||
A `user.js` is a configuration file that can control hundreds of Firefox settings. For a more technical breakdown and explanation, you can read more on the [overview](https://github.com/ghacksuserjs/ghacks-user.js/wiki/1.1-Overview) wiki page.
|
A `user.js` is a configuration file that can control hundreds of Firefox settings. For a more technical breakdown and explanation, you can read more on the [overview](https://github.com/ghacksuserjs/ghacks-user.js/wiki/1.1-Overview) wiki page.
|
||||||
|
|
||||||
###  ghacks user.js
|
### ![][b] ghacks user.js
|
||||||
The `ghacks user.js` is a **template**, which, as provided, aims to provide as much privacy and enhanced security as possible, and to reduce tracking and fingerprinting as much as possible - while minimizing any loss of functionality and breakage (but it will happen).
|
The `ghacks user.js` is a **template** which aims to provide as much privacy and enhanced security as possible, and to reduce tracking and fingerprinting as much as possible - while minimizing any loss of functionality and breakage (but it will happen).
|
||||||
|
|
||||||
Everyone, experts included, should at least read the [implementation](https://github.com/ghacksuserjs/ghacks-user.js/wiki/1.3-Implementation) wiki page, as it contains important information regarding a few `ghacks user.js` settings.
|
Everyone, experts included, should at least read the [implementation](https://github.com/ghacksuserjs/ghacks-user.js/wiki/1.3-Implementation) wiki page, as it contains important information regarding a few `ghacks user.js` settings.
|
||||||
|
|
||||||
|
Note that we do *not* recommend connecting over Tor on Firefox. Use the [Tor Browser](https://www.torproject.org/projects/torbrowser.html.en) if your [threat model](https://www.torproject.org/about/torusers.html.en) calls for it, or for accessing hidden services.
|
||||||
|
|
||||||
|
Also be aware that this `user.js` is made specifically for Firefox. Using it as-is in other Gecko-based browsers can be counterproductive, especially in the Tor Browser.
|
||||||
|
|
||||||
Sitemap: [Releases](https://github.com/ghacksuserjs/ghacks-user.js/releases), [changelogs](https://github.com/ghacksuserjs/ghacks-user.js/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3Achangelog), [Wiki](https://github.com/ghacksuserjs/ghacks-user.js/wiki), [stickies](https://github.com/ghacksuserjs/ghacks-user.js/issues?q=is%3Aissue+is%3Aopen+label%3A%22sticky+topic%22). [diffs](https://github.com/ghacksuserjs/ghacks-user.js/issues?q=is%3Aissue+label%3Adiffs)
|
Sitemap: [Releases](https://github.com/ghacksuserjs/ghacks-user.js/releases), [changelogs](https://github.com/ghacksuserjs/ghacks-user.js/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3Achangelog), [Wiki](https://github.com/ghacksuserjs/ghacks-user.js/wiki), [stickies](https://github.com/ghacksuserjs/ghacks-user.js/issues?q=is%3Aissue+is%3Aopen+label%3A%22sticky+topic%22). [diffs](https://github.com/ghacksuserjs/ghacks-user.js/issues?q=is%3Aissue+label%3Adiffs)
|
||||||
|
|
||||||
###  acknowledgments
|
### ![][b] acknowledgments
|
||||||
Literally thousands of sources, references and suggestions. That said...
|
Literally thousands of sources, references and suggestions. That said...
|
||||||
|
|
||||||
* Martin Brinkmann at [ghacks](https://www.ghacks.net/) <sup>1</sup>
|
* Martin Brinkmann at [ghacks](https://www.ghacks.net/) <sup>1</sup>
|
||||||
* The ghacks community and commentators
|
* The ghacks community and commentators
|
||||||
* [12bytes](http://12bytes.org/tech/firefox/firefoxgecko-configuration-guide-for-privacy-and-performance-buffs)
|
* [12bytes](https://12bytes.org/articles/tech/firefox/firefoxgecko-configuration-guide-for-privacy-and-performance-buffs)
|
||||||
* The 12bytes article now uses this user.js and supplements it with an additonal JS hosted right [here](https://github.com/atomGit/Firefox-user.js) at github
|
* The 12bytes article now uses this user.js and supplements it with an additional JS hosted at [GitLab](https://gitlab.com/labwrat/Firefox-user.js/tree/master)
|
||||||
|
|
||||||
<sup>1</sup> The ghacks user.js was an independent project by [Thorin-Oakenpants](https://github.com/Thorin-Oakenpants) started in early 2015 and was [first published](https://www.ghacks.net/2015/08/18/a-comprehensive-list-of-firefox-privacy-and-security-settings/) at ghacks in August 2015. With Martin Brinkmann's blessing, it will keep the ghacks name.
|
<sup>1</sup> The ghacks user.js was an independent project by [Thorin-Oakenpants](https://github.com/Thorin-Oakenpants) started in early 2015 and was [first published](https://www.ghacks.net/2015/08/18/a-comprehensive-list-of-firefox-privacy-and-security-settings/) at ghacks in August 2015. With Martin Brinkmann's blessing, it will keep the ghacks name.
|
||||||
|
|
||||||
###  [](https://opensource.org/licenses/MIT)
|
### ![][b] [](https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
[b]: /wikipiki/bullet01.png
|
||||||
|
@ -1 +1,3 @@
|
|||||||
theme: jekyll-theme-midnight
|
theme: jekyll-theme-midnight
|
||||||
|
title: ghacks-user.js
|
||||||
|
description: An ongoing comprehensive user.js template for configuring and hardening Firefox privacy, security and anti-fingerprinting
|
||||||
|
@ -36,7 +36,8 @@
|
|||||||
'camera.control.face_detection.enabled',
|
'camera.control.face_detection.enabled',
|
||||||
'dom.disable_window_status_change',
|
'dom.disable_window_status_change',
|
||||||
'dom.idle-observers-api.enabled',
|
'dom.idle-observers-api.enabled',
|
||||||
/* 58 : nothing */
|
/* 58 */
|
||||||
|
'browser.crashReports.unsubmittedCheck.autoSubmit',
|
||||||
/* 57 */
|
/* 57 */
|
||||||
'social.whitelist',
|
'social.whitelist',
|
||||||
'social.toast-notifications.enabled',
|
'social.toast-notifications.enabled',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/***
|
/***
|
||||||
This will reset the preferences that have been removed completely from the ghacks user.js.
|
This will reset the preferences that have been removed completely from the ghacks user.js.
|
||||||
|
|
||||||
Last updated: 08-Sept-2018
|
Last updated: 18-Mov-2018
|
||||||
|
|
||||||
For instructions see:
|
For instructions see:
|
||||||
https://github.com/ghacksuserjs/ghacks-user.js/wiki/3.1-Resetting-Inactive-Prefs-[Scripts]
|
https://github.com/ghacksuserjs/ghacks-user.js/wiki/3.1-Resetting-Inactive-Prefs-[Scripts]
|
||||||
@ -102,6 +102,12 @@
|
|||||||
/* 62-beta */
|
/* 62-beta */
|
||||||
'browser.urlbar.autoFill.typed',
|
'browser.urlbar.autoFill.typed',
|
||||||
'security.tls.version.fallback-limit',
|
'security.tls.version.fallback-limit',
|
||||||
|
/* 63-beta */
|
||||||
|
'extensions.webextensions.keepStorageOnUninstall',
|
||||||
|
'extensions.webextensions.keepUuidOnUninstall',
|
||||||
|
'privacy.trackingprotection.ui.enabled',
|
||||||
|
/* 64-beta */
|
||||||
|
'browser.eme.ui.enabled',
|
||||||
/* reset parrot: check your open about:config after running the script */
|
/* reset parrot: check your open about:config after running the script */
|
||||||
'_user.js.parrot'
|
'_user.js.parrot'
|
||||||
]
|
]
|
||||||
|
491
updater.sh
491
updater.sh
@ -1,129 +1,424 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
### ghacks-user.js updater for Mac/Linux
|
## ghacks-user.js updater for macOS and Linux
|
||||||
## author: @overdodactyl, @ema-pe
|
|
||||||
## version: 1.4
|
|
||||||
|
|
||||||
## DON'T GO HIGHER THAN VERSION x.9 !! ( because of ASCII comparison in check_for_update() )
|
## version: 2.4
|
||||||
|
## Author: Pat Johnson (@overdodactyl)
|
||||||
|
## Additional contributors: @earthlng, @ema-pe, @claustromaniac
|
||||||
|
|
||||||
ghacksjs="https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js"
|
## DON'T GO HIGHER THAN VERSION x.9 !! ( because of ASCII comparison in update_updater() )
|
||||||
updater="https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.sh"
|
|
||||||
update_pref=${1:--ask}
|
|
||||||
|
|
||||||
currdir=$(pwd)
|
readonly CURRDIR=$(pwd)
|
||||||
|
|
||||||
DOWNLOAD_TO_STDOUT="curl -s"
|
sfp=$(readlink -f "${BASH_SOURCE[0]}" 2>/dev/null || greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null)
|
||||||
DOWNLOAD_TO_FILE="curl -O"
|
if [ -z "$sfp" ]; then sfp=${BASH_SOURCE[0]}; fi
|
||||||
|
readonly SCRIPT_DIR=$(dirname "${sfp}")
|
||||||
|
|
||||||
# Use wget if curl is not available.
|
|
||||||
if [[ -z $(command -v "curl") ]]; then
|
#########################
|
||||||
DOWNLOAD_TO_STDOUT="wget --quiet --output-document=-"
|
# Base variables #
|
||||||
DOWNLOAD_TO_FILE="wget"
|
#########################
|
||||||
|
|
||||||
|
# Colors used for printing
|
||||||
|
RED='\033[0;31m'
|
||||||
|
BLUE='\033[0;34m'
|
||||||
|
BBLUE='\033[1;34m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
ORANGE='\033[0;33m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
# Argument defaults
|
||||||
|
UPDATE='check'
|
||||||
|
CONFIRM='yes'
|
||||||
|
OVERRIDE='user-overrides.js'
|
||||||
|
BACKUP='multiple'
|
||||||
|
COMPARE=false
|
||||||
|
SKIPOVERRIDE=false
|
||||||
|
VIEW=false
|
||||||
|
PROFILE_PATH=false
|
||||||
|
ESR=false
|
||||||
|
|
||||||
|
# Download method priority: curl -> wget
|
||||||
|
DOWNLOAD_METHOD=''
|
||||||
|
if [[ $(command -v 'curl') ]]; then
|
||||||
|
DOWNLOAD_METHOD='curl'
|
||||||
|
elif [[ $(command -v 'wget') ]]; then
|
||||||
|
DOWNLOAD_METHOD='wget'
|
||||||
|
else
|
||||||
|
echo -e "${RED}This script requires curl or wget.\nProcess aborted${NC}"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## get the full path of this script (readlink for Linux, greadlink for Mac with coreutils installed)
|
|
||||||
sfp=$(readlink -f "${BASH_SOURCE[0]}" 2>/dev/null || greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null)
|
|
||||||
|
|
||||||
## fallback for Macs without coreutils
|
show_banner () {
|
||||||
if [ -z "$sfp" ]; then sfp=${BASH_SOURCE[0]}; fi
|
echo -e "${BBLUE}\n"
|
||||||
|
echo ' ############################################################################'
|
||||||
|
echo ' #### ####'
|
||||||
|
echo ' #### ghacks user.js ####'
|
||||||
|
echo ' #### Hardening the Privacy and Security Settings of Firefox ####'
|
||||||
|
echo ' #### Maintained by @Thorin-Oakenpants and @earthlng ####'
|
||||||
|
echo ' #### Updater for macOS and Linux by @overdodactyl ####'
|
||||||
|
echo ' #### ####'
|
||||||
|
echo ' ############################################################################'
|
||||||
|
echo -e "${NC}\n"
|
||||||
|
echo -e "Documentation for this script is available here: ${CYAN}https://github.com/ghacksuserjs/ghacks-user.js/wiki/3.3-Updater-Scripts${NC}\n"
|
||||||
|
}
|
||||||
|
|
||||||
## change directory to the Firefox profile directory
|
#########################
|
||||||
cd "$(dirname "${sfp}")"
|
# Arguments #
|
||||||
|
#########################
|
||||||
|
|
||||||
## Used to check if a new version of updater.sh is available
|
usage() {
|
||||||
update_available="no"
|
echo -e "${BLUE}\nUsage: $0 [-h] [-p PROFILE] [-u] [-d] [-s] [-n] [-b] [-c] [-v] [-r] [-e] [-o OVERRIDE]\n${NC}" 1>&2 # Echo usage string to standard error
|
||||||
check_for_update () {
|
echo 'Optional Arguments:'
|
||||||
online_version="$($DOWNLOAD_TO_STDOUT ${updater} | sed -n '5 s/.*[[:blank:]]\([[:digit:]]*\.[[:digit:]]*\)/\1/p')"
|
echo -e "\t-h,\t\t Show this help message and exit."
|
||||||
path_to_script="$(dirname "${sfp}")/updater.sh"
|
echo -e "\t-p PROFILE,\t Path to your Firefox profile (if different than the dir of this script)"
|
||||||
current_version="$(sed -n '5 s/.*[[:blank:]]\([[:digit:]]*\.[[:digit:]]*\)/\1/p' "$path_to_script")"
|
echo -e "\t\t\t IMPORTANT: if the path include spaces, wrap the entire argument in quotes."
|
||||||
if [[ "$current_version" < "$online_version" ]]; then
|
echo -e "\t-l, \t\t Choose your Firefox profile from a list"
|
||||||
update_available="yes"
|
echo -e "\t-u,\t\t Update updater.sh and execute silently. Do not seek confirmation."
|
||||||
|
echo -e "\t-d,\t\t Do not look for updates to updater.sh."
|
||||||
|
echo -e "\t-s,\t\t Silently update user.js. Do not seek confirmation."
|
||||||
|
echo -e "\t-b,\t\t Only keep one backup of each file."
|
||||||
|
echo -e "\t-c,\t\t Create a diff file comparing old and new user.js within userjs_diffs. "
|
||||||
|
echo -e "\t-o OVERRIDE,\t Filename or path to overrides file (if different than user-overrides.js)."
|
||||||
|
echo -e "\t\t\t If used with -p, paths should be relative to PROFILE or absolute paths"
|
||||||
|
echo -e "\t\t\t If given a directory, all files inside will be appended recursively."
|
||||||
|
echo -e "\t\t\t You can pass multiple files or directories by passing a comma separated list."
|
||||||
|
echo -e "\t\t\t\t Note: If a directory is given, only files inside ending in the extension .js are appended"
|
||||||
|
echo -e "\t\t\t\t IMPORTANT: do not add spaces between files/paths. Ex: -o file1.js,file2.js,dir1"
|
||||||
|
echo -e "\t\t\t\t IMPORTANT: if any files/paths include spaces, wrap the entire argument in quotes."
|
||||||
|
echo -e "\t\t\t\t\t Ex: -o \"override folder\" "
|
||||||
|
echo -e "\t-n,\t\t Do not append any overrides, even if user-overrides.js exists."
|
||||||
|
echo -e "\t-v,\t\t Open the resulting user.js file."
|
||||||
|
echo -e "\t-r,\t\t Only download user.js to a temporary file and open it."
|
||||||
|
echo -e "\t-e,\t\t Activate ESR related preferences."
|
||||||
|
echo -e
|
||||||
|
echo 'Deprecated Arguments (they still work for now):'
|
||||||
|
echo -e "\t-donotupdate,\t Use instead -d"
|
||||||
|
echo -e "\t-update,\t Use instead -u"
|
||||||
|
echo -e
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
legacy_argument () {
|
||||||
|
echo -e "${ORANGE}\nWarning: command line arguments have changed."
|
||||||
|
echo -e "$1 has been deprecated and may not work in the future.\n"
|
||||||
|
echo -e "Please view the new options using the -h argument.${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# File Handling #
|
||||||
|
#########################
|
||||||
|
|
||||||
|
# Download files
|
||||||
|
download_file () {
|
||||||
|
declare -r url=$1
|
||||||
|
declare -r tf=$(mktemp)
|
||||||
|
local dlcmd=''
|
||||||
|
|
||||||
|
if [ $DOWNLOAD_METHOD = 'curl' ]; then
|
||||||
|
dlcmd="curl -o $tf"
|
||||||
|
else
|
||||||
|
dlcmd="wget -O $tf"
|
||||||
|
fi
|
||||||
|
|
||||||
|
$dlcmd "${url}" &>/dev/null && echo "$tf" || echo '' # return the temp-filename (or empty string on error)
|
||||||
|
}
|
||||||
|
|
||||||
|
open_file () { #expects one argument: file_path
|
||||||
|
if [ "$(uname)" == 'Darwin' ]; then
|
||||||
|
open "$1"
|
||||||
|
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
|
||||||
|
xdg-open "$1"
|
||||||
|
else
|
||||||
|
echo -e "${RED}Error: Sorry, opening files is not supported for your OS.${NC}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## Used to backup the current script, and download and execute the latest version of updater.sh
|
readIniFile () { # expects one argument: absolute path of profiles.ini
|
||||||
update_script () {
|
declare -r inifile="$1"
|
||||||
echo -e "This script will be backed up and the latest version of updater.sh will be executed.\n"
|
declare -r tfile=$(mktemp)
|
||||||
mv updater.sh "updater.sh.backup.$(date +"%Y-%m-%d_%H%M")"
|
|
||||||
$DOWNLOAD_TO_FILE ${updater} && echo -e "\nThe latest updater script has been downloaded\n"
|
|
||||||
|
|
||||||
# make new file executable
|
if [ $(grep '^\[Profile' "$inifile" | wc -l) == "1" ]; then ### only 1 profile found
|
||||||
chmod +x updater.sh
|
grep '^\[Profile' -A 4 "$inifile" | grep -v '^\[Profile' > $tfile
|
||||||
|
else
|
||||||
|
grep -E -v '^\[General\]|^StartWithLastProfile=|^IsRelative=' "$inifile"
|
||||||
|
echo ''
|
||||||
|
read -p 'Select the profile number ( 0 for Profile0, 1 for Profile1, etc ) : ' -r
|
||||||
|
echo -e "\n"
|
||||||
|
if [[ $REPLY =~ ^(0|[1-9][0-9]*)$ ]]; then
|
||||||
|
grep '^\[Profile'${REPLY} -A 4 "$inifile" | grep -v '^\[Profile'${REPLY} > $tfile
|
||||||
|
if [[ "$?" != "0" ]]; then
|
||||||
|
echo "Profile${REPLY} does not exist!" && exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Invalid selection!" && exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# execute new updater script
|
declare -r profpath=$(grep '^Path=' $tfile)
|
||||||
./updater.sh -donotupdate
|
declare -r pathisrel=$(grep '^IsRelative=' $tfile)
|
||||||
|
|
||||||
# exit script
|
rm "$tfile"
|
||||||
|
|
||||||
|
# update global variable
|
||||||
|
if [[ ${pathisrel#*=} == "1" ]]; then
|
||||||
|
PROFILE_PATH="$(dirname "$inifile")/${profpath#*=}"
|
||||||
|
else
|
||||||
|
PROFILE_PATH="${profpath#*=}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
getProfilePath () {
|
||||||
|
declare -r f1=~/Library/Application\ Support/Firefox/profiles.ini
|
||||||
|
declare -r f2=~/.mozilla/firefox/profiles.ini
|
||||||
|
|
||||||
|
if [ "$PROFILE_PATH" = false ]; then
|
||||||
|
PROFILE_PATH="$SCRIPT_DIR"
|
||||||
|
elif [ "$PROFILE_PATH" = 'list' ]; then
|
||||||
|
local ini=''
|
||||||
|
if [[ -f "$f1" ]]; then
|
||||||
|
ini="$f1"
|
||||||
|
elif [[ -f "$f2" ]]; then
|
||||||
|
ini="$f2"
|
||||||
|
else
|
||||||
|
echo -e "${RED}Error: Sorry, -l is not supported for your OS${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
readIniFile "$ini" # updates PROFILE_PATH or exits on error
|
||||||
|
#else
|
||||||
|
# PROFILE_PATH already set by user with -p
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Update updater.sh #
|
||||||
|
#########################
|
||||||
|
|
||||||
|
# Returns the version number of a updater.sh file
|
||||||
|
get_updater_version () {
|
||||||
|
echo $(sed -n '5 s/.*[[:blank:]]\([[:digit:]]*\.[[:digit:]]*\)/\1/p' "$1")
|
||||||
|
}
|
||||||
|
|
||||||
|
# Update updater.sh
|
||||||
|
# Default: Check for update, if available, ask user if they want to execute it
|
||||||
|
# Args:
|
||||||
|
# -donotupdate: New version will not be looked for and update will not occur
|
||||||
|
# -update: Check for update, if available, execute without asking
|
||||||
|
update_updater () {
|
||||||
|
if [ $UPDATE = 'no' ]; then
|
||||||
|
return 0 # User signified not to check for updates
|
||||||
|
fi
|
||||||
|
|
||||||
|
declare -r tmpfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.sh')
|
||||||
|
|
||||||
|
if [[ $(get_updater_version "${SCRIPT_DIR}/updater.sh") < $(get_updater_version "${tmpfile}") ]]; then
|
||||||
|
if [ $UPDATE = 'check' ]; then
|
||||||
|
echo -e "There is a newer version of updater.sh available. ${RED}Update and execute Y/N?${NC}"
|
||||||
|
read -p "" -n 1 -r
|
||||||
|
echo -e "\n\n"
|
||||||
|
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||||
|
return 0 # Update available, but user chooses not to update
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
return 0 # No update available
|
||||||
|
fi
|
||||||
|
mv "${tmpfile}" "${SCRIPT_DIR}/updater.sh"
|
||||||
|
chmod u+x "${SCRIPT_DIR}/updater.sh"
|
||||||
|
"${SCRIPT_DIR}/updater.sh" "$@ -d"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
main () {
|
#########################
|
||||||
## create backup folder if it doesn't exist
|
# Update user.js #
|
||||||
mkdir -p userjs_backups;
|
#########################
|
||||||
|
|
||||||
echo -e "\nThis script should be run from your Firefox profile directory.\n"
|
# Returns version number of a user.js file
|
||||||
|
get_userjs_version () {
|
||||||
echo -e "Updating the user.js for Firefox profile:\n$(pwd)\n"
|
if [ -e $1 ]; then
|
||||||
|
echo "$(sed -n '4p' "$1")"
|
||||||
if [ -e user.js ]; then
|
|
||||||
echo "Your current user.js file for this profile will be backed up and the latest ghacks version from github will take its place."
|
|
||||||
echo -e "\nIf currently using the ghacks user.js, please compare versions:"
|
|
||||||
echo " Available online: $($DOWNLOAD_TO_STDOUT ${ghacksjs} | sed -n '4p')"
|
|
||||||
echo " Currently using: $(sed -n '4p' user.js)"
|
|
||||||
else
|
else
|
||||||
echo "A user.js file does not exist in this profile. If you continue, the latest ghacks version from github will be downloaded."
|
echo "Not detected."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\nIf a user-overrides.js file exists in this profile, it will be appended to the user.js.\n"
|
|
||||||
|
|
||||||
read -p "Continue Y/N? " -n 1 -r
|
|
||||||
echo -e "\n\n"
|
|
||||||
|
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
||||||
if [ -e user.js ]; then
|
|
||||||
# backup current user.js
|
|
||||||
bakfile="userjs_backups/user.js.backup.$(date +"%Y-%m-%d_%H%M")"
|
|
||||||
mv user.js "${bakfile}" && echo "Your previous user.js file was backed up: ${bakfile}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# download latest ghacks user.js
|
|
||||||
echo "downloading latest ghacks user.js file"
|
|
||||||
$DOWNLOAD_TO_FILE ${ghacksjs} && echo "ghacks user.js has been downloaded"
|
|
||||||
|
|
||||||
if [ -e user-overrides.js ]; then
|
|
||||||
echo "user-overrides.js file found"
|
|
||||||
cat user-overrides.js >> user.js && echo "user-overrides.js has been appended to user.js"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Process aborted"
|
|
||||||
fi
|
|
||||||
|
|
||||||
## change directory back to the original working directory
|
|
||||||
cd "${currdir}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_override () {
|
||||||
update_pref="$(echo $update_pref | tr '[A-Z]' '[a-z]')"
|
input=$1
|
||||||
if [ $update_pref = "-donotupdate" ]; then
|
if [ -f "$input" ]; then
|
||||||
main
|
echo "" >> user.js
|
||||||
else
|
cat "$input" >> user.js
|
||||||
check_for_update
|
echo -e "Status: ${GREEN}Override file appended:${NC} ${input}"
|
||||||
if [ $update_available = "no" ]; then
|
elif [ -d "$input" ]; then
|
||||||
main
|
FSAVEIFS=$IFS
|
||||||
|
IFS=$'\n\b' # Set IFS
|
||||||
|
FILES="${input}"/*.js
|
||||||
|
for f in $FILES
|
||||||
|
do
|
||||||
|
add_override "$f"
|
||||||
|
done
|
||||||
|
IFS=$SAVEIFS # restore $IFS
|
||||||
else
|
else
|
||||||
## there is an update available
|
echo -e "${ORANGE}Warning: Could not find override file:${NC} ${input}"
|
||||||
if [ $update_pref = "-update" ]; then
|
fi
|
||||||
## update without asking
|
}
|
||||||
update_script
|
|
||||||
else
|
remove_comments () { # expects 2 arguments: from-file and to-file
|
||||||
read -p "There is a newer version of updater.sh available. Download and execute? Y/N? " -n 1 -r
|
sed -e 's/^[[:space:]]*\/\/.*$//' -e '/^\/\*/,/\*\//d' -e '/^[[:space:]]*$/d' -e 's/);[[:space:]]*\/\/.*/);/' "$1" > "$2"
|
||||||
echo -e "\n\n"
|
}
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
||||||
update_script
|
# Applies latest version of user.js and any custom overrides
|
||||||
else
|
update_userjs () {
|
||||||
main
|
declare -r newfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')
|
||||||
fi
|
|
||||||
|
echo 'Please observe the following information:'
|
||||||
|
echo -e "\tFirefox profile: ${ORANGE}$(pwd)${NC}"
|
||||||
|
echo -e "\tAvailable online: ${ORANGE}$(get_userjs_version $newfile)${NC}"
|
||||||
|
echo -e "\tCurrently using: ${ORANGE}$(get_userjs_version user.js)\n${NC}\n"
|
||||||
|
|
||||||
|
if [ $CONFIRM = 'yes' ]; then
|
||||||
|
echo -e "This script will update to the latest user.js file and append any custom configurations from user-overrides.js. ${RED}Continue Y/N? ${NC}"
|
||||||
|
read -p "" -n 1 -r
|
||||||
|
echo -e "\n"
|
||||||
|
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||||
|
echo -e "${RED}Process aborted${NC}"
|
||||||
|
rm $newfile
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Copy a version of user.js to diffs folder for later comparison
|
||||||
|
if [ "$COMPARE" = true ]; then
|
||||||
|
mkdir -p userjs_diffs
|
||||||
|
cp user.js userjs_diffs/past_user.js &>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
# backup user.js
|
||||||
|
mkdir -p userjs_backups
|
||||||
|
local bakname="userjs_backups/user.js.backup.$(date +"%Y-%m-%d_%H%M")"
|
||||||
|
if [ $BACKUP = 'single' ]; then
|
||||||
|
bakname='userjs_backups/user.js.backup'
|
||||||
|
fi
|
||||||
|
cp user.js "$bakname" &>/dev/null
|
||||||
|
|
||||||
|
mv "${newfile}" user.js
|
||||||
|
echo -e "Status: ${GREEN}user.js has been backed up and replaced with the latest version!${NC}"
|
||||||
|
|
||||||
|
if [ "$ESR" = true ]; then
|
||||||
|
sed -e 's/\/\* \(ESR[0-9]\{2,\}\.x still uses all.*\)/\/\/ \1/' user.js > user.js.tmp && mv user.js.tmp user.js
|
||||||
|
echo -e "Status: ${GREEN}ESR related preferences have been activated!${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# apply overrides
|
||||||
|
if [ "$SKIPOVERRIDE" = false ]; then
|
||||||
|
while IFS=',' read -ra FILE; do
|
||||||
|
add_override "$FILE"
|
||||||
|
done <<< "$OVERRIDE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# create diff
|
||||||
|
if [ "$COMPARE" = true ]; then
|
||||||
|
pastuserjs='userjs_diffs/past_user.js'
|
||||||
|
past_nocomments='userjs_diffs/past_userjs.txt'
|
||||||
|
current_nocomments='userjs_diffs/current_userjs.txt'
|
||||||
|
|
||||||
|
remove_comments $pastuserjs $past_nocomments
|
||||||
|
remove_comments user.js $current_nocomments
|
||||||
|
|
||||||
|
diffname="userjs_diffs/diff_$(date +"%Y-%m-%d_%H%M").txt"
|
||||||
|
diff=$(diff -w -B -U 0 $past_nocomments $current_nocomments)
|
||||||
|
if [ ! -z "$diff" ]; then
|
||||||
|
echo "$diff" > "$diffname"
|
||||||
|
echo -e "Status: ${GREEN}A diff file was created:${NC} ${PWD}/${diffname}"
|
||||||
|
else
|
||||||
|
echo -e "Warning: ${ORANGE}Your new user.js file appears to be identical. No diff file was created.${NC}"
|
||||||
|
fi
|
||||||
|
rm $past_nocomments $current_nocomments $pastuserjs &>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$VIEW" = true ]; then open_file "${PWD}/user.js"; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Execute #
|
||||||
|
#########################
|
||||||
|
|
||||||
|
if [ $# != 0 ]; then
|
||||||
|
readonly legacy_lc=$(echo $1 | tr '[A-Z]' '[a-z]')
|
||||||
|
# Display usage if first argument is -help or --help
|
||||||
|
if [ $1 = '--help' ] || [ $1 = '-help' ]; then
|
||||||
|
usage
|
||||||
|
elif [ $legacy_lc = '-donotupdate' ]; then
|
||||||
|
UPDATE='no'
|
||||||
|
legacy_argument $1
|
||||||
|
elif [ $legacy_lc = '-update' ]; then
|
||||||
|
UPDATE='yes'
|
||||||
|
legacy_argument $1
|
||||||
|
else
|
||||||
|
while getopts ":hp:ludsno:bcvre" opt; do
|
||||||
|
case $opt in
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
p)
|
||||||
|
PROFILE_PATH=${OPTARG}
|
||||||
|
;;
|
||||||
|
l)
|
||||||
|
PROFILE_PATH='list'
|
||||||
|
;;
|
||||||
|
u)
|
||||||
|
UPDATE='yes'
|
||||||
|
;;
|
||||||
|
d)
|
||||||
|
UPDATE='no'
|
||||||
|
;;
|
||||||
|
s)
|
||||||
|
CONFIRM='no'
|
||||||
|
;;
|
||||||
|
n)
|
||||||
|
SKIPOVERRIDE=true
|
||||||
|
;;
|
||||||
|
o)
|
||||||
|
OVERRIDE=${OPTARG}
|
||||||
|
;;
|
||||||
|
b)
|
||||||
|
BACKUP='single'
|
||||||
|
;;
|
||||||
|
c)
|
||||||
|
COMPARE=true
|
||||||
|
;;
|
||||||
|
v)
|
||||||
|
VIEW=true
|
||||||
|
;;
|
||||||
|
e)
|
||||||
|
ESR=true
|
||||||
|
;;
|
||||||
|
r)
|
||||||
|
tfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')
|
||||||
|
mv $tfile "${tfile}.js"
|
||||||
|
echo -e "${ORANGE}Warning: user.js was saved to temporary file ${tfile}.js${NC}"
|
||||||
|
open_file "${tfile}.js"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo -e "${RED}\n Error! Invalid option: -$OPTARG${NC}" >&2
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
:)
|
||||||
|
echo -e "${RED}Error! Option -$OPTARG requires an argument.${NC}" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
show_banner
|
||||||
|
update_updater
|
||||||
|
|
||||||
|
getProfilePath # updates PROFILE_PATH or exits on error
|
||||||
|
cd "$PROFILE_PATH" && update_userjs
|
||||||
|
|
||||||
|
cd "$CURRDIR"
|
||||||
|
1
wikipiki/License-MIT-yellow.svg
Normal file
1
wikipiki/License-MIT-yellow.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="78" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="78" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h47v20H0z"/><path fill="#dfb317" d="M47 0h31v20H47z"/><path fill="url(#b)" d="M0 0h78v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="245" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="370">license</text><text x="245" y="140" transform="scale(.1)" textLength="370">license</text><text x="615" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">MIT</text><text x="615" y="140" transform="scale(.1)" textLength="210">MIT</text></g> </svg>
|
After Width: | Height: | Size: 950 B |
Reference in New Issue
Block a user