0

Basicly what I want is to create extension that will override content of a certain URL:

http://overrideme

As you can imagine this page dose not exist in this world. So the effect i want to create is this. If user have my extenshion installed then if he went to http://overrideme he will see content of a page that i will provide

PS: i tryed to use "content" scripts, but they are no good, since they work with web pages that do exist.

obenjiro
  • 3,665
  • 7
  • 44
  • 82
  • I think the closest thing would be using [webRequest API](https://developer.chrome.com/extensions/webRequest) to substitute the url, but I don't know if it can reroute to chrome-extension:// protocol. And anyway the address displayed in the omnibox will be of the actual page, not the dummy http url. – wOxxOm Aug 20 '15 at 15:01
  • webRequest API also won't do since it' can't replace body of a page :( http://stackoverflow.com/questions/18310484/chrome-extension-modifying-http-response – obenjiro Aug 20 '15 at 17:43
  • 1
    The idea of webRequest is to replace the URL not the page body, so that the browser is redirected to your extension's page. – wOxxOm Aug 20 '15 at 17:45

1 Answers1

0

While webRequest API cannot allow you to show a page with http://overrideme in the address bar, it can allow you to show any other page instead whenever http://overrideme is requested (including resources, not just page navigation)

I.e. it can redirect http://overrideme to chrome-extension://yourextensionid/override.html

You need to respond to an onBeforeSendHeaders event with {redirectUrl: url} blocking response.

Xan
  • 74,770
  • 16
  • 179
  • 206