merging improvements
- keeps all user.js.parrot lines intact - keeps empty lines intact - fix for keeping `!` and `^` in non-"user_pref" lines intact + some other minor changes + streamlining
This commit is contained in:
parent
76b24fa6aa
commit
1c997693ff
74
updater.bat
74
updater.bat
@ -3,7 +3,7 @@ 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: 3.0-alpha57
|
REM ## version: 3.0-alpha92
|
||||||
|
|
||||||
SET _myname=%~n0
|
SET _myname=%~n0
|
||||||
SET _myparams=%*
|
SET _myparams=%*
|
||||||
@ -74,14 +74,15 @@ IF NOT DEFINED _ua (
|
|||||||
REM ECHO Visit the wiki for more detailed information.
|
REM ECHO Visit the wiki for more detailed information.
|
||||||
REM ECHO.
|
REM ECHO.
|
||||||
CHOICE /M "Continue"
|
CHOICE /M "Continue"
|
||||||
IF ERRORLEVEL 2 (
|
IF ERRORLEVEL 2 EXIT /B
|
||||||
GOTO end
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
CLS
|
CLS
|
||||||
ECHO.
|
ECHO.
|
||||||
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
|
||||||
|
)
|
||||||
EXIT /B
|
EXIT /B
|
||||||
:log
|
:log
|
||||||
ECHO ##################################################################
|
ECHO ##################################################################
|
||||||
@ -90,9 +91,7 @@ IF DEFINED _log (
|
|||||||
ECHO.
|
ECHO.
|
||||||
)
|
)
|
||||||
IF EXIST user.js (
|
IF EXIST user.js (
|
||||||
IF EXIST user.js.bak (
|
IF EXIST user.js.bak REN user.js.bak user.js.old.bak
|
||||||
REN user.js.bak user.js.old.bak
|
|
||||||
)
|
|
||||||
REN user.js user.js.bak
|
REN user.js user.js.bak
|
||||||
ECHO Current user.js file backed up.
|
ECHO Current user.js file backed up.
|
||||||
ECHO.
|
ECHO.
|
||||||
@ -109,13 +108,10 @@ IF EXIST user.js (
|
|||||||
ECHO.
|
ECHO.
|
||||||
ECHO Merging...
|
ECHO Merging...
|
||||||
ECHO.
|
ECHO.
|
||||||
DEL /F user-overrides-merged.js temp2 temp3 2>nul
|
|
||||||
COPY /B /V /Y user.js-overrides\*.js user-overrides
|
COPY /B /V /Y user.js-overrides\*.js user-overrides
|
||||||
CALL :mergeprefs user-overrides user-overrides-merged.js
|
CALL :merge user-overrides user-overrides-merged.js
|
||||||
COPY /B /V /Y user.js+user-overrides-merged.js temp2
|
COPY /B /V /Y user.js+user-overrides-merged.js temp2
|
||||||
CALL :mergeprefs temp2 temp3
|
CALL :merge temp2 user.js
|
||||||
DEL /F temp2 2>nul
|
|
||||||
MOVE /Y temp3 user.js
|
|
||||||
) ELSE (
|
) ELSE (
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO Appending...
|
ECHO Appending...
|
||||||
@ -128,11 +124,8 @@ IF EXIST user.js (
|
|||||||
IF EXIST "user-overrides.js" (
|
IF EXIST "user-overrides.js" (
|
||||||
IF DEFINED _merge (
|
IF DEFINED _merge (
|
||||||
ECHO Merging user-overrides.js...
|
ECHO Merging user-overrides.js...
|
||||||
DEL /F temp2 temp3 2>nul
|
|
||||||
COPY /B /V /Y user.js+user-overrides.js temp2
|
COPY /B /V /Y user.js+user-overrides.js temp2
|
||||||
CALL :mergeprefs temp2 temp3
|
CALL :merge temp2 user.js
|
||||||
DEL /F temp2 2>nul
|
|
||||||
MOVE /Y temp3 user.js
|
|
||||||
) ELSE (
|
) ELSE (
|
||||||
ECHO Appending user-overrides.js...
|
ECHO Appending user-overrides.js...
|
||||||
ECHO.
|
ECHO.
|
||||||
@ -151,9 +144,7 @@ IF EXIST user.js (
|
|||||||
ECHO.
|
ECHO.
|
||||||
ECHO.
|
ECHO.
|
||||||
IF "!changed!"=="true" (
|
IF "!changed!"=="true" (
|
||||||
IF EXIST user.js.old.bak (
|
IF EXIST user.js.old.bak DEL /F user.js.old.bak
|
||||||
DEL /F user.js.old.bak
|
|
||||||
)
|
|
||||||
ECHO Update complete.
|
ECHO Update complete.
|
||||||
) ELSE (
|
) ELSE (
|
||||||
IF "!changed!"=="false" (
|
IF "!changed!"=="false" (
|
||||||
@ -166,12 +157,8 @@ IF EXIST user.js (
|
|||||||
)
|
)
|
||||||
ECHO.
|
ECHO.
|
||||||
) ELSE (
|
) ELSE (
|
||||||
IF EXIST user.js.bak (
|
IF EXIST user.js.bak REN user.js.bak user.js
|
||||||
REN user.js.bak user.js
|
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
|
|
||||||
)
|
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO Update failed. Make sure PowerShell is allowed internet access.
|
ECHO Update failed. Make sure PowerShell is allowed internet access.
|
||||||
ECHO.
|
ECHO.
|
||||||
@ -181,42 +168,45 @@ IF EXIST user.js (
|
|||||||
IF NOT DEFINED _log (
|
IF NOT DEFINED _log (
|
||||||
IF NOT DEFINED _ua PAUSE
|
IF NOT DEFINED _ua PAUSE
|
||||||
)
|
)
|
||||||
:end
|
|
||||||
IF DEFINED _logp (
|
|
||||||
START user.js-update-log.txt
|
|
||||||
)
|
|
||||||
EXIT /B
|
EXIT /B
|
||||||
|
|
||||||
REM Function section starts below here
|
REM ###### Merge function ######
|
||||||
|
:merge
|
||||||
:mergeprefs
|
DEL /F %2 2>nul
|
||||||
FOR /F "tokens=* delims=" %%G IN (%~1) DO (
|
SETLOCAL disabledelayedexpansion
|
||||||
SET _pref=%%G
|
FOR /F "tokens=1,* delims=]" %%G IN ('find /n /v "" ^< "%~1"') DO (
|
||||||
|
SET "_pref=%%H"
|
||||||
|
SETLOCAL enabledelayedexpansion
|
||||||
SET "_temp=!_pref: =!"
|
SET "_temp=!_pref: =!"
|
||||||
IF /I "user_pref"=="!_temp:~0,9!" (
|
IF /I "user_pref"=="!_temp:~0,9!" (
|
||||||
|
IF /I NOT "user.js.parrot"=="!_temp:~12,14!" (
|
||||||
FOR /F "delims=," %%S IN ("!_pref!") DO (
|
FOR /F "delims=," %%S IN ("!_pref!") DO (
|
||||||
SET _pref=%%S
|
SET "_pref=%%S"
|
||||||
)
|
)
|
||||||
SET _pref=!_pref:"=""!
|
SET _pref=!_pref:"=""!
|
||||||
FIND /I "!_pref!" %~2 >nul 2>&1
|
FIND /I "!_pref!" %~2 >nul 2>&1
|
||||||
IF ERRORLEVEL 1 (
|
IF ERRORLEVEL 1 (
|
||||||
FIND /I "!_pref!" %~1 >temp123
|
FIND /I "!_pref!" %~1 >temp123
|
||||||
FOR /F "tokens=* delims=" %%X IN (temp123) DO (
|
FOR /F "tokens=* delims=" %%X IN (temp123) DO (
|
||||||
SET _temp=%%X
|
SET "_temp=%%X"
|
||||||
SET "_temp=!_temp: =!"
|
SET "_temp=!_temp: =!"
|
||||||
IF /I "user_pref"=="!_temp:~0,9!" (
|
IF /I "user_pref"=="!_temp:~0,9!" (
|
||||||
SET _pref=%%X
|
SET "_pref=%%X"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
ECHO !_pref!>>%~2
|
ECHO(!_pref!>>%~2
|
||||||
)
|
)
|
||||||
) ELSE (
|
) ELSE (
|
||||||
ECHO !_pref!>>%~2
|
ECHO(!_pref!>>%~2
|
||||||
)
|
)
|
||||||
|
) ELSE (
|
||||||
|
ECHO(!_pref!>>%~2
|
||||||
)
|
)
|
||||||
DEL /F temp123 2>nul
|
ENDLOCAL
|
||||||
REM DEL /F %~1 2>nul
|
)
|
||||||
|
ENDLOCAL
|
||||||
|
DEL /F %~1 temp123 >nul
|
||||||
GOTO EOF
|
GOTO EOF
|
||||||
REM end of mergeprefs
|
REM ############################
|
||||||
|
|
||||||
:EOF
|
:EOF
|
||||||
|
Loading…
Reference in New Issue
Block a user