How do inject a script into a website *before* the first script on this website is able to run?

Manuel Reimer manuel.reimer at
Tue Aug 15 12:52:37 UTC 2017


before Firefox 55 I was able to do the following:

Register my content script to run at "document_start".
Then I was able to access "document.head" from there and inject my 
<script> as the very first script to load.

I need my script to run right in website context as my script is meant 
to do heavy exchange with page javascript which is difficult or 
impossible with a content script directly.

Since Firefox 55 it seems to be impossible to do so. "document_start" 
seems to fire before "<head>" even exists.

I tried to fix this with the "DOMContentLoaded" but this now is too 
late. Scripts embedded into <body> already ran at this point...

Then I tried a "MutationObserver" to maybe wait for the point when 
<head> is inserted, but for me the MutationObserver is never fired.

Can someone please point me into the right direction?

Thanks in advance


More information about the Dev-addons mailing list