6

In a Firefox or Chrome(1) extension (using WebExtensions), is it possible to interrupt a request and return an alternate response instead, preventing the network request? What I'd like to do is store some html data (dynamically) using the storage API, and then return that html when the browser attempts to send off a specific request.

webRequest.onBeforeRequest seems to only support cancelling the request or returning a redirect. Is there a way to redirect to something inside the extension that returns the data? Or a way to craft and return a response directly?

(1) The Chrome docs for webRequest seem to reflect the same reality as the Firefox docs, and it seems that Firefox deliberately adopted much of WebExtensions to be consistent with Chrome.

freyley
  • 4,145
  • 3
  • 20
  • 25
  • It looks like redirecting to an extension page throws a browser security error. I'm not sure if it's possible to get around that, but it does seem that doing so will result in an ugly extension url, which isn't what I want at all. – freyley Nov 25 '17 at 06:02
  • The more I investigate, the more it seems that this just isn't one of the engineered use cases, and so is impossible with webRequest. – freyley Dec 04 '17 at 03:30

0 Answers0