Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get scripts.js working #720

Open
ephemer4l opened this issue Sep 9, 2022 · 3 comments
Open

Can't get scripts.js working #720

ephemer4l opened this issue Sep 9, 2022 · 3 comments

Comments

@ephemer4l
Copy link

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
Copy link
Owner

@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
Copy link
Author

ephemer4l commented Jan 5, 2023 via email

@fanglingsu
Copy link
Owner

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants