# HG changeset patch # User Guido Berhoerster # Date 1544686453 -3600 # Node ID 9d699dc7823dfca73fb3e76ed4beec55cd8b43eb # Parent 8f8a0b35515b171ca8db0fc4dc00d3aba1cbda51 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. diff -r 8f8a0b35515b -r 9d699dc7823d background.js --- 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