firefox - Referenceerror: data is undefined -
firefox - Referenceerror: data is undefined -
i'm trying create firefox addon uses contentscript inject .js file in page. of works maintain getting weird error.
main.js
var pagemod = require("sdk/page-mod"); var self = require("sdk/self"); var info = require('sdk/self').data; pagemod.pagemod({ include: ["http://www.google.com", "https://ww.google.com" ], contentscriptfile: data.url("contentscript.js") });
contentscript.js
var s = document.createelement('script'); s.src = data.url('jquery.js'); s.onload = function() { this.parentnode.removechild(this); }; (document.head||document.documentelement).appendchild(s); settimeout(function(){ var d = document.createelement('script'); d.src = data.url('script.js'); d.onload = function() { this.parentnode.removechild(this); }; (document.head||document.documentelement).appendchild(d); },100)
the content of script.js unrelevant, because doesn't executed. error in contentscript:2:1 referenceerror: info undefined.
keep in mind needs done way, script needs able modify dom.
you can't access data.url content script, can main.js. pass file path , name of script main in contentscriptoptions.
also i'm not sure you're intending utilize if include: ["https://www.google.com"]
page-mod work on https://www.google.com. include: "[*]"
allows websites etc.
firefox sdk
Comments
Post a Comment