mirror of
				https://github.com/arkenfox/user.js.git
				synced 2025-11-04 07:45:26 +01:00 
			
		
		
		
	updater for Windows v4.5 (#407)
support commenting-out active user-prefs with the merge function
This commit is contained in:
		
							
								
								
									
										17
									
								
								updater.bat
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								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: 4.4
 | 
					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
 | 
				
			||||||
@@ -75,7 +75,7 @@ ECHO:
 | 
				
			|||||||
ECHO:                ########################################
 | 
					ECHO:                ########################################
 | 
				
			||||||
ECHO:                ####  user.js Updater for Windows   ####
 | 
					ECHO:                ####  user.js Updater for Windows   ####
 | 
				
			||||||
ECHO:                ####       by claustromaniac        ####
 | 
					ECHO:                ####       by claustromaniac        ####
 | 
				
			||||||
ECHO:                ####             v4.4               ####
 | 
					ECHO:                ####             v4.5               ####
 | 
				
			||||||
ECHO:                ########################################
 | 
					ECHO:                ########################################
 | 
				
			||||||
ECHO:
 | 
					ECHO:
 | 
				
			||||||
SET /A "_line=0"
 | 
					SET /A "_line=0"
 | 
				
			||||||
@@ -191,8 +191,9 @@ 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:"^//// --- comment-out --- '[^'][^']*'.*" "%~1"') DO (SET "__unset__%%G=1")
 | 
				
			||||||
(
 | 
					(
 | 
				
			||||||
	FOR /F tokens^=2^,^*^ delims^=^'^" %%G IN ('FINDSTR /B /R /C:"user_pref.*\)[ 	]*;" "%~1"') DO (IF NOT "%%H"=="" (SET "%%G=%%H"))
 | 
					 | 
				
			||||||
	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
 | 
				
			||||||
@@ -205,11 +206,15 @@ SETLOCAL DisableDelayedExpansion
 | 
				
			|||||||
				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 %%K (
 | 
											IF DEFINED __unset__%%K (
 | 
				
			||||||
 | 
												ECHO://%%J
 | 
				
			||||||
 | 
											) ELSE (
 | 
				
			||||||
 | 
												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)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user