I\'m writing a Firefox extension (add-on) to allow users to annotate any page with text and/or drawings and then save an image of the page including the annotations. Use cas
So this is how I solved my problem by setting the onload attribute to call the init function in the script that's being appended to the page.
var myScript = top.window.content.document.createElement('script');
myScript.type = 'text/javascript';
myScript.setAttribute('src','chrome://path/to/script.js');
myScript.setAttribute('onload', 'firefoxInit()');
top.window.content.document.getElementsByTagName('head')[0].appendChild(myScript);