How can I modify a web page before it’s displayed with WebExtensions? The canonical ways to modify a page are documented here:
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Modify_a_web_page
However, doing the way the page above suggested modifies the page after it has been displayed.
For instance, if I want to hide a certain element in a page:
- I write the extension as above, then I click on a link and it loads and displays the page, but the element shows up visible for a very brief moment before it is finally hidden.
What I’m looking for:
- A way to intercept the response from the server and modify the DOM before we display the page, so that the element is never visible to the user, not even for a millisecond.
I know this might increase the page load time, but my concern is to never have a certain element visible, even if the compromise is to have it take a few more seconds before the page is displayed. How can I achieve that using WebExtensions?