'Clear whole DOM before page load from browser extension
I am trying to write a browser extension which improves a website with very bad performance and countless unnecessary and duplicate network requests by replacing the content with a simpler version and doing the requests myself.
To do this I would like to replace/clear the whole DOM before the content is loaded and network requests are sent. So far I have tried multiple ways, but all of them only work when the content-script is set to "run_at": "document_end". This way I can do something like
document.head.innerHTML = "";
document.body.innerHTML = "";
Because it only runs at document_end, it takes some seconds before the script is run and there are still some network requests going out.
Is there any way to completely clear the DOM when loading a website, so that it my script can be run immediatly? When I try my scripts with "run_at": "document_start they don't work at all and the original page is loaded.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
