I am working on a chrome extension, that inserts a div into the body element of the dom. Right now I am creating an event handler that fires on load to create the element. This means of course that the page loads completely, and then my div is inserted, which means the user sees the page without the div until loading is complete, and then the div pops up. I would like the div to be there while the page is loading. Is there a way to hijack the body element before any other elements have been written? Or do I have to somehow hide the content until everything has loaded, which of course would mean that the user sees a blank screen for a while.
If at all possible, I would like to avoid jQuery.
I'm not 100% sure, but looking at the Chrome extension developer guide, it looks like if you are using a Content Script and specify the run_at
field in your extension's manifest as document_start
, then it should inject the files before the DOM is constructed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With