I'm working on an extension for Firefox v.42.0. In it, I have the Addon and on detecting a certain page, the addon injects some code into the page DOM. I am trying to use var simpleStorage = require("sdk/simple-storage");
to include simpleStorage. I save the variable as follows
simpleStorage.storage.token = $value;
and then trying to access the simpleStorage in the injected code as follows
if (private_self_options === undefined)
var private_self_options = self.options;
var token = private_self_options.simpleStorage.storage.token;
However, this always returns an empty string. Could someone please point out my mistake?
You can get the contents of simpleStorage.storage.token
into token
with simply
var token = simpleStorage.storage.token
self.options
is for use on the content script side, as shown here . Using it to pass information from simple-storage might be done thus:
tab.attach({
contentScriptFile: "./content-script.js",
contentScriptOptions: {
token: simpleStorage.storage.token
}
});
In that case, your assignment statement in ./content-script.js
would be
var token = self.options.token;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.