diff --git a/webextension/js/background/messageHandler.js b/webextension/js/background/messageHandler.js index b49ecb5..d791d70 100644 --- a/webextension/js/background/messageHandler.js +++ b/webextension/js/background/messageHandler.js @@ -112,6 +112,14 @@ const messageHandler = { // lets remember the last tab created so we can close it if it looks like a redirect this.lastCreatedTab = tab; if (tab.cookieStoreId) { + // Don't count firefox-default, firefox-private, nor our own confirm page loads + if (tab.cookieStoreId !== "firefox-default" && + tab.cookieStoreId !== "firefox-private" && + tab.url.indexOf("confirm-page.html") === -1) { + // increment the counter of container tabs opened + this.incrementCountOfContainerTabsOpened(); + } + this.unhideContainer(tab.cookieStoreId); } setTimeout(() => { @@ -120,6 +128,18 @@ const messageHandler = { }); }, + async incrementCountOfContainerTabsOpened() { + const key = "containerTabsOpened"; + const count = await browser.storage.local.get(key); + let countOfContainerTabsOpened = count[key]; + if (countOfContainerTabsOpened === null) { + countOfContainerTabsOpened = 1; + } else { + countOfContainerTabsOpened += 1; + } + browser.storage.local.set({[key]: countOfContainerTabsOpened}); + }, + async unhideContainer(cookieStoreId) { if (!this.unhideQueue.includes(cookieStoreId)) { this.unhideQueue.push(cookieStoreId);