This commit is contained in:
luca0N! 2025-11-03 01:58:59 +00:00 committed by GitHub
commit db51135e6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -100,7 +100,8 @@ Optional Arguments:
-n Do not append any overrides, even if user-overrides.js exists. -n Do not append any overrides, even if user-overrides.js exists.
-v Open the resulting user.js file. -v Open the resulting user.js file.
-r Only download user.js to a temporary file and open it. -r Only download user.js to a temporary file and open it.
-e Activate ESR related preferences." -e Activate ESR related preferences.
-f PATH Use this path in the local disk for user.js instead of downloading it."
echo echo
exit 1 exit 1
} }
@ -247,8 +248,12 @@ remove_comments() { # expects 2 arguments: from-file and to-file
# Applies latest version of user.js and any custom overrides # Applies latest version of user.js and any custom overrides
update_userjs() { update_userjs() {
declare -r newfile="$(download_file 'https://raw.githubusercontent.com/arkenfox/user.js/master/user.js')" if [ -z "${USERJS_LOCAL_PATH}" ]; then
[ -z "${newfile}" ] && echo -e "${RED}Error! Could not download user.js${NC}" && return 1 # check if download failed declare -r newfile="$(download_file 'https://raw.githubusercontent.com/arkenfox/user.js/master/user.js')"
[ -z "${newfile}" ] && echo -e "${RED}Error! Could not download user.js${NC}" && return 1 # check if download failed
else
declare -r newfile="${USERJS_LOCAL_PATH}"
fi
echo -e "Please observe the following information: echo -e "Please observe the following information:
Firefox profile: ${ORANGE}$(pwd)${NC} Firefox profile: ${ORANGE}$(pwd)${NC}
@ -261,7 +266,7 @@ update_userjs() {
echo -e "\n" echo -e "\n"
if ! [[ $REPLY =~ ^[Yy]$ ]]; then if ! [[ $REPLY =~ ^[Yy]$ ]]; then
echo -e "${RED}Process aborted${NC}" echo -e "${RED}Process aborted${NC}"
rm "$newfile" [ -z "${USERJS_LOCAL_PATH}" ] && rm "$newfile"
return 1 return 1
fi fi
fi fi
@ -278,7 +283,12 @@ update_userjs() {
[ "$BACKUP" = 'single' ] && bakname='userjs_backups/user.js.backup' [ "$BACKUP" = 'single' ] && bakname='userjs_backups/user.js.backup'
cp user.js "$bakname" &>/dev/null cp user.js "$bakname" &>/dev/null
mv "${newfile}" user.js if [ -z "${USERJS_LOCAL_PATH}" ]; then
mv "${newfile}" user.js
else
cp -p "${USERJS_LOCAL_PATH}" user.js
fi
echo -e "Status: ${GREEN}user.js has been backed up and replaced with the latest version!${NC}" echo -e "Status: ${GREEN}user.js has been backed up and replaced with the latest version!${NC}"
if [ "$ESR" = true ]; then if [ "$ESR" = true ]; then
@ -328,7 +338,7 @@ if [ $# != 0 ]; then
if [ "$1" = '--help' ] || [ "$1" = '-help' ]; then if [ "$1" = '--help' ] || [ "$1" = '-help' ]; then
usage usage
else else
while getopts ":hp:ludsno:bcvre" opt; do while getopts ":hp:ludsnof:bcvre" opt; do
case $opt in case $opt in
h) h)
usage usage
@ -366,6 +376,9 @@ if [ $# != 0 ]; then
e) e)
ESR=true ESR=true
;; ;;
f)
USERJS_LOCAL_PATH=${OPTARG}
;;
r) r)
tfile="$(download_file 'https://raw.githubusercontent.com/arkenfox/user.js/master/user.js')" tfile="$(download_file 'https://raw.githubusercontent.com/arkenfox/user.js/master/user.js')"
[ -z "${tfile}" ] && echo -e "${RED}Error! Could not download user.js${NC}" && exit 1 # check if download failed [ -z "${tfile}" ] && echo -e "${RED}Error! Could not download user.js${NC}" && exit 1 # check if download failed