Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

293
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda