changeset 5:9d699dc7823d

Ensure browser action stays disabled on incognito tabs Re-enabling browser action on every tab update is intended though undocumented behavior, thus add an event handler to keep it disabled.
author Guido Berhoerster <guido+set-aside@berhoerster.name>
date Thu, 13 Dec 2018 08:34:13 +0100
parents 8f8a0b35515b
children 152e886b6e28
files background.js
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/background.js	Thu Nov 22 15:52:42 2018 +0100
+++ b/background.js	Thu Dec 13 08:34:13 2018 +0100
@@ -523,14 +523,19 @@
     title: browser.i18n.getMessage('showTabsMenuItem')
 });
 
-// disable the browser action for new incognito tabs
+// disable the browser action for incognito tabs
 browser.tabs.onCreated.addListener(tab => {
     if (tab.incognito) {
-        // this does not work, it seems that the browser action is re-enabled
-        // on every update
+        console.log('created, disabling');
         browser.browserAction.disable(tab.id);
     }
 });
+browser.tabs.onUpdated.addListener((tabId, details, tab) => {
+    if (tab.incognito) {
+        console.log('updated, disabling');
+        browser.browserAction.disable(tabId);
+    }
+});
 
 (async () => {
     // disable the browser action for existing incognito tabs