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

503
Visualizações
webRequest is not working with https://www.youtube.com/?

I have an array of URLs in local storage, and I am trying to block those. All URLs except https://www.youtube.com/ are blocked successfully. Even when refreshing the page in case of https://www.youtube.com/, it is logging to the console "entered" that is inside the if statement of blockListener. then even after this is not blocking the request.

Why is happening so?

code is here.......


    function blockListener(details) {  
            var sites = JSON.parse(localStorage.getItem(sitesToBeBlockedKey));//got sites array
            console.log(sites.includes(details.url));
            if(sites.includes(details.url)){
                console.log('entered');
                return {
                    cancel: true
                };
            }else{
                return {
                    cancel: false
                };
            }
    }

    
    function checkBlockRequest(){
                console.log('blocking start');
                chrome.webRequest.onBeforeRequest.addListener( blockListener, { urls: ["<all_urls>"], types: [ 'main_frame' ] }, ['blocking'] );
        });
    }

    checkBlockRequest();//called
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