AutoHotKey Script for patching your mods into Vivaldi
-
Vivaldi Modding Community,
I have spent considerable time working on a method to consistently patch mods into Vivaldi regardless of whether the application has been recently updated or not. @Christoph142 has posted a script to patch mods using Windows batch language, but I was looking for a script that would patch the mods regardless of whether vivaldi was updated recently or not and also one that could be easily made into a self-contained executable.
I have had some experience with the automation scripting language that AutoHotKey utilizes and would like to share the results with the Vivaldi community:
If only there was a command line method to download and install a Vivaldi update, than this could be fully automated... Still waiting on @Gwen-Dragon to get that code from the Vivaldi devs...
This AutoHotKey script assumes that the Vivaldi Application directory is located here:
C:\Program Files\Vivaldi\Application and the mod directory is located here:
C:\Program Files\Vivaldi\ModFolder\vivaldi but it also has an option for manual input for both of these directories as well as changing these default directory assumptions in the first section of the code.It is very important that your mod folder imitates the same directory structure as the Vivaldi installation.
For example:
C:\Program Files\Vivaldi\ModFolder\vivaldi
C:\Program Files\Vivaldi\ModFolder\vivaldi\browser.html
C:\Program Files\Vivaldi\ModFolder\vivaldi\custom.js
C:\Program Files\Vivaldi\ModFolder\vivaldi\resources
C:\Program Files\Vivaldi\ModFolder\vivaldi\style\custom.cssSo without further ado... here is the AutoHotKey code:
You will obviously need to download AutoHotKey in order to run it or convert it to a self-contained executable file for your usage. AutoHotKey can be downloaded here.
Enjoy!
;Misc Options #SingleInstance force #NoTrayIcon ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;Script provided by sethjbr;;;;;;;;;;;;;;;;; ;;;;;;;;;;built for the benefit of the Vivaldi Community;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Credits for original script design go to AutoHotKey forum user Corrupt @ https://autohotkey.com/board/topic/2712-using-loop-to-see-if-a-file-exists-and-get-its-path/ ;;Assistance with code development also go to AutoHotKey user KuroiLight @ https://autohotkey.com/boards/viewtopic.php?f=5&t=37354&p=173123#p173123 ; Important Notes about this script: ;;;;; This script has been designed to be run with AutoHotKey, but it can also be ;;;;; converted to a self-contained executable to place alongside your Vivaldi ;;;;; installation. ;;;;; I assume no liability for your use of this script and it comes with absolutely ;;;;; no warranty nor guarantee of any kind ;;;;; You are free to use this script for your own projects so long as these notices ;;;;; are retained ; Input your location for the Vivaldi Application folder below these ; three explanatory lines between the "" marks: ; The default for this directory is C:\Program Files\Vivaldi\Application Vivaldi_Application_Folder_Location := "C:\Program Files\Vivaldi\Application" ; Input your location for your Vivaldi mod folder below these ; three explanatory lines between the "" marks: ; The default for this directory is C:\Program Files\Vivaldi\ModFolder\vivaldi Vivaldi_Mod_Directory := "C:\Program Files\Vivaldi\ModFolder\vivaldi" ;;;;Keep in mind that your mod folder must imitate the folder structure of ;;;;the official Vivaldi application! ;;;;;;;For Example: ; C:\Program Files\Vivaldi\ModFolder\vivaldi ; C:\Program Files\Vivaldi\ModFolder\vivaldi\browser.html ; C:\Program Files\Vivaldi\ModFolder\vivaldi\custom.js ; C:\Program Files\Vivaldi\ModFolder\vivaldi\resources ; C:\Program Files\Vivaldi\ModFolder\vivaldi\style\custom.css" ;;;;; It is strongly recommended that you do not modify anything below this line Vivaldi_Install_Location_Identifier := "browser.html" Vivaldi_Mod_Install_Location := "" loop, %Vivaldi_Application_Folder_Location%\*.*, 1, 1 ; Vivaldi_Install_Location_Identifier the library for the file to get the full path { if (A_LoopFileName == Vivaldi_Install_Location_Identifier) { Vivaldi_Mod_Install_Location := A_LoopFileDir } } if (!Vivaldi_Mod_Install_Location) { MsgBox, % "This default Vivaldi application folder directory is incorrect:`n`n" . Vivaldi_Application_Folder_Location . "`n`nBecause I am a nice script, there will now be an opportunity to manually input or paste the location for both of the following:`n`n1. Custom Vivaldi Mod Directory`n2. Custom Vivaldi Mod Installation Location`n`nIMPORTANT: Your mod folder structure should have the same folder structure as the Vivaldi application folder.`n`nFor Example:`n`nC:\Program Files\Vivaldi\ModFolder\vivaldi`nC:\Program Files\Vivaldi\ModFolder\vivaldi\browser.html`nC:\Program Files\Vivaldi\ModFolder\vivaldi\custom.js`nC:\Program Files\Vivaldi\ModFolder\vivaldi\resources`nC:\Program Files\Vivaldi\ModFolder\vivaldi\style\custom.css" InputBox, Custom_Vivaldi_Mod_Directory, Manual Vivaldi Custom Mod Directory Input:, Please input the correct vivaldi folder path where your vivaldi mod folder can be found:., , 500,100,,,,,C:\Program Files\Vivaldi\ModFolder\vivaldi InputBox, Custom_Vivaldi_Mod_Install_Location, Manual Vivaldi Browser.html Folder Location Entry, Please input the correct vivaldi folder path where browser.html can be found:., , 700,100,,,,,C:\Program Files\Vivaldi\Application\1.12.955.36\resources\vivaldi if ErrorLevel MsgBox, Oops... It looks like cancel was pressed at least once or the process was terminated unexpectedly. `n`nPlease launch the process again. else FileCopyDir, %Custom_Vivaldi_Mod_Directory%, %Custom_Vivaldi_Mod_Install_Location%, 1 } else { MsgBox, % "Vivaldi's browser.html was successfully found here in the default directory: `n`n" . Vivaldi_Mod_Install_Location . "`n`nThe Vivaldi mod directory is assumed to be located here:`n`n" . Vivaldi_Mod_Directory . "`n`nAfter clicking on OK, the Vivaldi mod files will be copied to their appropriate destination.`n`nIMPORTANT: Your mod folder structure should have the same folder structure as the Vivaldi application folder.`n`nFor Example:`n`nC:\Program Files\Vivaldi\ModFolder\vivaldi`nC:\Program Files\Vivaldi\ModFolder\vivaldi\browser.html`nC:\Program Files\Vivaldi\ModFolder\vivaldi\custom.js`nC:\Program Files\Vivaldi\ModFolder\vivaldi\resources`nC:\Program Files\Vivaldi\ModFolder\vivaldi\style\custom.css" FileCopyDir, %Vivaldi_Mod_Directory%, %Vivaldi_Mod_Install_Location%, 1 Sleep, 1000 } Sleep, 333 return
-
@sethjbr What happens if the browser.html in ModFolder\vivaldi\browser.html is too old and fails? Is a backup created?
-
@legobuilder26 It would actually be best to do a diff of the browser.html file and present a confirmation of that diff for the user to verify & cancel out of there are any unexpected differences. Then the user can go and modify their browser.html as needed and run it again.
-