9951 explained code solutions for 126 technologies


chrome-extensionBlock specific requests by URL


chrome.webRequest.onBeforeRequest.addListener(
  function() { return {cancel: true}; },
  { urls: ["https://example.org/page1"] },
  ["blocking"]
);ctrl + c
onBeforeRequest.addListener

listen to request init event

return {cancel: true}

cancel request that matched pattern

urls

patterns to match that will trigger the listener

"blocking"

means our listener will work in synchronous mode (we need that for blocking specific requests)