I'm trying to execute custom JS code from a Firefox extension using:
function executeJS(document, script) {
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.appendChild(document.createTextNode(script));
document.getElementsByTagName('head')[0].appendChild(script);
}
The method call looks like:
executeJS(content.document, "$('#" + this.id + "').jixedbar({showOnTop:true});");
And this is the result that I get:
<script type="text/javascript">
[object XPCNativeWrapper [object HTMLScriptElement]]
</script>
What's wrong with my code? What's the proper way of execution arbitrary JS script from Firefox extension?