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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -