I'm actually more of a tabs guy

This commit is contained in:
claustromaniac 2018-04-23 12:54:26 +00:00 committed by GitHub
parent 3090b6fdd2
commit 22a8ebefdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,42 +19,41 @@ if [ -z "$sfp" ]; then sfp=${BASH_SOURCE[0]}; fi
cd "$(dirname "${sfp}")" cd "$(dirname "${sfp}")"
fQuit() { fQuit() {
## change directory back to the original working directory ## change directory back to the original working directory
cd "${currdir}" cd "${currdir}"
exit $1 exit $1
} }
fFF_check() { fFF_check() {
# there are many ways to see if firefox is running or not, some more reliable than others # there are many ways to see if firefox is running or not, some more reliable than others
# this isn't elegant and might not be future-proof but should at least be compatible with any environment # this isn't elegant and might not be future-proof but should at least be compatible with any environment
while [ -e webappsstore.sqlite-shm ] while [ -e webappsstore.sqlite-shm ]; do
do echo -e "\nThis Firefox profile seems to be in use. Close Firefox and try again.\n"
echo -e "\nThis Firefox profile seems to be in use. Close Firefox and try again.\n" read -p "Press any key to continue."
read -p "Press any key to continue." done
done
} }
fClean() { fClean() {
# the magic happens here # the magic happens here
prefs="@@" prefs="@@"
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 <<< `grep -E "${prefexp}" user.js` 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
continue continue
fi fi
echo "$line" echo "$line"
done < "$1" > prefs.js done < "$1" > prefs.js
} }
echo -e "\n\n" echo -e "\n\n"
@ -67,41 +66,40 @@ 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."
echo "This will allow inactive preferences to be reset to their default values." 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" echo -e "\nThis Firefox profile shouldn't be in use during the process.\n"
select option in Start Help Exit; select option in Start Help Exit; do
do case $option in
case $option in Start)
Start) if [ ! -e user.js ]; then
if [ ! -e user.js ]; then echo "user.js not found in the current directory."
echo "user.js not found in the current directory." fQuit 1
fQuit 1 elif [ ! -e prefs.js ]; then
elif [ ! -e prefs.js ]; then echo "prefs.js not found in the current directory."
echo "prefs.js not found in the current directory." fQuit 1
fQuit 1 fi
fi
fFF_check
fFF_check ## create backup folder if it doesn't exist
## create backup folder if it doesn't exist mkdir -p userjs_backups;
mkdir -p userjs_backups; bakfile="userjs_backups/prefs.js.backup.$(date +"%Y-%m-%d_%H%M")"
bakfile="userjs_backups/prefs.js.backup.$(date +"%Y-%m-%d_%H%M")" mv prefs.js "${bakfile}" && echo -e "\nprefs.js backed up: $bakfile"
mv prefs.js "${bakfile}" && echo -e "\nprefs.js backed up: $bakfile" echo "Cleaning prefs.js..."
echo "Cleaning prefs.js..." fClean "$bakfile"
fClean "$bakfile" echo "All done!"
echo "All done!" fQuit 0
fQuit 0 ;;
;; Help)
Help) 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." echo "2. Delete prefs.js in your profile folder."
echo "2. Delete prefs.js in your profile folder." echo "3. Delete Invalidprefs.js if you have one in the same folder."
echo "3. Delete Invalidprefs.js if you have one in the same folder." echo "4. Rename or copy your latest backup to prefs.js."
echo "4. Rename or copy your latest backup to prefs.js." echo "5. Run Firefox and see if you notice anything wrong with it."
echo "5. Run Firefox and see if you notice anything wrong with it." echo "6. If you do notice something wrong, especially with your extensions, and/or with the UI, go to about:support, and restart Firefox with add-ons disabled. Then, restart it again normally, and see if the problems were solved."
echo "6. If you do notice something wrong, especially with your extensions, and/or with the UI, go to about:support, and restart Firefox with add-ons disabled. Then, restart it again normally, and see if the problems were solved." echo -e "If you are able to identify the cause of your issues, please bring it up on ghacks-user.js GitHub repository.\n"
echo -e "If you are able to identify the cause of your issues, please bring it up on ghacks-user.js GitHub repository.\n" ;;
;; Exit)
Exit) fQuit 0
fQuit 0 ;;
;; esac
esac
done done