Reputation: 355
I've got a content script that should be added on page if I select this preference in addon settings. I can add bool setting, but I absolutely can't understand how to operate with it on main.js file. The setting is
"preferences": [{
"description": "",
"name": "tagHide",
"type": "bool",
"value": false,
"title": "Hide something"}]
And in the main file I added this
var data = require("sdk/self").data;
var pageMod = require("sdk/page-mod");
var prefs = require("sdk/simple-prefs").prefs;
function onPrefChange(prefName) {
if (prefs.tagHide) {
console.log(prefs.tagHide);
pageMod.PageMod({
include: "*.corbina.net",
contentScriptFile: data.url("cutter.js")
});
};
}
This code logs "true" of "false" in the console, but pagemod seems not working. Any errors I've got here?
Upvotes: 0
Views: 107
Reputation: 5830
There are a few issues with this code as-is:
require("sdk/simple-prefs").on("", onPrefChange);
, see the docsattachTo
option.Upvotes: 2