From 479a2ab55340174b5848ba04c141396a1bf87062 Mon Sep 17 00:00:00 2001 From: josc146 Date: Wed, 29 Mar 2023 17:36:37 +0800 Subject: [PATCH] feat: pdf and local file support --- src/background/index.mjs | 21 ++++++++++++--------- src/manifest.json | 5 +++-- src/manifest.v2.json | 5 +++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/background/index.mjs b/src/background/index.mjs index 8a9e119..e3812df 100644 --- a/src/background/index.mjs +++ b/src/background/index.mjs @@ -180,15 +180,18 @@ function refreshMenu() { } Browser.contextMenus.onClicked.addListener((info, tab) => { - const message = { - itemId: info.menuItemId.replace(menuId, ''), - selectionText: info.selectionText, - useMenuPosition: true, - } - console.debug('menu clicked', message) - Browser.tabs.sendMessage(tab.id, { - type: 'CREATE_CHAT', - data: message, + Browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => { + const currentTab = tabs[0] + const message = { + itemId: info.menuItemId.replace(menuId, ''), + selectionText: info.selectionText, + useMenuPosition: tab.id === currentTab.id, + } + console.debug('menu clicked', message) + Browser.tabs.sendMessage(currentTab.id, { + type: 'CREATE_CHAT', + data: message, + }) }) }) }) diff --git a/src/manifest.json b/src/manifest.json index 413fa30..a3442f1 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -33,7 +33,8 @@ { "matches": [ "https://*/*", - "http://*/*" + "http://*/*", + "file://*/*" ], "js": [ "shared.js", @@ -47,7 +48,7 @@ "web_accessible_resources": [ { "resources": [ - "*.png" + "logo.png" ], "matches": [ "" diff --git a/src/manifest.v2.json b/src/manifest.v2.json index 23d9db5..abccea6 100644 --- a/src/manifest.v2.json +++ b/src/manifest.v2.json @@ -33,7 +33,8 @@ { "matches": [ "https://*/*", - "http://*/*" + "http://*/*", + "file://*/*" ], "js": [ "shared.js", @@ -45,7 +46,7 @@ } ], "web_accessible_resources": [ - "*.png" + "logo.png" ], "commands": { "newChat": {