I'm working on a Chrome extension that would prevent me from visiting time-wasting websites.
Whenever I visit such website I would like to append an element to the body
that will stay position:fixed
on top of the page.
What I'm struggling with is that often styles from the original page are leaking towards my appended markup.
1.
One solution could be using iframe but we have 2019 and I've been living under a rock for a year or two and as I'm returning to web development everything is React, virtual DOM, CSS4 who knows.
Here I've found a solution using iframe: https://stackoverflow.com/a/4199540
function writeToFrame() {
var doc = document.getElementById('testing').contentWindow.document;
doc.open();
doc.write('<html><head><title></title><style>body{ background: blue }</style></head><body>Hello world.</body></html>');
doc.close();
}
It works, the background: blue
is not leaking.
I'm worried that using iframes can bring some difficulties further down the line - namely communicating with the extension scripts.
2.
Option two would be using reset.css
but it doesn't work:
Do you have maybe better ideas, maybe there is something obvious that I'm missing?