3

I want to create my own Userscript for Tampermonkey for a specific site I often use and I want to add some features and I want to improve some things.

Since it loads some .js files, that do some stuff I don't want to happen, I want to replace these .js files and reimplement the things I need within my Userscript.

I don't want to replace functions, I want to completely remove specific .js files from the DOM before they get executed and reimplement them in my Userscript to my preferences.

I tried to use this method: http://userscripts-mirror.org/scripts/show/125936 But it didn't work at all, no errormessages or similar, it just doesn't execute the Eventlistener, I use Chrome, could it be that this has to be implemented in another way for Chrome?

1 Answer 1

4

beforescriptexecute event referenced in your question isn't implemented in Chrome and probably never will be.

There is no way for a userscript in Chrome to prevent some webpage script that is referenced in the page html <script> tag from loading.

The only solution is to use an extension that blocks urls via webRequest API.

  • If you don't mind making your userscript dependent on another extension then use HTTP Request Blocker, Requestly and others.
  • For a complete solution without dependencies you'll have to make your own extension, not a userscript.
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer, since I already use AdBlock I simply created a filter to block the JS, I just hoped I could do this independent from other extensions, but it's not that much of a big deal, I'll create a specific Filterlist for Adblock on my Github which I can include on all of my machines where I intend to use this script, so it's not that much of a hassle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.