diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 19:47:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 19:47:39 +0000 |
commit | 8d13bdc6cac0e20c43c6f909fc0208774b9c5c84 (patch) | |
tree | 5fd46925c6b4a881c9208772ed8e5cc0588bc164 /src/js/incognito.js | |
parent | Initial commit. (diff) | |
download | privacybadger-upstream.tar.xz privacybadger-upstream.zip |
Adding upstream version 2020.10.7.upstream/2020.10.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/js/incognito.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/js/incognito.js b/src/js/incognito.js new file mode 100644 index 0000000..56d2d93 --- /dev/null +++ b/src/js/incognito.js @@ -0,0 +1,49 @@ +/* globals badger:false */ + +require.scopes.incognito = (function() { +var tabs = {}; + +// Get all existing tabs +chrome.tabs.query({}, function(results) { + results.forEach(function(tab) { + tabs[tab.id] = tab.incognito; + }); +}); + +// Create tab event listeners +function onUpdatedListener(tabId, changeInfo, tab) { + tabs[tab.id] = tab.incognito; +} + +function onRemovedListener(tabId) { + delete tabs[tabId]; +} + +// Subscribe to tab events +function startListeners() { + chrome.tabs.onUpdated.addListener(onUpdatedListener); + chrome.tabs.onRemoved.addListener(onRemovedListener); +} + +function learningEnabled(tab_id) { + if (badger.getSettings().getItem("learnInIncognito")) { + // treat all pages as if they're not incognito + return true; + } + // if we don't have incognito data for whatever reason, + // default to disabled + if (!tabs.hasOwnProperty(tab_id)) { + return false; + } + // else, do not learn in incognito tabs + return !tabs[tab_id]; +} + +/************************************** exports */ +let exports = { + learningEnabled, + startListeners, +}; +return exports; +/************************************** exports */ +})(); |