From 13cd59bbe097059b00e78edd33ee460e26995b83 Mon Sep 17 00:00:00 2001 From: Bauke Date: Mon, 16 Nov 2020 22:17:56 +0100 Subject: [PATCH] If the next link can't be opened in the current tab, create a new one for it instead. --- source/background.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/background.ts b/source/background.ts index 18de3ad..b9c8ae1 100644 --- a/source/background.ts +++ b/source/background.ts @@ -36,7 +36,12 @@ browser.browserAction.onClicked.addListener(async () => { data: nextItem }; - await browser.tabs.sendMessage(tabs[0].id!, message); + try { + await browser.tabs.sendMessage(tabs[0].id!, message); + } catch { + await browser.tabs.create({active: true, url: nextItem.url}); + } + await removeQItem(nextItem.id); } }, 500);