justdanpo / VivaldiHooks

VivaldiHooks is a set of hooks/scripts for Vivaldi browser modding.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Snapshot 4.3.2431.3 - VivaldiHooks broken, no hooks loaded.

Pathduck opened this issue · comments

Today's snapshot seems to have completely broken VivaldiHooks, it does not initialize at all 😿

confirmed broken =) Let's wait

Looks bad :(

I'm hoping the Devs haven't changed the code in such a way as to make VH impossible to implement.

Today's Vivaldi update (43.2439.39) neutered VivaldiHooks. :-(

I chose the wrong day to try out vivaldihooks apparently...

Today's Vivaldi update (43.2439.39) neutered VivaldiHooks. :-(

It's been broken for over two weeks in the snapshot branch. And judging from the lack of updates, I assume this project has been abandoned now.

I suppose you have already figured this part out, but just in case here are my current findings: you can get to understandable errors (about strict mode) with this patch (as of Vivaldi 4.3.2439.41)

@@ -8,1 +8,1 @@
-    const jdhooks_module_index = 'jdhooks_module'
+    const jdhooks_module_index = 36331
@@ -726,2 +726,2 @@
-    window.webpackJsonp.push([[0], { [jdhooks_module_index]: jdhooks_module_step1 }, [[jdhooks_module_index]]])
+    window.webpackChunkgapp_browser_react.push([[0], { [jdhooks_module_index]: jdhooks_module_step1 }])

I have found that magic number at the end of bundle.js (739 and 277 are used in two of Vivaldi’s files). Unfortunately it is likely to change…

var s = i.O(void 0, [ 739, 277 ], (() => i(36331)));

update [2021-20-21]: a hack-ish way to get the number is reading the file (like when fetching hook descriptions) and matching with this regex (obvious problem – it depends on the code not to change)

/(?<=\[\d+,\d+\],\(\(\)=>[a-zA-Z]\()\d+(?=\)\)\);[a-zA-Z]=[a-zA-Z](\.[a-zA-Z])?\([a-zA-Z]\)\}\)\(\);$)/

so i guess we better go & find a more reliable way.

Update: i have managed to get a little bit further. Current patch is still not working, most of it is me trying if i can get past the current error & if it’ll get me any useful results. First steps made thanks to a random user found via GitHub search.

Giving up atm, will try to continue sometime later.

diff --git a/jdhooks.js b/opt/vivaldi-snapshot/resources/vivaldi/jdhooks.js
index 864b4ca..ac15437 100644
--- a/jdhooks.js
+++ b/opt/vivaldi-snapshot/resources/vivaldi/jdhooks.js
@@ -48,6 +48,10 @@
 
     //hookModuleExport(moduleName, exportName, export => newExport)
     const hookModuleExport = vivaldi.jdhooks.hookModuleExport = (moduleName, exportName, cb) => {
+        if (!vivaldi.jdhooks._moduleMap[moduleName]) {
+            console.log("no module called", moduleName);
+            return;
+        }
         const moduleIndex = vivaldi.jdhooks._moduleMap[moduleName].idx
         const oldfn = vivaldi.jdhooks._modules[moduleIndex]
         vivaldi.jdhooks._modules[moduleIndex] = (moduleInfo, exports, nrequire) => {
@@ -522,6 +526,11 @@
         for (const modIndex in jdhooks._modules) {
             let found = false
 
+            if (!jdhooks._modules[modIndex]) {
+                console.log("nothing at index", modIndex);
+                continue;
+            }
+
             const fntxt = jdhooks._modules[modIndex].toString()
             const fntxtPrepared = replaceAll(replaceAll(replaceAll(fntxt, "\\\\", "/"), '\r', ' '), '\n', ' ')
 
@@ -665,6 +674,11 @@
 
         for (const moduleIndex in modules_list) {
             let oldfn = modules_list[moduleIndex]
+            if (!oldfn) {
+                console.log("nothing at", moduleIndex);
+                continue;
+            }
+
             modules_list[moduleIndex] = (moduleInfo, exports, require) => {
                 oldfn(moduleInfo, exports, overrideRequire(require, moduleIndex))
             }
@@ -683,12 +697,17 @@
     }
 
     function jdhooks_module_step1(moduleInfo, exportsInfo, nrequire) {
+        console.log("Hello from jdhooks! moduleInfo:", moduleInfo, "exportsInfo:", exportsInfo, "nrequire:", nrequire);
 
+        /*
         let cl = arguments.callee
         while (cl.caller != null) cl = cl.caller
         let match = cl.toString().match(/\.\s*push\s*\(\s*\[\s*(\d+)/m)
         if (null == match) return
         let startupModule = Number(match[1])
+    */
+        // only numeric property of `i` (`nrequire`), as of now
+        let startupModule = nrequire.j;
 
         for (const propertyName in nrequire) {
             if (nrequire[propertyName] && nrequire[propertyName][jdhooks_module_index] && nrequire[propertyName][jdhooks_module_index].name) {
@@ -723,5 +742,10 @@
         }
     }
 
-    window.webpackJsonp.push([[0], { [jdhooks_module_index]: jdhooks_module_step1 }, [[jdhooks_module_index]]])
+    function requireHandle(req) {
+        console.log("hello from require handle", req);
+        console.log(req(jdhooks_module_index));
+    }
+
+    window.webpackChunkgapp_browser_react.push([[jdhooks_module_index], { [jdhooks_module_index]: jdhooks_module_step1 }, requireHandle])
 })()
commented

Too bad...
Can anyone tell me? What to do to manually change Speed dial tiles geometry?
Cannot look at standard squares ((
Can someone tell me which files and what to change?

Pleeeeeeeease fix

Pleeeeeeeease fix

Pleeeeeeeease help us find a fix

As you can see, i tried it a few times, but always failed. I don’t know what the maintainer has/hasn’t tried, but you can look at earlier history that these big breaks also lasted long and thus are far from trivial. If you have enough motivation to mess with it so long that it starts working again, you are very welcome to do so.

Update: i have managed to get a little bit further. Current patch is still not working, most of it is me trying if i can get past the current error & if it’ll get me any useful results. First steps made thanks to a random user found via GitHub search.

Giving up atm, will try to continue sometime later.

Webpack was updated in Vivaldi 4.3.
I believe 4 -> 5. Hooks need to be re-implemented.

Webpack was updated in Vivaldi 4.3.

Have you got an idea if there are some docs that would push this forward? If i remember correctly, i couldn’t find anything helpful last time i tried.