Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace url with a different one before load

In google chrome extensions, How can i replace a request URL with a different one before it loads?

I took a look at chrome.webRequest and i think one of them is what i am looking for, I don't know which one exactly.
I believe google limits some kind of stuff, not sure if this is one of them.

like image 871
Osa Avatar asked Oct 05 '22 15:10

Osa


1 Answers

I found an example that does this :

chrome.webRequest.onBeforeRequest.addListener(
  function(info) {
    // Redirect the original request to a given URL.
    var url = "http://site.com/image.png";
    return {redirectUrl: url};
  },
  // filters
  {
    urls: [
      "http://original.com/*"
    ],
    types: ["image"]
  },
  // extraInfoSpec
  ["blocking"]);
like image 119
Osa Avatar answered Oct 10 '22 02:10

Osa