I'm trying to create a feature for an extension that has a checkbox, if the checkbox is checked the extension will stop collecting data, and if the checkbox is unchecked the extension will collect data. The feature works when the extension popup is open, and when I'm using the devtool. When the popup is closed and the checkbox is unchecked, it doesn't collect any data
I store the checkbox status in localstorage:
chrome.storage.local.set(
{
Privacy: document.getElementById("Privacy").checked,
}
I call function to collect data if the checkbox is uncheck:
chrome.tabs.onActivated.addListener(function (activeInfo) {
chrome.storage.local.get(["Privacy"], function (result) {
if (result.Privacy != true || result.Privacy == null) {
getTabInfo((activeTabId = activeInfo.tabId));
console.log("inside privacy");
} else {
console.log("inside tabs.onActivated:");
console.log("this is result.Privacy: ");
console.log(result.Privacy);
}
});
})
I have tried : result.Privacy == false
, that doesn't work either. I know its not collecting data because I don't see any data stored in the database.
This is a sample of my manifest.json
:
"background":
{
"scripts": ["js/background.js", "js/firebase.js"],
"persistent": true
},
"permissions": [
"tabs",
"activeTab",
"scripting",
"*://*/*",
"storage",
"identity"
],