1
0
Mostly a bump in performance.
This commit is contained in:
claustromaniac 2018-04-18 16:18:43 +00:00 committed by GitHub
parent 6ee25c2bf5
commit e25137ce94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,18 +1,17 @@
@ECHO OFF @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: 1.2 REM ## version: 2.0
SETLOCAL EnableDelayedExpansion
: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 #### v1.2 #### ECHO #### v2.0 ####
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."
@ -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) 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..."
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 :message "Cleaning prefs.js..."
CALL :cleanup CALL :cleanup
CLS CLS
CALL :message "All done^!" CALL :message "All done^!"
TIMEOUT 5 >nul TIMEOUT 5 >nul
ENDLOCAL
EXIT /B EXIT /B
REM ########## Abort Function ########### REM ########## Abort Function ###########
@ -44,11 +45,9 @@ TIMEOUT %~2 >nul
EXIT EXIT
REM ########## Message Function ######### REM ########## Message Function #########
:message :message
SETLOCAL DisableDelayedExpansion
ECHO: ECHO:
ECHO: %~1 ECHO: %~1
ECHO: ECHO:
ENDLOCAL
GOTO :EOF GOTO :EOF
REM ####### Firefox Check Function ###### REM ####### Firefox Check Function ######
:FFcheck :FFcheck
@ -67,23 +66,16 @@ IF NOT ERRORLEVEL 1 (
GOTO :EOF GOTO :EOF
REM ######### Cleanup Function ########## REM ######### Cleanup Function ##########
:cleanup :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 ( FOR /F "tokens=1,* delims=:" %%G IN ('FINDSTR /N "^" prefs.js') DO (
SET "_line=%%H" FOR /F tokens^=2^ delims^=^" %%I IN ("%%H") DO (
SETLOCAL EnableDelayedExpansion IF NOT DEFINED [%%I] (
IF /I "user_pref"=="!_line:~0,9!" ( ECHO:%%H
FOR /F tokens^=2^ delims^=^" %%I IN ("!_line:.=\.!") DO (
FINDSTR /R /C:"user_pref[ ]*\([ ]*[\"']%%I[\"'][ ]*," user.js >nul
IF ERRORLEVEL 1 (ECHO:!_line!)
) )
) ELSE (
ECHO:!_line!
) )
ENDLOCAL
) )
)>tempcleanedprefs )>tempcleanedprefs
ENDLOCAL
MOVE /Y tempcleanedprefs prefs.js MOVE /Y tempcleanedprefs prefs.js
GOTO :EOF GOTO :EOF
REM ############### Help ################## REM ############### Help ##################