From e25137ce94a4074ae283ce436f3e126c0042eff6 Mon Sep 17 00:00:00 2001 From: claustromaniac <20734810+claustromaniac@users.noreply.github.com> Date: Wed, 18 Apr 2018 16:18:43 +0000 Subject: [PATCH 1/7] v2 Mostly a bump in performance. --- prefsCleaner.bat | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/prefsCleaner.bat b/prefsCleaner.bat index 33146df..605aff8 100644 --- a/prefsCleaner.bat +++ b/prefsCleaner.bat @@ -1,18 +1,17 @@ -@ECHO OFF +@ECHO OFF & SETLOCAL DisableDelayedExpansion TITLE prefs.js cleaner REM ### prefs.js cleaner for Windows REM ## author: @claustromaniac -REM ## version: 1.2 +REM ## version: 2.0 -SETLOCAL EnableDelayedExpansion :begin ECHO: ECHO: ECHO ######################################## ECHO #### prefs.js cleaner for Windows #### ECHO #### by claustromaniac #### -ECHO #### v1.2 #### +ECHO #### v2.0 #### ECHO ######################################## ECHO: CALL :message "This script should be run from your Firefox profile directory." @@ -29,12 +28,14 @@ IF NOT EXIST "user.js" (CALL :abort "user.js not found in the current directory. IF NOT EXIST "prefs.js" (CALL :abort "prefs.js not found in the current directory." 30) CALL :FFcheck CALL :message "Backing up prefs.js..." -COPY /B /V /Y prefs.js "prefs-backup-!date:/=-!_!time::=.!.js" +SET "_time=%time: =0%" +COPY /B /V /Y prefs.js "prefs-backup-%date:/=-%_%_time::=.%.js" CALL :message "Cleaning prefs.js..." CALL :cleanup CLS CALL :message "All done^!" TIMEOUT 5 >nul +ENDLOCAL EXIT /B REM ########## Abort Function ########### @@ -44,11 +45,9 @@ TIMEOUT %~2 >nul EXIT REM ########## Message Function ######### :message -SETLOCAL DisableDelayedExpansion ECHO: ECHO: %~1 ECHO: -ENDLOCAL GOTO :EOF REM ####### Firefox Check Function ###### :FFcheck @@ -67,23 +66,16 @@ IF NOT ERRORLEVEL 1 ( GOTO :EOF REM ######### Cleanup Function ########## :cleanup -SETLOCAL DisableDelayedExpansion ( + FOR /F tokens^=2^ delims^=^'^" %%G IN ('FINDSTR /R /C:"^[^'\"]*user_pref[^;]*\)[ ]*;" "user.js"') DO (SET "[%%G]=1") FOR /F "tokens=1,* delims=:" %%G IN ('FINDSTR /N "^" prefs.js') DO ( - SET "_line=%%H" - SETLOCAL EnableDelayedExpansion - IF /I "user_pref"=="!_line:~0,9!" ( - FOR /F tokens^=2^ delims^=^" %%I IN ("!_line:.=\.!") DO ( - FINDSTR /R /C:"user_pref[ ]*\([ ]*[\"']%%I[\"'][ ]*," user.js >nul - IF ERRORLEVEL 1 (ECHO:!_line!) + FOR /F tokens^=2^ delims^=^" %%I IN ("%%H") DO ( + IF NOT DEFINED [%%I] ( + ECHO:%%H ) - ) ELSE ( - ECHO:!_line! ) - ENDLOCAL ) )>tempcleanedprefs -ENDLOCAL MOVE /Y tempcleanedprefs prefs.js GOTO :EOF REM ############### Help ################## From 3d2b0703bedee1c12b86cd508757e0a27802482c Mon Sep 17 00:00:00 2001 From: claustromaniac <20734810+claustromaniac@users.noreply.github.com> Date: Wed, 18 Apr 2018 18:49:36 +0000 Subject: [PATCH 2/7] actually working v2 --- prefsCleaner.bat | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/prefsCleaner.bat b/prefsCleaner.bat index 605aff8..46abc15 100644 --- a/prefsCleaner.bat +++ b/prefsCleaner.bat @@ -33,7 +33,7 @@ COPY /B /V /Y prefs.js "prefs-backup-%date:/=-%_%_time::=.%.js" CALL :message "Cleaning prefs.js..." CALL :cleanup CLS -CALL :message "All done^!" +CALL :message "All done!" TIMEOUT 5 >nul ENDLOCAL EXIT /B @@ -56,7 +56,7 @@ IF NOT ERRORLEVEL 1 ( CLS CALL :message "Firefox is still running." ECHO If you're not currently using this profile you can continue, otherwise - CALL :message "close Firefox first^!" + CALL :message "close Firefox first!" ECHO: PAUSE CLS @@ -67,10 +67,12 @@ GOTO :EOF REM ######### Cleanup Function ########## :cleanup ( - FOR /F tokens^=2^ delims^=^'^" %%G IN ('FINDSTR /R /C:"^[^'\"]*user_pref[^;]*\)[ ]*;" "user.js"') DO (SET "[%%G]=1") + FOR /F tokens^=2^ delims^=^'^" %%G IN ('FINDSTR /R ^^[^^\^"^']*user_pref user.js') DO ( + IF NOT ""=="%%G" (SET "[%%G]=1") + ) FOR /F "tokens=1,* delims=:" %%G IN ('FINDSTR /N "^" prefs.js') DO ( - FOR /F tokens^=2^ delims^=^" %%I IN ("%%H") DO ( - IF NOT DEFINED [%%I] ( + FOR /F tokens^=1^,2^ delims^=^" %%I IN ("%%H") DO ( + IF NOT DEFINED [%%J] ( ECHO:%%H ) ) From 824dec4f9e14ad503d71e47705349ae0691a969c Mon Sep 17 00:00:00 2001 From: claustromaniac <20734810+claustromaniac@users.noreply.github.com> Date: Wed, 18 Apr 2018 20:29:39 +0000 Subject: [PATCH 3/7] Update prefsCleaner.bat --- prefsCleaner.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prefsCleaner.bat b/prefsCleaner.bat index 46abc15..3964b6d 100644 --- a/prefsCleaner.bat +++ b/prefsCleaner.bat @@ -67,7 +67,7 @@ GOTO :EOF REM ######### Cleanup Function ########## :cleanup ( - FOR /F tokens^=2^ delims^=^'^" %%G IN ('FINDSTR /R ^^[^^\^"^']*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") ) FOR /F "tokens=1,* delims=:" %%G IN ('FINDSTR /N "^" prefs.js') DO ( From 64d08dd6bc8a53078ed56d0f1c7d898c16c4cbef Mon Sep 17 00:00:00 2001 From: claustromaniac <20734810+claustromaniac@users.noreply.github.com> Date: Wed, 18 Apr 2018 20:33:39 +0000 Subject: [PATCH 4/7] Update updater.bat --- updater.bat | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/updater.bat b/updater.bat index 0df74bb..baa96cc 100644 --- a/updater.bat +++ b/updater.bat @@ -66,7 +66,7 @@ IF DEFINED _updateb ( START CMD /C "!_myname:~9!.bat" !_myparams! ) ) - EXIT /B + EXIT /B ) :begin CLS @@ -157,7 +157,8 @@ IF EXIST user.js.new ( IF DEFINED _singlebackup ( MOVE /Y user.js user.js.bak >nul ) ELSE ( - MOVE /Y user.js "user-backup-!date:/=-!_!time::=.!.js" >nul + SET "_time=!time: =0!" + MOVE /Y user.js "user-backup-!date:/=-!_!_time::=.!.js" >nul ) REN user.js.new user.js CALL :message "Update complete." From b0fb59f735b23466824d66878a50fcc76d5a72ca Mon Sep 17 00:00:00 2001 From: claustromaniac <20734810+claustromaniac@users.noreply.github.com> Date: Wed, 18 Apr 2018 22:42:06 +0000 Subject: [PATCH 5/7] shit is so fast I can't even read --- prefsCleaner.bat | 1 - 1 file changed, 1 deletion(-) diff --git a/prefsCleaner.bat b/prefsCleaner.bat index 3964b6d..b74317f 100644 --- a/prefsCleaner.bat +++ b/prefsCleaner.bat @@ -32,7 +32,6 @@ SET "_time=%time: =0%" COPY /B /V /Y prefs.js "prefs-backup-%date:/=-%_%_time::=.%.js" CALL :message "Cleaning prefs.js..." CALL :cleanup -CLS CALL :message "All done!" TIMEOUT 5 >nul ENDLOCAL From 8fa3a9db6b0bc212cbe04539354c511c976adc7c Mon Sep 17 00:00:00 2001 From: claustromaniac <20734810+claustromaniac@users.noreply.github.com> Date: Sat, 21 Apr 2018 14:34:08 +0000 Subject: [PATCH 6/7] fix for missing empty lines --- prefsCleaner.bat | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/prefsCleaner.bat b/prefsCleaner.bat index b74317f..b5ff0dc 100644 --- a/prefsCleaner.bat +++ b/prefsCleaner.bat @@ -70,9 +70,13 @@ REM ######### Cleanup Function ########## IF NOT ""=="%%G" (SET "[%%G]=1") ) FOR /F "tokens=1,* delims=:" %%G IN ('FINDSTR /N "^" prefs.js') DO ( - FOR /F tokens^=1^,2^ delims^=^" %%I IN ("%%H") DO ( - IF NOT DEFINED [%%J] ( - ECHO:%%H + IF ""=="%%H" ( + ECHO: + ) ELSE ( + FOR /F tokens^=1^,2^ delims^=^" %%I IN ("%%H") DO ( + IF NOT DEFINED [%%J] ( + ECHO:%%H + ) ) ) ) From fdac8fba6a59d05800dd5a4cd0605fec764136ae Mon Sep 17 00:00:00 2001 From: claustromaniac <20734810+claustromaniac@users.noreply.github.com> Date: Sun, 22 Apr 2018 01:34:48 +0000 Subject: [PATCH 7/7] Update prefsCleaner.bat --- prefsCleaner.bat | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/prefsCleaner.bat b/prefsCleaner.bat index b5ff0dc..91a81a5 100644 --- a/prefsCleaner.bat +++ b/prefsCleaner.bat @@ -65,18 +65,16 @@ IF NOT ERRORLEVEL 1 ( GOTO :EOF REM ######### Cleanup Function ########## :cleanup +FOR /F tokens^=2^ delims^=^'^" %%G IN ('FINDSTR /R /C:"^[^\"']*user_pref[ ]*\([ ]*[\"'][^\"']*[\"'][ ]*," user.js') DO ( + IF NOT ""=="%%G" (SET "[%%G]=1") +) ( - FOR /F tokens^=2^ delims^=^'^" %%G IN ('FINDSTR /R /C:"^[^\"']*user_pref[ ]*\([ ]*[\"'][^\"']*[\"'][ ]*," user.js') DO ( - IF NOT ""=="%%G" (SET "[%%G]=1") - ) FOR /F "tokens=1,* delims=:" %%G IN ('FINDSTR /N "^" prefs.js') DO ( IF ""=="%%H" ( ECHO: ) ELSE ( - FOR /F tokens^=1^,2^ delims^=^" %%I IN ("%%H") DO ( - IF NOT DEFINED [%%J] ( - ECHO:%%H - ) + FOR /F tokens^=1^,2^ delims^=^"^' %%I IN ("%%H") DO ( + IF NOT DEFINED [%%J] (ECHO:%%H) ) ) )