I come from Chrome extensions, so I’m used to defining when a file should be injected by setting run_at, e.g., to document_start for injection before DOM construction. Is there an equivalent for Firefox addons?
I come from Chrome extensions, so I’m used to defining when a file should
Share
Yes, the equivalent would be the
content-document-global-creatednotification. An extension can add an observer for that notification and then do something with the window – like injecting a content script. See How to override JS function from a firefox extension? for one example of using this notification.If you use the Add-on SDK it will do this job for you. The
page-modpackage supports acontentScriptWhenparameter – you can use"start"as its value and the content script will be injected before any page scripts get a chance to run.