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.