Skip to content

Instantly share code, notes, and snippets.

View pwall2222's full-sized avatar

PWall pwall2222

  • 18:49 (UTC +01:00)
View GitHub Profile
@pwall2222
pwall2222 / sust.md
Last active March 19, 2021 23:26
How to replace a whole page with content script

Why

I was creating a page to substitude another in a project and I couldn't quite find anything to do this. So when i came out with the solution I decided I had to post it online.

How

Very easy stopping the window load, and then appending an iframe wich covers the whole page.

Code example

window.stop();
document.documentElement.innerHTML = "<head></head><body></body>";
const doc = await fetch("").then(response => response.text());
const item = document.createElement("iframe");