• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

114
Vistas
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 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

AdBlock is a browser extension that uses WebExtensions API

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

about 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda