Patching Vivaldi with batch scripts
-
-
-
@Pathduck No, that’s wrong. It was something like: “Give a fish a stick and it can eat itself; throw the fish into a forest and it will lose its desire for sticks.”
edit: but I can’t recall whether the fish will make any sound when landing in the shrubbery. That’s something to consider.
-
@Pathduck It does work, but you're right. I didn't noticed that the script wasn't inside of the
body
-
Now this is the code to patch Vivaldi correctly:
:: end Vivaldi :: taskkill /F /IM vivaldi.exe /T @echo off setlocal enabledelayedexpansion :: This is a list of your Vivaldi installations' Application folders (you can use the Vivaldi folder, too, but it takes longer to find the file): set installPaths="D:\Anwendungen\Vivaldi\Application" :: Don't alter anything below this point ;) set nrOfInstalls=0 set "SuccessfulPatched=Couldn't Patch :^(" for %%i in (%installPaths%) do ( <NUL set /p=Searching for newest window.html in %%~dpi... set /a nrOfInstalls=nrOfInstalls+1 set installPath=%%~dpi set latestVersionFolder= for /f "tokens=*" %%a in ('dir /a:-d /b /s "!installPath!"') do ( if "%%~nxa"=="window.html" set latestVersionFolder=%%~dpa ) if not defined latestVersionFolder ( set cnt=any echo. echo Couldn't find it. :( echo Is !installPath! the correct Vivaldi Application folder? echo. ) else ( echo Found it. echo. if exist !latestVersionFolder!\window.bak.html ( echo Backup is already in place. ) else ( echo Creating a backup of your original window.html file. copy /y "!latestVersionFolder!\window.html" "!latestVersionFolder!\window.bak.html" ) echo. ) ) findstr /v custom.js "!latestVersionFolder!\window.html" > temp0.txt setlocal disabledelayedexpansion ( FOR /F "tokens=*" %%A IN (temp0.txt) DO ( IF "%%A" EQU "</body>" ( echo ^<script src="custom.js"^>^</script^> ) ECHO %%A ) ) >temp.txt setlocal enabledelayedexpansion type *.js > !latestVersionFolder!\custom.js move /Y temp.txt "!latestVersionFolder!window.html" del temp0.txt echo. echo Copied files^^! set cnt=0 for %%A in (*.js) do set /a cnt+=1 set "SuccessfulPatched=Succesfully Patched" echo. echo. echo All done^^! :) !SuccessfulPatched! !cnt! .js files^^! echo. echo. :: Start Vivaldi :: echo Start Vivaldi^^! cd .. cd Application start vivaldi.exe timeout 5 exit
The result looks like this:
<!-- Vivaldi window document --> <!DOCTYPE html> <html> <head> <!-- Keep the styling in sync with ./browser.html --> <meta charset="UTF-8" /> <title>Vivaldi</title> <link rel="stylesheet" href="style/common.css" /> <link rel="stylesheet" href="chrome://vivaldi-data/css-mods/css" /> </head> <body> <script src="custom.js"></script> </body> </html>
-
Be the only good person in this forum (you know who I mean) and post the details of the two files.
-
@barbudo2005 Sorry, we are cruel with our hints... Does this help?
$ tidy <!-- Vivaldi window document --> <!DOCTYPE html> <html> <head> <!-- Keep the styling in sync with ./browser.html --> <meta charset="UTF-8" /> <title>Vivaldi</title> <link rel="stylesheet" href="style/common.css" /> <link rel="stylesheet" href="chrome://vivaldi-data/css-mods/css" /> </head> <body></body> <script src="custom.js"></script> </html>line 11 column 3 - Warning: content occurs after end of body <!-- Vivaldi window document --> <!DOCTYPE html> <html> <head> <!-- Keep the styling in sync with ./browser.html --> <meta charset="UTF-8"> <title>Vivaldi</title> <link rel="stylesheet" href="style/common.css"> <link rel="stylesheet" href="chrome://vivaldi-data/css-mods/css"> </head> <body> <script src="custom.js"></script> </body> </html>
-
@barbudo2005 What do you mean? The first block of code is the updated version of the patch.bat file from the first post. The second code block is the correct result, where the custom code is inside of
<body> ... </body>
-
Thanks, my post crossed with yours.
-
You have redeemed yourself "in time". The other character will remain on the blacklist for quite some time.
-
-
@barbudo2005 You don't have to change
browser.html
butwindow.html
-
@oudstand Thank you.
I understand that to get the best speed in Vivaldi, this is the correct setting:
-
@barbudo2005 No the other way around - Enable portals by turning that option OFF.
-
@Pathduck Thank you.
-
Since the batch script in the OP is broken now that
window.html
is the one to be modified and notbrowser.html
anymore. And I wasn't able to get any of the newer batch scripts posted here to work on Windows, I modified the script posted by @Christoph142.I just changed all instances of
browser.html
andbrowser.bak.html
towindow.html
andwindow.bak.html
respectively. Which looks to have worked perfectly. Thanks to @debiedowner for the script and @Christoph142 for posting it.Here's the modified script:
:: Author: debiedowner @echo off REM make current directory work when run as administrator cd "%~dp0" set installPath="C:\Users\Steve.Bachand\AppData\Local\Vivaldi\Application\" echo Searching at: %installPath% for /f "tokens=*" %%a in ('dir /a:-d /b /s %installPath%') do ( if "%%~nxa"=="window.html" set latestVersionFolder=%%~dpa ) if "%latestVersionFolder%"=="" ( pause & exit ) else ( echo Found latest version folder: "%latestVersionFolder%" ) if not exist "%latestVersionFolder%\window.bak.html" ( echo Creating a backup of your original window.html file. copy "%latestVersionFolder%\window.html" "%latestVersionFolder%\window.bak.html" ) echo copying js files to custom.js type *.js > "%latestVersionFolder%\custom.js" echo patching window.html file type "%latestVersionFolder%\window.bak.html" | findstr /v "</body>" | findstr /v "</html>" > "%latestVersionFolder%\window.html" echo ^<script src="custom.js"^>^</script^> >> "%latestVersionFolder%\window.html" echo ^</body^> >> "%latestVersionFolder%\window.html" echo ^</html^> >> "%latestVersionFolder%\window.html" pause
-
In the last stable update 6.4.3160.42 or in the previous custom.js stopped working.
My files are:
browser.html:
<!DOCTYPE html> <html> <head> <!-- Keep the styling in sync with ./window.html --> <meta charset="UTF-8" /> <title>Vivaldi</title> <link rel="stylesheet" href="style/common.css" /> <link rel="stylesheet" href="chrome://vivaldi-data/css-mods/css" /> </head> <body> <div id="app" /> <script src="vendor-bundle.js"></script> <script src="background-common-bundle.js"></script> <script src="bundle.js"></script> </body> </html>
window.html
<!-- Vivaldi window document --> <!DOCTYPE html> <html> <head> <!-- Keep the styling in sync with ./browser.html --> <meta charset="UTF-8"> <title>Vivaldi</title> <link rel="stylesheet" href="style/common.css"> <link rel="stylesheet" href="chrome://vivaldi-data/css-mods/css"> </head> <body> <script src="custom.js"></script> </body> </html>
What could be the cause of this problem?
-
@explorerthegeneral this hasn't worked for me. or do i need to put the files in the window file first and then it will work from then on?
-
Windows
Here is a modified Version without the need to edit the Installation Path(If Vivaldi is installed as a user):
:: Author: debiedowner :: Editor: Phobos @echo off REM make current directory work when run as administrator cd "%~dp0" set installPath="%localappdata%\Vivaldi\Application\" echo Searching at: %installPath% for /f "tokens=*" %%a in ('dir /a:-d /b /s %installPath%') do ( if "%%~nxa"=="window.html" set latestVersionFolder=%%~dpa ) if "%latestVersionFolder%"=="" ( echo No window.html found in "%latestVersionFolder%" pause & exit ) else ( echo Found latest version folder: "%latestVersionFolder%" ) if not exist "%latestVersionFolder%\window.bak.html" ( echo Creating a backup of your original window.html file. copy "%latestVersionFolder%\window.html" "%latestVersionFolder%\window.bak.html" ) echo copying js files to custom.js type *.js > "%latestVersionFolder%\custom.js" echo patching window.html file type "%latestVersionFolder%\window.bak.html" | findstr /v "</body>" | findstr /v "</html>" > "%latestVersionFolder%\window.html" echo ^<script src="custom.js"^>^</script^> >> "%latestVersionFolder%\window.html" echo ^</body^> >> "%latestVersionFolder%\window.html" echo ^</html^> >> "%latestVersionFolder%\window.html" pause
-
This doesn't seem to work on Mac. It places the custom script file in the folder, but it doesn't edit the browser.html file.
This is what my custom script looks like:
#!/bin/bash # Original version by Isildur, adapted by luetage # Quit Vivaldi osascript -e 'quit app "Vivaldi.app"' # Find path to Framework folder of current version and save it as variable findPath="`find /Applications/Vivaldi.app -name Vivaldi\ Framework.framework`" # Copy custom js file to Vivaldi.app cp "/Applications/Vivaldi Mods/global-media-controls.js" "$findPath"/Resources/vivaldi/ # Save path to window.html as variable browserHtml="$findPath"/Resources/vivaldi/window.html # Insert references, if not present, and save to temporary file sed 's| </body>| <script src="global-media-controls.js"></script></body>|' "$browserHtml" > "$browserHtml".temp # Backup original file cp "$browserHtml" "$browserHtml".bak # Overwrite mv "$browserHtml".temp "$browserHtml" # Pause script read -rsp $'Press [Enter] to restart Vivaldi...\n' # Open Vivaldi open /Applications/Vivaldi.app