From 1f7be5c9c3294e9b3966ee44461d8dba100d4f50 Mon Sep 17 00:00:00 2001 From: idk Date: Tue, 17 Mar 2020 04:42:24 -0400 Subject: [PATCH] one apptab per app --- scrub.js | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/scrub.js b/scrub.js index 923b375..4108e7f 100644 --- a/scrub.js +++ b/scrub.js @@ -183,18 +183,26 @@ var contextSetup = function(requestDetails) { if (tabId.cookieStoreId != context[0].cookieStoreId) { function Create() { function onCreated(tab) { - function closeOldTab() { + function closeOldTab(tabs) { if (tabId.id != tab.id) { console.log("(isolate) Closing un-isolated tab", tabId.id); console.log("in favor of", tab.id); console.log("with context", tab.cookieStoreId); browser.tabs.remove(tabId.id); } + for (index = 0; index < tabs.length; index++) { + if (index != tabs.length - 1) + browser.tabs.remove(tabs[index].id); + } } - closeOldTab(tab); + var pins = browser.tabs.query({ + cookieStoreId: context[0].cookieStoreId + }); + pins.then(closeOldTab, onError); } var created = browser.tabs.create({ active: true, + pinned: true, cookieStoreId: context[0].cookieStoreId, url: requestDetails.url }); @@ -216,18 +224,26 @@ var contextSetup = function(requestDetails) { if (tabId.cookieStoreId != context[0].cookieStoreId) { function Create() { function onCreated(tab) { - function closeOldTab() { + function closeOldTab(tabs) { if (tabId.id != tab.id) { console.log("(isolate) Closing un-isolated tab", tabId.id); console.log("in favor of", tab.id); console.log("with context", tab.cookieStoreId); browser.tabs.remove(tabId.id); } + for (index = 0; index < tabs.length; index++) { + if (index != tabs.length - 1) + browser.tabs.remove(tabs[index].id); + } } - closeOldTab(tab); + var pins = browser.tabs.query({ + cookieStoreId: context[0].cookieStoreId + }); + pins.then(closeOldTab, onError); } var created = browser.tabs.create({ active: true, + pinned: true, cookieStoreId: context[0].cookieStoreId, url: requestDetails.url }); @@ -249,18 +265,26 @@ var contextSetup = function(requestDetails) { if (tabId.cookieStoreId != context[0].cookieStoreId) { function Create() { function onCreated(tab) { - function closeOldTab() { + function closeOldTab(tabs) { if (tabId.id != tab.id) { console.log("(isolate) Closing un-isolated tab", tabId.id); console.log("in favor of", tab.id); console.log("with context", tab.cookieStoreId); browser.tabs.remove(tabId.id); } + for (index = 0; index < tabs.length; index++) { + if (index != tabs.length - 1) + browser.tabs.remove(tabs[index].id); + } } - closeOldTab(tab); + var pins = browser.tabs.query({ + cookieStoreId: context[0].cookieStoreId + }); + pins.then(closeOldTab, onError); } var created = browser.tabs.create({ active: true, + pinned: true, cookieStoreId: context[0].cookieStoreId, url: requestDetails.url }); @@ -282,18 +306,26 @@ var contextSetup = function(requestDetails) { if (tabId.cookieStoreId != context[0].cookieStoreId) { function Create() { function onCreated(tab) { - function closeOldTab() { + function closeOldTab(tabs) { if (tabId.id != tab.id) { console.log("(isolate) Closing un-isolated tab", tabId.id); console.log("in favor of", tab.id); console.log("with context", tab.cookieStoreId); browser.tabs.remove(tabId.id); } + for (index = 0; index < tabs.length; index++) { + if (index != tabs.length - 1) + browser.tabs.remove(tabs[index].id); + } } - closeOldTab(tab); + var pins = browser.tabs.query({ + cookieStoreId: context[0].cookieStoreId + }); + pins.then(closeOldTab, onError); } var created = browser.tabs.create({ active: true, + pinned: true, cookieStoreId: context[0].cookieStoreId, url: requestDetails.url });