From 587c36a7bb5abcf30182f82df8d33f1a8f25d73c Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 3 Jan 2018 09:16:15 -0500 Subject: [PATCH] close the newest tab --- background.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/background.js b/background.js index 5ed6015..198d8b8 100644 --- a/background.js +++ b/background.js @@ -12,12 +12,11 @@ const getBrowser = () => { const maxNumTabs = 5; const [browser, browserType] = getBrowser(); -browser.tabs.onCreated.addListener(tabId => { +browser.tabs.onCreated.addListener(newTab => { getTabs(tabs => { const numTabsOpen = tabs.filter(tab => !tab.pinned).length; if (numTabsOpen > maxNumTabs) { - const newTab = tabs.filter(tab => tab.active)[0]; - removeTab(newTab.id); + browser.tabs.remove(newTab.id); } }); }); @@ -29,7 +28,4 @@ const getTabs = callback => { browser.tabs.query({}).then(tabs => callback(tabs)); } }; - -const removeTab = tabId => { - browser.tabs.remove(tabId); -}; +; -- 2.51.2