From 2165e27b5a4415ab99eed2856f48f75a6745a76d Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Mon, 17 Oct 2022 23:43:37 -0700 Subject: [PATCH] Remove extra tab lookup, support command-click to not close tab --- background.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/background.js b/background.js index 1992f9b..8c0e760 100644 --- a/background.js +++ b/background.js @@ -1,12 +1,6 @@ const reData = new RegExp('^data:(.*?);base64,(.*)$'); -async function handleClick() { - const tabs = await browser.tabs.query({currentWindow: true, active: true}); - if (tabs.length != 1) { - return; - } - const tab = tabs[0]; - +async function handleClick(tab, e) { const promiseImgURL = browser.tabs.captureTab(tab.id); const cfg = await browser.storage.sync.get(); @@ -38,7 +32,9 @@ async function handleClick() { const img = atob(imgBase64); // All tab info captured - browser.tabs.remove([tab.id]); + if (!e.modifiers.includes('Command')) { + browser.tabs.remove([tab.id]); + } const createResp = await promiseCreateResp; const create = await createResp.json();