I'm not sure about FF extensions, but there is no need for business in a βnormalβ JS country createTextNode. Outside of FF extensions, you can use Node.textContent- although perhaps this is different from types XPCNativeWrapper.
script.textContent = 'var foo = 1; alert(foo);'
I think the main problem, however, is that you also have a variable and parameter named script. Try the following:
function executeJS(document, scriptContent) {
var script = document.createElement('script');
script.appendChild(document.createTextNode(scriptContent));
document.head.appendChild(script);
}
type , BTW.
, , , :
const XUL = Namespace("xul", "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
function injectScript(name) {
let file = Components.stack.filename;
let directory = file.replace(/.* -> |[^\/]+$/g, "");
let script = document.createElementNS(XUL, "script");
script.setAttribute("type", "application/javascript;version=1.8");
script.setAttribute("src", directory + name);
document.documentElement.appendChild(script);
}
injectScript("script.js");