Watch a URL in a tab and block it so it doesn't get called or alter it before it is sent

google-chrome-extension

Solution

You can use chrome.webRequest's onBeforeRequest method in blocking mode to cancel navigations.

Your manifest will need to declare permissions for "webRequest" and "webRequestBlocking".

Then add a background script that hooks onBeforeRequest and cancels the navigation for that URL only:

chrome.extension.onBeforeRequest.addListener(function() { return {cancel: true} },
  { urls: ["http://www.test.com/alter.php"] },
  ["blocking"]
);

Problem

I would like to block a URL to be called by giving the URL address, something like: This doesn't work but something like this. ``` $.watch("http://www.test.com/alter.php",function(){ //It was called here return false; //This in this scenario would block the URL to be called, it would cancel its request, it wouldn't even send the request, it would cancel before it access the web. }); ``` is it possible to block a URL so it doesn't get called or alter its request before its called in a tab via the Google Extensions? thanks in advance.

Original source