From 9a48cb5107a91c7b1da98cb2acb0ee61ec30ba3b Mon Sep 17 00:00:00 2001 From: typeling1578 Date: Thu, 23 Mar 2023 14:43:35 +0900 Subject: [PATCH] Fixed a problem that caused multiple containers to be created. --- background.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/background.js b/background.js index 33edb45..07630fc 100644 --- a/background.js +++ b/background.js @@ -35,6 +35,11 @@ async function updateContainerState() { try { await browser.contextualIdentities.remove(prefs.contextId); } catch (e) { console.error(e) } + if (privatedContainerId) { + try { + await browser.contextualIdentities.remove(privatedContainerId); + } catch (e) { console.error(e) } + } } try { await browser.contextualIdentities.get(prefs.contextId); @@ -127,10 +132,11 @@ async function deleteHistory(details) { browser.tabs.onCreated.addListener(async (tab) => { if (privatedContainerId === tab.cookieStoreId) { privatedTabs.push(tab); + await updateContainerState(); } - await updateContainerState(); }); browser.tabs.onRemoved.addListener(async (tabId) => { + if (privatedTabs.filter(privatedTab => privatedTab.id === tabId).length === 0) return; privatedTabs = privatedTabs.filter(privatedTab => privatedTab.id !== tabId); if (privatedTabs.length === 0 && started) { await updateContainerState();