Introduce end-of-line normalization (#471)

fix for #469
This commit is contained in:
Денис 2018-08-07 00:06:30 +02:00 committed by earthlng
parent 06b69bb95a
commit 3806ccc68c
2 changed files with 373 additions and 373 deletions

View File

@ -1,108 +1,108 @@
@ECHO OFF & SETLOCAL DisableDelayedExpansion @ECHO OFF & SETLOCAL DisableDelayedExpansion
TITLE prefs.js cleaner TITLE prefs.js cleaner
REM ### prefs.js cleaner for Windows REM ### prefs.js cleaner for Windows
REM ## author: @claustromaniac REM ## author: @claustromaniac
REM ## version: 2.1 REM ## version: 2.1
:begin :begin
ECHO: ECHO:
ECHO: ECHO:
ECHO ######################################## ECHO ########################################
ECHO #### prefs.js cleaner for Windows #### ECHO #### prefs.js cleaner for Windows ####
ECHO #### by claustromaniac #### ECHO #### by claustromaniac ####
ECHO #### v2.1 #### ECHO #### v2.1 ####
ECHO ######################################## ECHO ########################################
ECHO: ECHO:
CALL :message "This script should be run from your Firefox profile directory." CALL :message "This script should be run from your Firefox profile directory."
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.
CALL :message "This will allow inactive preferences to be reset to their default values." CALL :message "This will allow inactive preferences to be reset to their default values."
ECHO This Firefox profile shouldn't be in use during the process. ECHO This Firefox profile shouldn't be in use during the process.
CALL :message "" CALL :message ""
TIMEOUT 1 /nobreak >nul TIMEOUT 1 /nobreak >nul
CHOICE /C SHE /N /M "Start [S] Help [H] Exit [E]" CHOICE /C SHE /N /M "Start [S] Help [H] Exit [E]"
CLS CLS
IF ERRORLEVEL 3 (EXIT /B) IF ERRORLEVEL 3 (EXIT /B)
IF ERRORLEVEL 2 (GOTO :showhelp) IF ERRORLEVEL 2 (GOTO :showhelp)
IF NOT EXIST "user.js" (CALL :abort "user.js not found in the current directory." 30) IF NOT EXIST "user.js" (CALL :abort "user.js not found in the current directory." 30)
IF NOT EXIST "prefs.js" (CALL :abort "prefs.js not found in the current directory." 30) IF NOT EXIST "prefs.js" (CALL :abort "prefs.js not found in the current directory." 30)
CALL :FFcheck CALL :FFcheck
CALL :message "Backing up prefs.js..." CALL :message "Backing up prefs.js..."
SET "_time=%time: =0%" SET "_time=%time: =0%"
COPY /B /V /Y prefs.js "prefs-backup-%date:/=-%_%_time::=.%.js" COPY /B /V /Y prefs.js "prefs-backup-%date:/=-%_%_time::=.%.js"
CALL :message "Cleaning prefs.js..." CALL :message "Cleaning prefs.js..."
CALL :cleanup CALL :cleanup
CALL :message "All done!" CALL :message "All done!"
TIMEOUT 5 >nul TIMEOUT 5 >nul
ENDLOCAL ENDLOCAL
EXIT /B EXIT /B
REM ########## Abort Function ########### REM ########## Abort Function ###########
:abort :abort
CALL :message %1 CALL :message %1
TIMEOUT %~2 >nul TIMEOUT %~2 >nul
EXIT EXIT
REM ########## Message Function ######### REM ########## Message Function #########
:message :message
ECHO: ECHO:
ECHO: %~1 ECHO: %~1
ECHO: ECHO:
GOTO :EOF GOTO :EOF
REM ####### Firefox Check Function ###### REM ####### Firefox Check Function ######
:FFcheck :FFcheck
TASKLIST /FI "IMAGENAME eq firefox.exe" 2>NUL | FIND /I /N "firefox.exe">NUL TASKLIST /FI "IMAGENAME eq firefox.exe" 2>NUL | FIND /I /N "firefox.exe">NUL
IF NOT ERRORLEVEL 1 ( IF NOT ERRORLEVEL 1 (
CLS CLS
CALL :message "Firefox is still running." CALL :message "Firefox is still running."
ECHO If you're not currently using this profile you can continue, otherwise ECHO If you're not currently using this profile you can continue, otherwise
CALL :message "close Firefox first!" CALL :message "close Firefox first!"
ECHO: ECHO:
PAUSE PAUSE
CLS CLS
CALL :message "Resuming..." CALL :message "Resuming..."
TIMEOUT 5 /nobreak >nul TIMEOUT 5 /nobreak >nul
) )
GOTO :EOF GOTO :EOF
REM ######### Cleanup Function ########## REM ######### Cleanup Function ##########
:cleanup :cleanup
FOR /F tokens^=2^ delims^=^'^" %%G IN ('FINDSTR /R /C:"^[^\"']*user_pref[ ]*\([ ]*[\"'][^\"']*[\"'][ ]*," user.js') DO ( FOR /F tokens^=2^ delims^=^'^" %%G IN ('FINDSTR /R /C:"^[^\"']*user_pref[ ]*\([ ]*[\"'][^\"']*[\"'][ ]*," user.js') DO (
IF NOT ""=="%%G" (SET "[%%G]=1") IF NOT ""=="%%G" (SET "[%%G]=1")
) )
( (
FOR /F "tokens=1,* delims=:" %%G IN ('FINDSTR /N "^" prefs.js') DO ( FOR /F "tokens=1,* delims=:" %%G IN ('FINDSTR /N "^" prefs.js') DO (
IF ""=="%%H" ( IF ""=="%%H" (
ECHO: ECHO:
) ELSE ( ) ELSE (
FOR /F tokens^=1^,2^ delims^=^"^' %%I IN ("%%H") DO ( FOR /F tokens^=1^,2^ delims^=^"^' %%I IN ("%%H") DO (
IF NOT DEFINED [%%J] (ECHO:%%H) IF NOT DEFINED [%%J] (ECHO:%%H)
) )
) )
) )
)>tempcleanedprefs )>tempcleanedprefs
MOVE /Y tempcleanedprefs prefs.js MOVE /Y tempcleanedprefs prefs.js
GOTO :EOF GOTO :EOF
REM ############### Help ################## REM ############### Help ##################
:showhelp :showhelp
MODE 80,34 MODE 80,34
CLS CLS
CALL :message "This script creates a backup of your prefs.js file before doing anything." CALL :message "This script creates a backup of your prefs.js file before doing anything."
ECHO It should be safe, but you can follow these steps if something goes wrong: ECHO It should be safe, but you can follow these steps if something goes wrong:
ECHO: ECHO:
CALL :message " 1. Make sure Firefox is closed." CALL :message " 1. Make sure Firefox is closed."
ECHO 2. Delete prefs.js in your profile folder. ECHO 2. Delete prefs.js in your profile folder.
CALL :message " 3. Delete Invalidprefs.js if you have one in the same folder." CALL :message " 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.
CALL :message " 5. Run Firefox and see if you notice anything wrong with it." CALL :message " 5. Run Firefox and see if you notice anything wrong with it."
ECHO 6. If you do notice something wrong, especially with your extensions, ECHO 6. If you do notice something wrong, especially with your extensions,
CALL :message " and/or with the UI, go to about:support, and restart Firefox with" CALL :message " and/or with the UI, go to about:support, and restart Firefox with"
ECHO add-ons disabled. Then, restart it again normally, and see if the ECHO add-ons disabled. Then, restart it again normally, and see if the
CALL :message " problems were solved." CALL :message " problems were solved."
ECHO: ECHO:
CALL :message "If you are able to identify the cause of your issues, please bring it up" CALL :message "If you are able to identify the cause of your issues, please bring it up"
ECHO on ghacks-user.js GitHub repository. ECHO on ghacks-user.js GitHub repository.
ECHO: ECHO:
ECHO: ECHO:
PAUSE PAUSE
CLS CLS
GOTO :begin GOTO :begin
REM ##################################### REM #####################################

View File

@ -1,265 +1,265 @@
@ECHO OFF & SETLOCAL EnableDelayedExpansion @ECHO OFF & SETLOCAL EnableDelayedExpansion
TITLE ghacks user.js updater TITLE ghacks user.js updater
REM ## ghacks-user.js updater for Windows REM ## ghacks-user.js updater for Windows
REM ## author: @claustromaniac REM ## author: @claustromaniac
REM ## version: 4.5 REM ## version: 4.5
REM ## instructions: https://github.com/ghacksuserjs/ghacks-user.js/wiki/3.3-Updater-Scripts REM ## instructions: https://github.com/ghacksuserjs/ghacks-user.js/wiki/3.3-Updater-Scripts
SET _myname=%~n0 SET _myname=%~n0
SET _myparams=%* SET _myparams=%*
:parse :parse
IF "%~1"=="" (GOTO endparse) IF "%~1"=="" (GOTO endparse)
IF /I "%~1"=="-unattended" (SET _ua=1) IF /I "%~1"=="-unattended" (SET _ua=1)
IF /I "%~1"=="-log" (SET _log=1) IF /I "%~1"=="-log" (SET _log=1)
IF /I "%~1"=="-logp" (SET _log=1 & SET _logp=1) IF /I "%~1"=="-logp" (SET _log=1 & SET _logp=1)
IF /I "%~1"=="-multioverrides" (SET _multi=1) IF /I "%~1"=="-multioverrides" (SET _multi=1)
IF /I "%~1"=="-merge" (SET _merge=1) IF /I "%~1"=="-merge" (SET _merge=1)
IF /I "%~1"=="-updatebatch" (SET _updateb=1) IF /I "%~1"=="-updatebatch" (SET _updateb=1)
IF /I "%~1"=="-singlebackup" (SET _singlebackup=1) IF /I "%~1"=="-singlebackup" (SET _singlebackup=1)
SHIFT SHIFT
GOTO parse GOTO parse
:endparse :endparse
IF DEFINED _updateb ( IF DEFINED _updateb (
REM The normal flow here goes from phase 1 to phase 2 and then phase 3. REM The normal flow here goes from phase 1 to phase 2 and then phase 3.
IF NOT "!_myname:~0,9!"=="[updated]" ( IF NOT "!_myname:~0,9!"=="[updated]" (
IF EXIST "[updated]!_myname!.bat" ( IF EXIST "[updated]!_myname!.bat" (
REM ## Phase 3 ##: The new script, with the original name, will: REM ## Phase 3 ##: The new script, with the original name, will:
REM * Delete the [updated]*.bat script REM * Delete the [updated]*.bat script
REM * Begin the normal routine REM * Begin the normal routine
REN "[updated]!_myname!.bat" "[updated]!_myname!.bat.old" REN "[updated]!_myname!.bat" "[updated]!_myname!.bat.old"
DEL /F "[updated]!_myname!.bat.old" DEL /F "[updated]!_myname!.bat.old"
CALL :message "Script updated^!" CALL :message "Script updated^!"
TIMEOUT 3 >nul TIMEOUT 3 >nul
GOTO begin GOTO begin
) )
REM ## Phase 1 ## REM ## Phase 1 ##
REM * Download new batch and name it [updated]*.bat REM * Download new batch and name it [updated]*.bat
REM * Start that script in a new CMD window REM * Start that script in a new CMD window
REM * Exit REM * Exit
CALL :message "Updating script..." CALL :message "Updating script..."
REM Uncomment the next line and comment the powershell call for testing. REM Uncomment the next line and comment the powershell call for testing.
REM COPY /B /V /Y "!_myname!.bat" "[updated]!_myname!.bat" REM COPY /B /V /Y "!_myname!.bat" "[updated]!_myname!.bat"
( (
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.bat', '[updated]!_myname!.bat')" powershell -Command "(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.bat', '[updated]!_myname!.bat')"
) >nul 2>&1 ) >nul 2>&1
IF EXIST "[updated]!_myname!.bat" ( IF EXIST "[updated]!_myname!.bat" (
START /min CMD /C "[updated]!_myname!.bat" !_myparams! START /min CMD /C "[updated]!_myname!.bat" !_myparams!
) ELSE ( ) ELSE (
CALL :message "Failed. Make sure PowerShell is allowed internet access." CALL :message "Failed. Make sure PowerShell is allowed internet access."
TIMEOUT 120 >nul TIMEOUT 120 >nul
) )
) ELSE ( ) ELSE (
IF "!_myname!"=="[updated]" ( IF "!_myname!"=="[updated]" (
CALL :message "The [updated] label is reserved. Rename this script and try again." CALL :message "The [updated] label is reserved. Rename this script and try again."
TIMEOUT 300 >nul TIMEOUT 300 >nul
) ELSE ( ) ELSE (
REM ## Phase 2 ##: The [updated]*.bat script will: REM ## Phase 2 ##: The [updated]*.bat script will:
REM * Copy itself overwriting the original batch REM * Copy itself overwriting the original batch
REM * Start that script in a new CMD instance REM * Start that script in a new CMD instance
REM * Exit REM * Exit
IF EXIST "!_myname:~9!.bat" ( IF EXIST "!_myname:~9!.bat" (
REN "!_myname:~9!.bat" "!_myname:~9!.bat.old" REN "!_myname:~9!.bat" "!_myname:~9!.bat.old"
DEL /F "!_myname:~9!.bat.old" DEL /F "!_myname:~9!.bat.old"
) )
COPY /B /V /Y "!_myname!.bat" "!_myname:~9!.bat" COPY /B /V /Y "!_myname!.bat" "!_myname:~9!.bat"
START CMD /C "!_myname:~9!.bat" !_myparams! START CMD /C "!_myname:~9!.bat" !_myparams!
) )
) )
EXIT /B EXIT /B
) )
:begin :begin
CLS CLS
ECHO: ECHO:
ECHO: ECHO:
ECHO: ######################################## ECHO: ########################################
ECHO: #### user.js Updater for Windows #### ECHO: #### user.js Updater for Windows ####
ECHO: #### by claustromaniac #### ECHO: #### by claustromaniac ####
ECHO: #### v4.5 #### ECHO: #### v4.5 ####
ECHO: ######################################## ECHO: ########################################
ECHO: ECHO:
SET /A "_line=0" SET /A "_line=0"
IF NOT EXIST user.js ( IF NOT EXIST user.js (
CALL :message "user.js not detected in the current directory." CALL :message "user.js not detected in the current directory."
) ELSE ( ) ELSE (
FOR /F "skip=1 tokens=1,* delims=:" %%G IN (user.js) DO ( FOR /F "skip=1 tokens=1,* delims=:" %%G IN (user.js) DO (
SET /A "_line+=1" SET /A "_line+=1"
IF !_line! GEQ 4 (GOTO exitloop) IF !_line! GEQ 4 (GOTO exitloop)
IF !_line! EQU 1 (SET _name=%%H) IF !_line! EQU 1 (SET _name=%%H)
IF !_line! EQU 2 (SET _date=%%H) IF !_line! EQU 2 (SET _date=%%H)
IF !_line! EQU 3 (SET _version=%%G) IF !_line! EQU 3 (SET _version=%%G)
) )
:exitloop :exitloop
IF NOT "!_name!"=="" ( IF NOT "!_name!"=="" (
IF /I NOT "!_name!"=="!_name:ghacks=!" ( IF /I NOT "!_name!"=="!_name:ghacks=!" (
CALL :message "!_name! !_version:~2!,!_date!" CALL :message "!_name! !_version:~2!,!_date!"
) ELSE (CALL :message "Current user.js version not recognised.") ) ELSE (CALL :message "Current user.js version not recognised.")
) ELSE (CALL :message "Current user.js version not recognised.") ) ELSE (CALL :message "Current user.js version not recognised.")
) )
ECHO: ECHO:
IF NOT DEFINED _ua ( IF NOT DEFINED _ua (
CALL :message "This batch should be run from your Firefox profile directory." CALL :message "This batch should be run from your Firefox profile directory."
ECHO: It will download the latest version of ghacks user.js from github and then ECHO: It will download the latest version of ghacks user.js from github and then
CALL :message "append any of your own changes from user-overrides.js to it." CALL :message "append any of your own changes from user-overrides.js to it."
CALL :message "Visit the wiki for more detailed information." CALL :message "Visit the wiki for more detailed information."
ECHO: ECHO:
TIMEOUT 1 /nobreak >nul TIMEOUT 1 /nobreak >nul
CHOICE /C SHE /N /M "Start [S] Help [H] Exit [E]" CHOICE /C SHE /N /M "Start [S] Help [H] Exit [E]"
CLS CLS
IF ERRORLEVEL 3 (EXIT /B) IF ERRORLEVEL 3 (EXIT /B)
IF ERRORLEVEL 2 (GOTO :showhelp) IF ERRORLEVEL 2 (GOTO :showhelp)
) )
IF DEFINED _log ( IF DEFINED _log (
CALL :log >>user.js-update-log.txt 2>&1 CALL :log >>user.js-update-log.txt 2>&1
IF DEFINED _logp (START user.js-update-log.txt) IF DEFINED _logp (START user.js-update-log.txt)
EXIT /B EXIT /B
:log :log
SET _log=2 SET _log=2
ECHO:################################################################## ECHO:##################################################################
ECHO: %date%, %time% ECHO: %date%, %time%
) )
IF EXIST user.js.new (DEL /F "user.js.new") IF EXIST user.js.new (DEL /F "user.js.new")
CALL :message "Retrieving latest user.js file from github repository..." CALL :message "Retrieving latest user.js file from github repository..."
( (
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js', 'user.js.new')" powershell -Command "(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js', 'user.js.new')"
) >nul 2>&1 ) >nul 2>&1
IF EXIST user.js.new ( IF EXIST user.js.new (
IF DEFINED _multi ( IF DEFINED _multi (
FORFILES /P user.js-overrides /M *.js >nul 2>&1 FORFILES /P user.js-overrides /M *.js >nul 2>&1
IF NOT ERRORLEVEL 1 ( IF NOT ERRORLEVEL 1 (
IF DEFINED _merge ( IF DEFINED _merge (
CALL :message "Merging..." CALL :message "Merging..."
COPY /B /V /Y user.js-overrides\*.js user-overrides-merged.js COPY /B /V /Y user.js-overrides\*.js user-overrides-merged.js
CALL :merge user-overrides-merged.js CALL :merge user-overrides-merged.js
COPY /B /V /Y user.js.new+user-overrides-merged.js user.js.new COPY /B /V /Y user.js.new+user-overrides-merged.js user.js.new
CALL :merge user.js.new CALL :merge user.js.new
) ELSE ( ) ELSE (
CALL :message "Appending..." CALL :message "Appending..."
COPY /B /V /Y user.js.new+"user.js-overrides\*.js" user.js.new COPY /B /V /Y user.js.new+"user.js-overrides\*.js" user.js.new
) )
) ELSE (CALL :message "No override files found.") ) ELSE (CALL :message "No override files found.")
) ELSE ( ) ELSE (
IF EXIST "user-overrides.js" ( IF EXIST "user-overrides.js" (
COPY /B /V /Y user.js.new+"user-overrides.js" "user.js.new" COPY /B /V /Y user.js.new+"user-overrides.js" "user.js.new"
IF DEFINED _merge ( IF DEFINED _merge (
CALL :message "Merging user-overrides.js..." CALL :message "Merging user-overrides.js..."
CALL :merge user.js.new CALL :merge user.js.new
) ELSE ( ) ELSE (
CALL :message "user-overrides.js appended." CALL :message "user-overrides.js appended."
) )
) ELSE (CALL :message "user-overrides.js not found.") ) ELSE (CALL :message "user-overrides.js not found.")
) )
IF EXIST user.js ( IF EXIST user.js (
FC user.js.new user.js >nul && SET "_changed=false" || SET "_changed=true" FC user.js.new user.js >nul && SET "_changed=false" || SET "_changed=true"
) )
IF "!_changed!"=="true" ( IF "!_changed!"=="true" (
CALL :message "Backing up..." CALL :message "Backing up..."
IF DEFINED _singlebackup ( IF DEFINED _singlebackup (
MOVE /Y user.js user.js.bak >nul MOVE /Y user.js user.js.bak >nul
) ELSE ( ) ELSE (
SET "_time=!time: =0!" SET "_time=!time: =0!"
MOVE /Y user.js "user-backup-!date:/=-!_!_time::=.!.js" >nul MOVE /Y user.js "user-backup-!date:/=-!_!_time::=.!.js" >nul
) )
REN user.js.new user.js REN user.js.new user.js
CALL :message "Update complete." CALL :message "Update complete."
) ELSE ( ) ELSE (
IF "!_changed!"=="false" ( IF "!_changed!"=="false" (
DEL /F user.js.new >nul DEL /F user.js.new >nul
CALL :message "Update completed without changes." CALL :message "Update completed without changes."
) ELSE ( ) ELSE (
REN user.js.new user.js REN user.js.new user.js
CALL :message "Update complete." CALL :message "Update complete."
) )
) )
) ELSE ( ) ELSE (
CALL :message "Update failed. Make sure PowerShell is allowed internet access." CALL :message "Update failed. Make sure PowerShell is allowed internet access."
ECHO: No changes were made. ECHO: No changes were made.
) )
IF NOT DEFINED _log ( IF NOT DEFINED _log (
IF NOT DEFINED _ua (PAUSE) IF NOT DEFINED _ua (PAUSE)
) )
EXIT /B EXIT /B
REM ########### Message Function ########### REM ########### Message Function ###########
:message :message
SETLOCAL DisableDelayedExpansion SETLOCAL DisableDelayedExpansion
IF NOT "2"=="%_log%" (ECHO:) IF NOT "2"=="%_log%" (ECHO:)
ECHO: %~1 ECHO: %~1
IF NOT "2"=="%_log%" (ECHO:) IF NOT "2"=="%_log%" (ECHO:)
ENDLOCAL ENDLOCAL
GOTO :EOF GOTO :EOF
REM ############ Merge function ############ REM ############ Merge function ############
:merge :merge
SETLOCAL DisableDelayedExpansion SETLOCAL DisableDelayedExpansion
FOR /F tokens^=2^,^*^ delims^=^'^" %%G IN ('FINDSTR /R /C:"^user_pref[ ]*\([ ]*[\"'].*[\"'][ ]*,.*\)[ ]*;" "%~1"') DO (SET "[%%G]=%%H") FOR /F tokens^=2^,^*^ delims^=^'^" %%G IN ('FINDSTR /R /C:"^user_pref[ ]*\([ ]*[\"'].*[\"'][ ]*,.*\)[ ]*;" "%~1"') DO (SET "[%%G]=%%H")
FOR /F tokens^=2^,^*^ delims^=^' %%G IN ('FINDSTR /R /C:"^//// --- comment-out --- '[^'][^']*'.*" "%~1"') DO (SET "__unset__%%G=1") FOR /F tokens^=2^,^*^ delims^=^' %%G IN ('FINDSTR /R /C:"^//// --- comment-out --- '[^'][^']*'.*" "%~1"') DO (SET "__unset__%%G=1")
( (
FOR /F "tokens=1,* delims=:" %%I IN ('FINDSTR /N "^" "%~1"') DO ( FOR /F "tokens=1,* delims=:" %%I IN ('FINDSTR /N "^" "%~1"') DO (
SET "_temp=%%J" SET "_temp=%%J"
SETLOCAL EnableDelayedExpansion SETLOCAL EnableDelayedExpansion
IF NOT "!_temp:~0,9!"=="user_pref" ( IF NOT "!_temp:~0,9!"=="user_pref" (
ENDLOCAL & ECHO:%%J ENDLOCAL & ECHO:%%J
) ELSE ( ) ELSE (
IF "!_temp:;=!"=="!_temp!" ( IF "!_temp:;=!"=="!_temp!" (
ENDLOCAL & ECHO:%%J ENDLOCAL & ECHO:%%J
) ELSE ( ) ELSE (
ENDLOCAL ENDLOCAL
FOR /F tokens^=2^ delims^=^'^" %%K IN ("%%J") DO ( FOR /F tokens^=2^ delims^=^'^" %%K IN ("%%J") DO (
IF NOT "_user.js.parrot"=="%%K" ( IF NOT "_user.js.parrot"=="%%K" (
IF DEFINED __unset__%%K ( IF DEFINED __unset__%%K (
ECHO://%%J ECHO://%%J
) ELSE ( ) ELSE (
IF DEFINED [%%K] ( IF DEFINED [%%K] (
SETLOCAL EnableDelayedExpansion SETLOCAL EnableDelayedExpansion
FOR /F "delims=" %%L IN ("![%%K]!") DO ( FOR /F "delims=" %%L IN ("![%%K]!") DO (
ENDLOCAL & ECHO:user_pref("%%K"%%L ENDLOCAL & ECHO:user_pref("%%K"%%L
SET "[%%K]=" SET "[%%K]="
) )
) )
) )
) ELSE (ECHO:%%J) ) ELSE (ECHO:%%J)
) )
) )
) )
) )
)>updatertempfile )>updatertempfile
MOVE /Y updatertempfile "%~1" >nul MOVE /Y updatertempfile "%~1" >nul
ENDLOCAL ENDLOCAL
GOTO :EOF GOTO :EOF
REM ############### Help ################## REM ############### Help ##################
:showhelp :showhelp
MODE 80,46 MODE 80,46
CLS CLS
CALL :message "Available arguments (case-insensitive):" CALL :message "Available arguments (case-insensitive):"
CALL :message " -log" CALL :message " -log"
ECHO: Write the console output to a logfile (user.js-update-log.txt) ECHO: Write the console output to a logfile (user.js-update-log.txt)
CALL :message " -logP" CALL :message " -logP"
ECHO: Like -log, but also open the logfile after updating. ECHO: Like -log, but also open the logfile after updating.
CALL :message " -merge" CALL :message " -merge"
ECHO: Merge overrides instead of appending them. Single-line comments and ECHO: Merge overrides instead of appending them. Single-line comments and
ECHO: _user.js.parrot lines are appended normally. Overrides for inactive ECHO: _user.js.parrot lines are appended normally. Overrides for inactive
ECHO: user.js prefs will be appended. When -Merge and -MultiOverrides are used ECHO: user.js prefs will be appended. When -Merge and -MultiOverrides are used
ECHO: together, a user-overrides-merged.js file is also generated in the root ECHO: together, a user-overrides-merged.js file is also generated in the root
ECHO: directory for quick reference. It contains only the merged data from ECHO: directory for quick reference. It contains only the merged data from
ECHO: override files and can be safely discarded after updating, or used as the ECHO: override files and can be safely discarded after updating, or used as the
ECHO: new user-overrides.js. When there are conflicting records for the same ECHO: new user-overrides.js. When there are conflicting records for the same
ECHO: pref, the value of the last one declared will be used. Visit the wiki ECHO: pref, the value of the last one declared will be used. Visit the wiki
ECHO: for usage examples and more detailed information. ECHO: for usage examples and more detailed information.
CALL :message " -multiOverrides" CALL :message " -multiOverrides"
ECHO: Use any and all .js files in a user.js-overrides sub-folder as overrides ECHO: Use any and all .js files in a user.js-overrides sub-folder as overrides
ECHO: instead of the default user-overrides.js file. Files are appended in ECHO: instead of the default user-overrides.js file. Files are appended in
ECHO: alphabetical order. ECHO: alphabetical order.
CALL :message " -unattended" CALL :message " -unattended"
ECHO: Run without user input. ECHO: Run without user input.
CALL :message " -singleBackup" CALL :message " -singleBackup"
ECHO: Use a single backup file and overwrite it on new updates, instead of ECHO: Use a single backup file and overwrite it on new updates, instead of
ECHO: cumulative backups. This was the default behaviour before v4.3. ECHO: cumulative backups. This was the default behaviour before v4.3.
CALL :message " -updatebatch" CALL :message " -updatebatch"
ECHO: Update the script itself on execution, before the normal routine. ECHO: Update the script itself on execution, before the normal routine.
CALL :message "" CALL :message ""
PAUSE PAUSE
MODE 80,25 MODE 80,25
GOTO :begin GOTO :begin
REM ##################################### REM #####################################