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

497
Views
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
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!