I'm looking to make a web extension for Firefox that stores HTML pages and other resources in local storage and serves them for offline viewing. To do that, I need to intercept requests that the browser makes for the pages and the content in them.
Problem is, I can't figure out how to do that. I've tried several approaches:
- The webRequest API doesn't allow fulfilling a request entirely - it can only block or redirect a request, or edit the response after it's been done.
- Service Workers can listen to the
fetchevent, which can do what I want, but callingnavigator.serviceWorker.registerin an addon page (themoz-extension://<id>domain) results in an error:DOMException: The operation is insecure.Relevant Firefox bug - I could possibly set up the service worker on a self hosted domain with a content script, but then it won't be completely offline.
Is there an API that I missed that can intercept requests from inside a web extension?