function onPrefChange(prefName) {
const simplePrefs = require("sdk/simple-prefs");
simplePrefs.on("", onPrefChange);
if (simplePrefs.dismixed == true && simplePrefs.disapp !== true)
{
dismixedtrue();
} else if (simplePrefs.dissecure == true && simplePrefs.disapp !== true) {
dissecure();
} else if (simplePrefs.disapp == true) {
disapp();
} else {
disnormal();
}
console.log("The preference " +
prefName +
" value has changed!");
}
Now I can disable part of the app without having to disable and then enabling (which is what the sime-pref is for) but have to disable and then enable the add-on to enable part of the app if that makes sense? Am I missing something in the code maybe to check for a false value in the conditions?
Also the value simplePrefs is coming back as undefined? Sorry guys still learning
And yes, every time a user changes one of your addon preferences, your onPrefChange function will be called and you may make your addon react to the preferences modification.
Thanks again guys for your help. Still having the same issue as my last post though with this new code:
const simplePrefs = require("sdk/simple-prefs");
simplePrefs.on("", onPrefChange);
onPrefChange();
function onPrefChange(prefName) {
//console.log("The preference " + prefName + " value has changed!");
tabs.on("ready", function(tab) {
var host = tabs.activeTab.url;
var worker = tabs.activeTab.attach({
contentScriptFile: self.data.url("docs.js")
});
worker.port.on("data", function(response) {
var mixedcont = response;
console.log(simplePrefs.prefs.dismixed + ' mixed content value for onchange in func')
if (mixedcont == "true" && host.indexOf("https:") == 0 && simplePrefs.prefs.dismixed !== true && simplePrefs.prefs.disapp !== true)
{
notificationmixed(host);
console.log(mixedcont + ' found show notify ')
} else if (host.indexOf("https:") == 0 && mixedcont !== "true" && simplePrefs.prefs.dissecure !== true && simplePrefs.prefs.disapp !== true) {
notification(host);
console.log(host + ' green light "')
} else {
console.log(host + ' could not determine ')
}
});
});
}
It must be something simple that I am doing wrong here?
It will disable part of the add-on without having to disable and then enabling the add-on, however will not enable part of the add-on without having to disable and then re-enabling the add-on?