Problem Definition
I'm trying to develop a Firefox Add-on using Firefox SDK. I've problem with emitting add-on preference to the external script (ins.js) in ./data folder. I've read lots of questions about these problems but I can't implement my code how to change this. I know that my problem will be solve with worker and port objects but I need a little bit help.
Note: I don't make a bookmark add-on and I know other API's about bookmarking operations. Please do not advice about bookmark API.
[main.js]
function handleClick(state) {
var accInf = require("sdk/simple-prefs").prefs.bookmarklet;
accInf = accInf.substring(208, 220);
console.log(accInf)
require("sdk/tabs").activeTab.attach({
contentScriptFile: [self.data.url("ins.js")]
});
}
accInf is variable that I want to emit to ins.js and accesing it as a variable or assigning another variable.
[ins.js]
function makechange() {
//function body
// that recives a variable defined in pref by user and accessing (or assigning other variable) this variable to make some jobs.
}
[package.json]
"preferences": [{
"name": "bookmarklet",
"title": "Some title is here!",
"description": "....",
"type": "string",
"value": "please enter value"
}]
What I Want to Do
I'm trying to emit a variable (accInf) which defined by user as a pref (bookmarklet) to the ins.js and accessing in ins.js scope. How can I change the code in ins.js and index.js to solving this problem?
Related Questions Which I Found Before I Ask This Question
Firefox SDK access preferences from content script
Use of simple-prefs (SDK API) with external script and postMessage