I'm working on a chrome extension that will add some features to an existing page. But for that, I need to add a script to a page as soon as possible!! (No, I cannot simply run a content script that starts before everything, I need this particular script to be inserted into the DOM)
(Why? Because that page loads everythin using ajax calls, and I need to be able to perform some operations before those calls)
So I intent to add the script the sooner I can immediately after the head of the document appears.
I'm looking at MutationsObserver
, and it seems it could do that job. But how can I check if a certain Node
from the addedNodes
collection is the head???