fanglingsu / vimb

Vimb - the vim like browser is a webkit based web browser that behaves like the vimperator plugin for the firefox and usage paradigms from the great editor vim. The goal of vimb is to build a completely keyboard-driven, efficient and pleasurable browsing-experience.
https://fanglingsu.github.io/vimb/
GNU General Public License v3.0
1.35k stars 100 forks source link

Can't get scripts.js working #720

Open ephemer4l opened 2 years ago

ephemer4l commented 2 years ago

Version: 3.6.0 WebKit compile: 2.36.7 WebKit run: 2.36.7 GTK compile: 3.24.34 GTK run: 3.24.34 libsoup compile: 2.74.2 libsoup run: 2.74.2 Extension dir: /usr/lib/vimb

My scripts.js:

function userscript_twitter()
{
    if (window.location.href.search('://twitter.com/') != -1) {
        window.location.href = window.location.href.replace('://twitter.com/', '://mobile.twitter.com/');
    }

    /* other code here unrelated to URL rewriting */
}

and in my config I have:

au LoadFinished *://twitter.com/* eval! userscript_twitter();

I just can't understand why this doesn't work. I've tried to also rename scripts.js to script.js and tried to run the function with eval from within vimb and none of these work. What can I do to get scripts working?

fanglingsu commented 1 year ago

@ephemer4l This looks right .config/vimb/scripts.js should be the right path. To near the issue down you could test following.

  1. au LoadFinished *://twitter.com/* eval! alert(1); - if that works go to step 2.
  2. Open twitter and run the script by yourself with :eval! userscript_twitter(); if this does not work it might be an issue with the scripts.js file.
ephemer4l commented 1 year ago

What output should I be getting from the first step? Because I'm not getting any :/

On 23/01/05 03:55AM, Daniel Carl wrote:

@ephemer4l This looks right .config/vimb/scripts.js should be the right path. To near the issue down you could test following.

  1. au LoadFinished *://twitter.com/* eval! alert(1); - if that works go to step 2.
  2. Open twitter and run the script by yourself with :eval! userscript_twitter(); if this does not work it might be an issue with the scripts.js file.

-- Reply to this email directly or view it on GitHub: https://github.com/fanglingsu/vimb/issues/720#issuecomment-1372123687 You are receiving this because you were mentioned.

Message ID: @.***>

fanglingsu commented 1 year ago

@ephemer4l You should see a modal alert box showing "1". Could you enable scripts by :set scripts=on and check again. This should not be required, but we schould check this too. I think that the LoadFinished is not fired because the page is not loaded complete for some reason. You might try to use an other event which is fired earlier.