1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
--- prefsCleaner.sh
+++ prefsCleaner.sh
@@ -22,10 +16,0 @@
-readonly CURRDIR=$(pwd)
-
-## get the full path of this script (readlink for Linux, greadlink for Mac with coreutils installed)
-SCRIPT_FILE=$(readlink -f "${BASH_SOURCE[0]}" 2>/dev/null || greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null)
-
-## fallback for Macs without coreutils
-[ -z "$SCRIPT_FILE" ] && SCRIPT_FILE=${BASH_SOURCE[0]}
-
-
-AUTOUPDATE=true
@@ -34,11 +18,0 @@
-## download method priority: curl -> wget
-DOWNLOAD_METHOD=''
-if command -v curl >/dev/null; then
- DOWNLOAD_METHOD='curl --max-redirs 3 -so'
-elif command -v wget >/dev/null; then
- DOWNLOAD_METHOD='wget --max-redirect 3 --quiet -O'
-else
- AUTOUPDATE=false
- echo -e "No curl or wget detected.\nAutomatic self-update disabled!"
-fi
-
@@ -46,2 +19,0 @@
- ## change directory back to the original working directory
- cd "${CURRDIR}"
@@ -57,7 +29 @@
- -d Don't auto-update prefsCleaner.sh"
-}
-
-download_file() { # expects URL as argument ($1)
- declare -r tf=$(mktemp)
-
- $DOWNLOAD_METHOD "${tf}" "$1" &>/dev/null && echo "$tf" || echo '' # return the temp-filename or empty string on error
+"
@@ -75,18 +40,0 @@
-## returns the version number of a prefsCleaner.sh file
-get_prefsCleaner_version() {
- echo "$(sed -n '5 s/.*[[:blank:]]\([[:digit:]]*\.[[:digit:]]*\)/\1/p' "$1")"
-}
-
-## updates the prefsCleaner.sh file based on the latest public version
-update_prefsCleaner() {
- declare -r tmpfile="$(download_file 'https://raw.githubusercontent.com/arkenfox/user.js/master/prefsCleaner.sh')"
- [ -z "$tmpfile" ] && echo -e "Error! Could not download prefsCleaner.sh" && return 1 # check if download failed
-
- [[ $(get_prefsCleaner_version "$SCRIPT_FILE") == $(get_prefsCleaner_version "$tmpfile") ]] && return 0
-
- mv "$tmpfile" "$SCRIPT_FILE"
- chmod u+x "$SCRIPT_FILE"
- "$SCRIPT_FILE" "$@" -d
- exit 0
-}
-
@@ -132 +80 @@
-while getopts "sd" opt; do
+while getopts "s" opt; do
@@ -137,3 +84,0 @@
- d)
- AUTOUPDATE=false
- ;;
@@ -142,5 +86,0 @@
-
-## change directory to the Firefox profile directory
-cd "$(dirname "${SCRIPT_FILE}")"
-
-[ "$AUTOUPDATE" = true ] && update_prefsCleaner "$@"
|