start containerTabsOpened counter

This commit is contained in:
groovecoder 2017-10-25 12:36:16 -05:00 committed by Jonathan Kingston
parent a7be3c9935
commit 4e6eee220c

View file

@ -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);