Add commandline argument -s to allow silent execution. Bump version to 1.4.

This commit is contained in:
4n0nym0u53 2021-06-05 18:08:09 +02:00
parent b6d7b2bff5
commit e2e5edaa21

61
prefsCleaner.sh Normal file → Executable file
View file

@ -2,10 +2,11 @@
## prefs.js cleaner for Linux/Mac ## prefs.js cleaner for Linux/Mac
## author: @claustromaniac ## author: @claustromaniac
## version: 1.3 ## version: 1.4
## special thanks to @overdodactyl and @earthlng for a few snippets that I stol..*cough* borrowed from the updater.sh ## special thanks to @overdodactyl and @earthlng for a few snippets that I stol..*cough* borrowed from the updater.sh
SILENT='no'
currdir=$(pwd) currdir=$(pwd)
## get the full path of this script (readlink for Linux, greadlink for Mac with coreutils installed) ## get the full path of this script (readlink for Linux, greadlink for Mac with coreutils installed)
@ -33,6 +34,26 @@ fFF_check() {
done done
} }
fPrint() {
echo -e "\n\n"
echo " ╔══════════════════════════╗"
echo " ║ prefs.js cleaner ║"
echo " ║ by claustromaniac ║"
echo " ║ v1.3 ║"
echo " ╚══════════════════════════╝"
echo -e "\nThis script should be run from your Firefox profile directory.\n"
echo "It will remove any entries from prefs.js that also exist in user.js."
echo "This will allow inactive preferences to be reset to their default values."
echo -e "\nThis Firefox profile shouldn't be in use during the process.\n"
}
fUsage() {
echo -e "\nUsage: $0 [-s]" 1>&2
echo -e "
Optional Arguments:
-s Run silently (chooses option 1)."
}
fClean() { fClean() {
# the magic happens here # the magic happens here
prefs="@@" prefs="@@"
@ -54,19 +75,7 @@ fClean() {
done < "$1" > prefs.js done < "$1" > prefs.js
} }
echo -e "\n\n" fStart() {
echo " ╔══════════════════════════╗"
echo " ║ prefs.js cleaner ║"
echo " ║ by claustromaniac ║"
echo " ║ v1.3 ║"
echo " ╚══════════════════════════╝"
echo -e "\nThis script should be run from your Firefox profile directory.\n"
echo "It will remove any entries from prefs.js that also exist in user.js."
echo "This will allow inactive preferences to be reset to their default values."
echo -e "\nThis Firefox profile shouldn't be in use during the process.\n"
select option in Start Help Exit; do
case $option in
Start)
if [ ! -e user.js ]; then if [ ! -e user.js ]; then
fQuit 1 "user.js not found in the current directory." fQuit 1 "user.js not found in the current directory."
elif [ ! -e prefs.js ]; then elif [ ! -e prefs.js ]; then
@ -80,8 +89,32 @@ select option in Start Help Exit; do
echo "Cleaning prefs.js..." echo "Cleaning prefs.js..."
fClean "$bakfile" fClean "$bakfile"
fQuit 0 "All done!" fQuit 0 "All done!"
}
if [ $# != 0 ]; then
while getopts "s" opt; do
case $opt in
s)
SILENT='yes'
esac
done
fi
if [ $SILENT == 'yes' ]; then
fStart
fi
fPrint
select option in Start Help Exit; do
case $option in
Start)
fStart
;; ;;
Help) Help)
fUsage
echo -e "\nThis script creates a backup of your prefs.js file before doing anything." echo -e "\nThis script creates a backup of your prefs.js file before doing anything."
echo -e "It should be safe, but you can follow these steps if something goes wrong:\n" echo -e "It should be safe, but you can follow these steps if something goes wrong:\n"
echo "1. Make sure Firefox is closed." echo "1. Make sure Firefox is closed."