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

The 8472 8472-mozaddons at infinite-source.de
Tue Aug 15 13:07:03 UTC 2017


MutationObserver should be the right approach. Maybe post your attempt?

On 15.08.2017 14:52, Manuel Reimer wrote:
> Hello,
> 
> 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
> 
> Manuel
> _______________________________________________
> Dev-addons mailing list
> Dev-addons at mozilla.org
> https://mail.mozilla.org/listinfo/dev-addons
> 



More information about the Dev-addons mailing list