6

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.

Osa
  • 1,922
  • 7
  • 30
  • 51

1 Answers1

5

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"]);
Osa
  • 1,922
  • 7
  • 30
  • 51