Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

289
Vistas
Javascript YouTube adblocker not entirely working

First time user here!

So, somewhat recently I got a YouTube adblocker for my computer off of GitHub. It is a simple Chrome plug-in written in JavaScript and it used to work great, but then it partially stopped working. What I mean by that is, when the adblocker is enabled it only blocks advertisements that have valid urls (such as https://www.example.com/). All other urls (such as example.com) won't get blocked.

I would've tried contacting the programmer of the plug-in, but I can't find his or her GitHub page anymore. I am a complete newcomer to JavaScript programming, however I do know what the problem is, just not how to go about rewriting the code.

There is a portion of background.js that contains a function with the parameter (argument?) urls:, which contains an array that consists of "all_urls". To my knowledge, "all_urls" will match any url that begins with schemes such as https:// and http://.

Here is the code in question.

background.js

var numBlocked = 0;

chrome.webRequest.onBeforeRequest.addListener(
  function(details) {
    // It is easier to ignore requests instead of modifying them - everything seems to work fine
    // Note that get_midroll_info response contains playerAds describing all of the ads in the video
    const ignore =
      details.url.indexOf("/get_video_info") != -1 ||
      details.url.indexOf("/api/stats/ads") != -1 ||
      details.url.indexOf("/pagead/conversion") != -1 ||
      details.url.indexOf("ad_companion") != -1 ||
      details.url.indexOf("get_midroll_info") != -1;
    if (ignore) {
      numBlocked++; // keep track of blocked requests
      chrome.browserAction.setBadgeBackgroundColor({color: "#FF0000"});
      chrome.browserAction.setBadgeText({text: (numBlocked > 99) ? "99+" : `${numBlocked}`});
    }
    return {cancel: ignore};
  },
  {urls: ["<all_urls>"]},
  ["blocking"]
);

Thanks, and sorry in advance if I forgot something.

about 4 years ago · Juan Pablo Isaza
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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda