This commit is contained in:
claustromaniac 2018-04-22 21:10:49 +00:00 committed by GitHub
parent c469249873
commit 7ef1e4969e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,7 +2,7 @@
## prefs.js cleaner for Linux/Mac ## prefs.js cleaner for Linux/Mac
## author: @claustromaniac ## author: @claustromaniac
## version: 1.0b3 ## version: 1.0b4
## 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
@ -36,33 +36,32 @@ fFF_check() {
fClean() { fClean() {
# the magic happens here # the magic happens here
prefs="_" prefs="@@"
preffp=`grep -E "user_pref[ ]*\([ ]*[\"'][^\"']*[\"'][ ]*," user.js`
prefexp="user_pref[ ]*\([ ]*[\"']([^\"']*)[\"'][ ]*," prefexp="user_pref[ ]*\([ ]*[\"']([^\"']*)[\"'][ ]*,"
while read -r line || [[ -n "$line" ]]; do while read -r line || [[ -n "$line" ]]; do
if [[ $line =~ $prefexp ]]; then if [[ $line =~ $prefexp ]]; then
if [[ $prefs != *${BASH_REMATCH[1]}* ]]; then if [[ $prefs != *"@@${BASH_REMATCH[1]}@@"* ]]; then
prefs=${prefs}${BASH_REMATCH[1]} prefs="${prefs}${BASH_REMATCH[1]}@@"
fi fi
fi fi
done <<< "$preffp" done <<< `grep -E "${prefexp}" user.js`
while IFS='' read -r line || [[ -n "$line" ]]; do while IFS='' read -r line || [[ -n "$line" ]]; do
if [[ $line =~ $prefexp ]]; then if [[ $line =~ $prefexp ]]; then
if [[ $prefs != *${BASH_REMATCH[1]}* ]]; then if [[ $prefs != *"@@${BASH_REMATCH[1]}@@"* ]]; then
echo "$line" echo "$line"
fi fi
else else
echo "$line" echo "$line"
fi fi
done < $1 > prefs.js done < "$1" > prefs.js
} }
echo -e "\n\n" echo -e "\n\n"
echo " ╔══════════════════════════╗" echo " ╔══════════════════════════╗"
echo " ║ prefs.js cleaner ║" echo " ║ prefs.js cleaner ║"
echo " ║ by claustromaniac ║" echo " ║ by claustromaniac ║"
echo " ║ v1.0b3 ║" echo " ║ v1.0b4 ║"
echo " ╚══════════════════════════╝" echo " ╚══════════════════════════╝"
echo -e "\nThis script should be run from your Firefox profile directory.\n" 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 "It will remove any entries from prefs.js that also exist in user.js."
@ -84,7 +83,7 @@ do
bakfile="prefs.js.backup.$(date +"%Y-%m-%d_%H%M")" bakfile="prefs.js.backup.$(date +"%Y-%m-%d_%H%M")"
mv prefs.js "${bakfile}" && echo -e "\nprefs.js backed up." mv prefs.js "${bakfile}" && echo -e "\nprefs.js backed up."
echo "Cleaning prefs.js..." echo "Cleaning prefs.js..."
fClean $bakfile fClean "$bakfile"
echo "All done!" echo "All done!"
fQuit 0 fQuit 0
;; ;;