luetage / vivaldi_modding

Custom modifications for Vivaldi web browser.
MIT License
81 stars 6 forks source link

chrome.tabs doesn't work #9

Closed hgkjshegfskef closed 2 years ago

hgkjshegfskef commented 2 years ago

I have attempted to use https://github.com/luetage/vivaldi_modding/blob/master/internal-page-theme.js , which in turn requires https://forum.vivaldi.net/topic/57191/restore-methods-for-chrome-tabs . I didn't realize at first that the script from the repo doesn't reference a different script from the repo, so I didn't assume this would be a dependency, but it probably is.

After copying verbatim the internal-page-theme script into the console (which was my attempt to debug non-working code), I got "Cannot read property 'onUpdated'" on line chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab).

In browser.html the dependency is included before the internal-page-theme. The files are owned by root and are in the same folder as browser.html, so I assume the browser can read them just fine.

What I'm curious about is: how to make the internal-page-theme script work? Does it require additional dependencies? I don't see the code from the forum post in this repository, perhaps it is not a dependency after all? If not, how do I make it work? I am not a web developer.

hgkjshegfskef commented 2 years ago

Also, searching the forum post for "onUpdated" doesn't give any results. What provides this function?

luetage commented 2 years ago

I don’t know what console you are starting, it has to be the one for UI. chrome.tabs.onUpdated is a standard chrome api and works as expected. We have another issue here. Both insertCSS and executeScript had been deprecated, that’s why tam created the workaround. While there are new apis out, they don’t work on internal pages like the about page, because we do not have the permissions to do so. The workaround still used to trigger on internal pages last I checked, but now it seems to fail. I’m afraid there’s nothing I can do about that :/ But thank you for notifiying me, I will mark this as archived and post about it in the topic at some point in the not so far future. Might try a few other things first, but can’t say whether anything could help changing the page now. In truth Vivaldi team should have themed this years ago…

luetage commented 2 years ago

I take it all back. I tricked myself because I forgot how the mod functions… The modification still works out fine, but you have to open vivaldi://about and about:blank in a new tab to trigger. This has always been a requirement. What this means is you can’t input the addresses in the address field and hit enter to open in existing tab, this will fail.

hgkjshegfskef commented 2 years ago

Thanks for the response.

I don’t know what console you are starting, it has to be the one for UI

I went to about:blank, Inspect element -> Console. Then I just pasted the internal-page-theme script there and pressed Enter, as an attempt to give further pointers why it doesn't work in general when referenced from browser.html.

you have to open vivaldi://about and about:blank in a new tab to trigger

How can I reproduce this? So if I do Ctrl+T and then enter about:blank in the address, that will not trigger the repaint, correct? How to reliably test if the script works then? Since you are saying that it still works fine, clearly I am doing something wrong in the process.

The original issue I am trying to overcome is that the Dark Reader addon, which is supposed to repaint web pages into dark colors, is flashing with white color for a few milliseconds before repainting, and the official resolution for chromium users is to change the color of about:blank page. Installing chromium addons that do this doesn't work, so I thought, there must be a way for vivaldi to do the same.

luetage commented 2 years ago

You can test by opening from a bookmark or from menu, or from quick commands or from the address field, but you have to make sure it opens in a new tab. From menu (help-about) and from bookmarks that’s likely your default. From the address field and from quick commands you have to use a modifier, depending on your settings, to open in a new tab. This could be alt or shift enter (take a look at your settings). What you cannot do is run the script in the console for the webpage. How this script works is that it triggers in the user interface and injects css code on the webpage. Anyway, your use case of wanting to control the color of the blank page on load of a new page is not covered by this mod. Please take a look at this post by nomadic, which could help you ☛ https://forum.vivaldi.net/topic/29218/customize-a-dark-color-for-the-new-tab-blank-page/11.

hgkjshegfskef commented 2 years ago

Thank you for the information. Indeed, with just the CSS from that post I was able to paint the blank page, but the flashing remained. That concludes my attempt of making vivaldi usable.

luetage commented 2 years ago

Eh, it’s more complicated than you might think. I don’t see the blank page helping at all, Vivaldi already shows the background color before loading a link. The very shory white flash you can discern when loading a heavy page is actually Chromium preloading the page and using the standard page background. It’s not the user interface you see.