Fix shortcut triggered for real active tab (#345)

This commit is contained in:
Binly42 2022-03-02 20:15:43 +08:00 committed by GitHub
parent 45f83116f6
commit 46b1a33e1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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");