From 46b1a33e1d1b7fcd04225bb0062b5f94528b2335 Mon Sep 17 00:00:00 2001 From: Binly42 Date: Wed, 2 Mar 2022 20:15:43 +0800 Subject: [PATCH] Fix shortcut triggered for real active tab (#345) --- src/background/keyboardShortcuts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/background/keyboardShortcuts.js b/src/background/keyboardShortcuts.js index 6a04f6e..4734ff7 100644 --- a/src/background/keyboardShortcuts.js +++ b/src/background/keyboardShortcuts.js @@ -43,13 +43,13 @@ export const onCommandListener = async command => { }; const translateSelectedText = async () => { - const tab = (await browser.tabs.query({ active: true }))[0]; + const tab = (await browser.tabs.query({ active: true, currentWindow: true }))[0]; browser.tabs.sendMessage(tab.id, { message: "translateSelectedText" }); }; const translatePage = async () => { - const tab = (await browser.tabs.query({ active: true }))[0]; + const tab = (await browser.tabs.query({ active: true, currentWindow: true }))[0]; const tabUrl = await browser.tabs.sendMessage(tab.id, { message: "getTabUrl" }); const targetLang = getSettings("targetLang");