Windows batch file for patching your mods into Vivaldi



  • As mentioned in the introductory post, we are aware that every update wipes your mods, which is pretty annoying if you need to reapply them each and every time. Until there is a way in Vivaldi that rids this need, I tinkered a little batch script that patches your mods into Vivaldi:

    :::::::::::::::::::::::::::::::::::::::::::
    :: Script to copy over your Vivaldi mods ::
    :: by Christoph142                       ::
    :::::::::::::::::::::::::::::::::::::::::::
    
    @echo off
    setlocal enabledelayedexpansion
    
    :: This is the folder that contains your modded files (make sure it uses similar folder structure):
    set "modFolder=C:\Users\You\Test\Vivaldi Mod Files"
    :: 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="C:\Users\You\AppData\Local\Vivaldi\Application\" "C:\Users\You\Test\Snapshot\Application\"
    
    :: Don't alter anything below this point ;)
    
    set nrOfInstalls=0
    set nrOfSuccessfulPatches=0
    
    for %%i in (%installPaths%) do (
    	<NUL set /p=Searching for newest browser.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"=="browser.html" set latestVersionFolder=%%~dpa
    	)
    
    	if not defined latestVersionFolder (
    		echo.
    		echo Couldn't find it. :(
    		echo Is !installPath! the correct Vivaldi Application folder?
    		echo.
    	) else (
    		echo Found it.
    		echo.
    
    		if exist !latestVersionFolder!\browser.bak.html (
    			echo Backup is already in place.
    		) else (
    			echo Creating a backup of your original browser.html file.
    			rename "!latestVersionFolder!\browser.html" "browser.bak.html"
    		)
    		echo.
    
    		echo Copying files
    		echo    from %modFolder%
    		echo    into !latestVersionFolder!:
    
    		xcopy /s /y "%modFolder%" "!latestVersionFolder!"
    
    		echo.
    
    		set /a nrOfSuccessfulPatches=nrOfSuccessfulPatches+1
    	)
    )
    
    echo All done^^! :)
    echo Successfully patched %nrOfSuccessfulPatches% out of %nrOfInstalls% installs.
    echo.
    pause
    

    To use it, simply enter your mod folder as well as the application folders of the Vivaldi installs you want to patch into the file once. After each Vivaldi update you can then execute this script and be done. ;)



  • set "modFolder=C:\Users\You\Vivaldi Mod Files"
    seems wrong to me, should be, if anything
    set modFolder="C:\Users\You\Vivaldi Mod Files"
    you can also use %LOCALAPPDATA% instead of C:\Users\You\AppData\Local
    and %USERPROFILE% instead of C:\Users\You



  • It seems odd, but this is the only correct way of assigning paths including whitespaces to a batch script variable. ;)
    Your version assigns a string including the quotation marks to the variable.

    And you know that these folders are example paths, right? They don't get used in production unless you forget to substitute them. :silly:



  • it's strange, it doesn't seem needed to me

    set "modFolder=C:\Users\You\Vivaldi Mod Files"
    echo x%modFolder%x
    set modFolder=C:\Users\You\Vivaldi Mod Files
    echo x%modFolder%x

    this produces the same output, no need of quotes at all



  • Believe me, you do. Echoing (as text) is not the same as using it as a folder. This script got tested by us and is solid.



  • @Christoph142:

    And you know that these folders are example paths, right? They don't get used in production unless you forget to substitute them. :silly:

    of course, these system variables are already set so you don't have to edit the batch everytime you change user or pc =)



  • Mod folder and batch file should be put together to work correctly?
    Custom.css copying worked, but other files are not always correctly copied (the browser.html was backed up, but not copied); it says something like "cyclic error".

    I've script in C:\Portable programs\VivaldiRC\script.bat
    and mod folder in C:\Portable programs\VivaldiRC\Application\Mod
    Paths in the batch points to my mod folder/vivaldi, obviously :P



  • You seem to be doing something wrong.
    You can place the mod where you want. It doesn't need to stay in your modding directory.
    Just make sure to set
    [ul]

    • modFolder to the root of your mods (i.e. "modFolder=C:\Portable programs\VivaldiRC\Application\Mod") and
    • installPaths to your Vivaldi Application directory (i.e. installPaths="C:\Portable programs\VivaldiRC\Application" in your case)
      [/ul]

    and pay attention to not add additional whitespaces and keep the quotation marks where they are. ;)



  • Searching for newest browser.html in C:\Users\Bende\AppData\Local\Vivaldi\Application\...'dir /a:-d /b /s "C:\Users\Bende\AppData\Local\Vivaldi\Application\"' is not recognized as an internal or external command, operable program or batch file.
    
    Couldn't find it. :(
    Is C:\Users\Bende\AppData\Local\Vivaldi\Application\ the correct Vivaldi Application folder?
    
    All done! :)
    Successfully patched 0 out of 1 installs.
    
    Press any key to continue . . .
    

    It's kind of difficult to make out the code as Markdown has mangled it somewhat (whoever devised Markdown as a formatting system needs shooting before they reproduce any more), but as far as I can tell, the Command Prompt is parsing the dir command incorrectly, and it is not performing the search that the command ought to do. The only things in this Batch that I've modified are the two sets at the top.

    To answer the Batch File's query: yes, that is the correct Application folder. it has the Application in it.
    So what's going on?



  • Hi, the new forum doesn't display correctly the first post :-(



  • @Hobbes Yeah, the new forum unfortunately doesn't support the same markup as the old one did. I tried to fix that for you ;)



  • @Christoph142
    Great, thanks !



  • Does anyone have the complete version of this? I don't think the snippets above can possibly be all.



  • @rseiler It wasn't. It seems to have been corrupted at some point. I uploaded it again just now.



  • It would be really nice if Vivaldi could finally implement an official method. Is anything developing on that front?



  • @luetage not to my knowledge I'm afraid. But I'll keep bugging them. ;)


Log in to reply
 

Looks like your connection to Vivaldi Forum was lost, please wait while we try to reconnect.