|
@@ -1,20 +1,21 @@
|
|
@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.0
|
|
|
|
|
|
+REM ## version: 4.1
|
|
|
|
+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 /I "%~1"=="-unattended" ( SET _ua=1 )
|
|
|
|
-IF /I "%~1"=="-log" ( SET _log=1 )
|
|
|
|
-IF /I "%~1"=="-logp" ( SET _log=1 & SET _logp=1 )
|
|
|
|
-IF /I "%~1"=="-multioverrides" ( SET _multi=1 )
|
|
|
|
-IF /I "%~1"=="-merge" ( SET _merge=1 )
|
|
|
|
-IF /I "%~1"=="-updatebatch" ( SET _updateb=1 )
|
|
|
|
|
|
+IF "%~1"=="" (GOTO endparse)
|
|
|
|
+IF /I "%~1"=="-unattended" (SET _ua=1)
|
|
|
|
+IF /I "%~1"=="-log" (SET _log=1)
|
|
|
|
+IF /I "%~1"=="-logp" (SET _log=1 & SET _logp=1)
|
|
|
|
+IF /I "%~1"=="-multioverrides" (SET _multi=1)
|
|
|
|
+IF /I "%~1"=="-merge" (SET _merge=1)
|
|
|
|
+IF /I "%~1"=="-updatebatch" (SET _updateb=1)
|
|
SHIFT
|
|
SHIFT
|
|
GOTO parse
|
|
GOTO parse
|
|
:endparse
|
|
:endparse
|
|
@@ -75,7 +76,7 @@ ECHO:
|
|
ECHO: ########################################
|
|
ECHO: ########################################
|
|
ECHO: #### user.js Updater for Windows ####
|
|
ECHO: #### user.js Updater for Windows ####
|
|
ECHO: #### by claustromaniac ####
|
|
ECHO: #### by claustromaniac ####
|
|
-ECHO: #### v4.0 ####
|
|
|
|
|
|
+ECHO: #### v4.1 ####
|
|
ECHO: ########################################
|
|
ECHO: ########################################
|
|
ECHO:
|
|
ECHO:
|
|
SET /A "_line=0"
|
|
SET /A "_line=0"
|
|
@@ -84,10 +85,10 @@ IF NOT EXIST user.js (
|
|
) ELSE (
|
|
) ELSE (
|
|
FOR /F "skip=1 tokens=1,2 delims=:" %%G IN (user.js) DO (
|
|
FOR /F "skip=1 tokens=1,2 delims=:" %%G IN (user.js) DO (
|
|
SET /A "_line+=1"
|
|
SET /A "_line+=1"
|
|
- IF !_line! GEQ 4 ( GOTO exitloop )
|
|
|
|
- IF !_line! EQU 1 ( SET _name=%%H )
|
|
|
|
- IF !_line! EQU 2 ( SET _date=%%H )
|
|
|
|
- IF !_line! EQU 3 ( SET _version=%%G )
|
|
|
|
|
|
+ IF !_line! GEQ 4 (GOTO exitloop)
|
|
|
|
+ IF !_line! EQU 1 (SET _name=%%H)
|
|
|
|
+ IF !_line! EQU 2 (SET _date=%%H)
|
|
|
|
+ IF !_line! EQU 3 (SET _version=%%G)
|
|
)
|
|
)
|
|
:exitloop
|
|
:exitloop
|
|
IF !_line! GEQ 4 (
|
|
IF !_line! GEQ 4 (
|
|
@@ -110,20 +111,20 @@ IF NOT DEFINED _ua (
|
|
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 2 ( GOTO :showhelp )
|
|
|
|
|
|
+ IF ERRORLEVEL 3 (EXIT /B)
|
|
|
|
+ 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
|
|
ECHO:##################################################################
|
|
ECHO:##################################################################
|
|
CALL :message "%date%, %time%"
|
|
CALL :message "%date%, %time%"
|
|
)
|
|
)
|
|
-IF EXIST user.js.old.bak ( DEL /F user.js.old.bak )
|
|
|
|
|
|
+IF EXIST user.js.old.bak (DEL /F user.js.old.bak)
|
|
IF EXIST user.js (
|
|
IF EXIST user.js (
|
|
- IF EXIST user.js.bak ( REN user.js.bak user.js.old.bak )
|
|
|
|
|
|
+ IF EXIST user.js.bak (REN user.js.bak user.js.old.bak)
|
|
REN user.js user.js.bak
|
|
REN user.js user.js.bak
|
|
CALL :message "Current user.js file backed up."
|
|
CALL :message "Current user.js file backed up."
|
|
)
|
|
)
|
|
@@ -145,7 +146,7 @@ IF EXIST user.js (
|
|
CALL :message "Appending..."
|
|
CALL :message "Appending..."
|
|
COPY /B /V /Y user.js+"user.js-overrides\*.js" user.js
|
|
COPY /B /V /Y user.js+"user.js-overrides\*.js" user.js
|
|
)
|
|
)
|
|
- ) ELSE ( CALL :message "No override files found." )
|
|
|
|
|
|
+ ) ELSE (CALL :message "No override files found.")
|
|
ECHO:
|
|
ECHO:
|
|
) ELSE (
|
|
) ELSE (
|
|
IF EXIST "user-overrides.js" (
|
|
IF EXIST "user-overrides.js" (
|
|
@@ -156,7 +157,7 @@ IF EXIST user.js (
|
|
) 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.")
|
|
ECHO:
|
|
ECHO:
|
|
)
|
|
)
|
|
CALL :message "Handling backups..."
|
|
CALL :message "Handling backups..."
|
|
@@ -164,7 +165,6 @@ IF EXIST user.js (
|
|
IF EXIST user.js.bak (
|
|
IF EXIST user.js.bak (
|
|
FC user.js.bak user.js >nul && SET "changed=false" || SET "changed=true"
|
|
FC user.js.bak user.js >nul && SET "changed=false" || SET "changed=true"
|
|
)
|
|
)
|
|
- ECHO:
|
|
|
|
IF "!changed!"=="true" (
|
|
IF "!changed!"=="true" (
|
|
IF EXIST user.js.old.bak DEL /F user.js.old.bak
|
|
IF EXIST user.js.old.bak DEL /F user.js.old.bak
|
|
CALL :message "Update complete."
|
|
CALL :message "Update complete."
|
|
@@ -173,26 +173,26 @@ IF EXIST user.js (
|
|
DEL /F user.js.bak
|
|
DEL /F user.js.bak
|
|
IF EXIST user.js.old.bak REN user.js.old.bak user.js.bak
|
|
IF EXIST user.js.old.bak REN user.js.old.bak user.js.bak
|
|
CALL :message "Update completed without changes."
|
|
CALL :message "Update completed without changes."
|
|
- ) ELSE ( CALL :message "Update complete." )
|
|
|
|
|
|
+ ) ELSE (CALL :message "Update complete.")
|
|
)
|
|
)
|
|
ECHO:
|
|
ECHO:
|
|
) ELSE (
|
|
) ELSE (
|
|
- IF EXIST user.js.bak ( REN user.js.bak user.js )
|
|
|
|
- IF EXIST user.js.old.bak ( REN user.js.old.bak user.js.bak )
|
|
|
|
|
|
+ IF EXIST user.js.bak (REN user.js.bak user.js)
|
|
|
|
+ IF EXIST user.js.old.bak (REN user.js.old.bak user.js.bak)
|
|
CALL :message "Update failed. Make sure PowerShell is allowed internet access."
|
|
CALL :message "Update failed. Make sure PowerShell is allowed internet access."
|
|
- CALL :message "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
|
|
-ECHO:
|
|
|
|
|
|
+IF NOT DEFINED _log (ECHO:)
|
|
ECHO: %~1
|
|
ECHO: %~1
|
|
-ECHO:
|
|
|
|
|
|
+IF NOT DEFINED _log (ECHO:)
|
|
ENDLOCAL
|
|
ENDLOCAL
|
|
GOTO :EOF
|
|
GOTO :EOF
|
|
REM ############ Merge function ############
|
|
REM ############ Merge function ############
|
|
@@ -230,28 +230,31 @@ ENDLOCAL
|
|
GOTO :EOF
|
|
GOTO :EOF
|
|
REM ############### Help ##################
|
|
REM ############### Help ##################
|
|
:showhelp
|
|
:showhelp
|
|
-MODE 80,38
|
|
|
|
|
|
+MODE 80,43
|
|
CLS
|
|
CLS
|
|
-CALL :message "Available switches (case-insensitive):"
|
|
|
|
|
|
+CALL :message "Available arguments (case-insensitive):"
|
|
CALL :message " -log"
|
|
CALL :message " -log"
|
|
-ECHO: Writes 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 opens the logfile after updating.
|
|
|
|
|
|
+ECHO: Like -log, but also open the logfile after updating.
|
|
CALL :message " -merge"
|
|
CALL :message " -merge"
|
|
-ECHO: Merges overrides instead of appending them. Comments and _user.js.parrot
|
|
|
|
-ECHO: lines are appended normally. Overrides for inactive (commented out)
|
|
|
|
|
|
+ECHO: Merge overrides instead of appending them. One-line comments and
|
|
|
|
+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.
|
|
|
|
|
|
+ECHO: pref, the value of the last one declared will be used. Visit the wiki
|
|
|
|
+ECHO: for usage examples and more detailed information.
|
|
CALL :message " -multiOverrides"
|
|
CALL :message " -multiOverrides"
|
|
-ECHO: uses 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"
|
|
|
|
+ECHO: Run without user input.
|
|
CALL :message " -updatebatch"
|
|
CALL :message " -updatebatch"
|
|
-ECHO: The script will update itself on execution.
|
|
|
|
|
|
+ECHO: Update the script itself on execution, before the normal routine.
|
|
CALL :message ""
|
|
CALL :message ""
|
|
PAUSE
|
|
PAUSE
|
|
CLS
|
|
CLS
|