addons/firefox-addons/set-aside

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 Dec 13 08:34:13 2018 +0100 (17 months ago)
parents 8f8a0b35515b
children 152e886b6e28
files background.js
line diff
     1.1 --- a/background.js	Thu Nov 22 15:52:42 2018 +0100
     1.2 +++ b/background.js	Thu Dec 13 08:34:13 2018 +0100
     1.3 @@ -523,14 +523,19 @@
     1.4      title: browser.i18n.getMessage('showTabsMenuItem')
     1.5  });
     1.6  
     1.7 -// disable the browser action for new incognito tabs
     1.8 +// disable the browser action for incognito tabs
     1.9  browser.tabs.onCreated.addListener(tab => {
    1.10      if (tab.incognito) {
    1.11 -        // this does not work, it seems that the browser action is re-enabled
    1.12 -        // on every update
    1.13 +        console.log('created, disabling');
    1.14          browser.browserAction.disable(tab.id);
    1.15      }
    1.16  });
    1.17 +browser.tabs.onUpdated.addListener((tabId, details, tab) => {
    1.18 +    if (tab.incognito) {
    1.19 +        console.log('updated, disabling');
    1.20 +        browser.browserAction.disable(tabId);
    1.21 +    }
    1.22 +});
    1.23  
    1.24  (async () => {
    1.25      // disable the browser action for existing incognito tabs