Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
How do I block a certain script from loading?

How would I block a URL from loading like AdBlock does?

For example https://example.com/hi.js

I've tried this with XMLHttpRequest, but didn't succeed. I would very like to do this in JavaScript. Not DevTools or some other stuff.

XMLHttpRequest.prototype.realOpen = XMLHttpRequest.prototype.open;

// Create a new function to filter out certain urls
var myOpen = function(method, url, async, user, password) {
  // Redirects the /pause to /play
  // (which will do nothing since Spotify is already playing)
  if (url.match(/doubleclick/gi)) {
    alert("a")
    url = "about:blank";
  }
  this.realOpen(method, url, async, user, password);
}

// Overwrite the original open with our modded version
XMLHttpRequest.prototype.open = myOpen;

Please DO NOT answer with "it's not possible" or "use DevTools instead" when clearly AdBlock is capable of it.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

AdBlock is a browser extension that uses WebExtensions API

See this article for more info on how to do what you want

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!