Skip to content

Commit 93e0de0

Browse files
committed
feat: pdf and local file support
1 parent 9ebeba6 commit 93e0de0

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

src/background/index.mjs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,18 @@ function refreshMenu() {
180180
}
181181

182182
Browser.contextMenus.onClicked.addListener((info, tab) => {
183-
const message = {
184-
itemId: info.menuItemId.replace(menuId, ''),
185-
selectionText: info.selectionText,
186-
useMenuPosition: true,
187-
}
188-
console.debug('menu clicked', message)
189-
Browser.tabs.sendMessage(tab.id, {
190-
type: 'CREATE_CHAT',
191-
data: message,
183+
Browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
184+
const currentTab = tabs[0]
185+
const message = {
186+
itemId: info.menuItemId.replace(menuId, ''),
187+
selectionText: info.selectionText,
188+
useMenuPosition: tab.id === currentTab.id,
189+
}
190+
console.debug('menu clicked', message)
191+
Browser.tabs.sendMessage(currentTab.id, {
192+
type: 'CREATE_CHAT',
193+
data: message,
194+
})
192195
})
193196
})
194197
})

src/manifest.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
{
3434
"matches": [
3535
"https://*/*",
36-
"http://*/*"
36+
"http://*/*",
37+
"file://*/*"
3738
],
3839
"js": [
3940
"shared.js",
@@ -47,7 +48,7 @@
4748
"web_accessible_resources": [
4849
{
4950
"resources": [
50-
"*.png"
51+
"logo.png"
5152
],
5253
"matches": [
5354
"<all_urls>"

src/manifest.v2.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
{
3434
"matches": [
3535
"https://*/*",
36-
"http://*/*"
36+
"http://*/*",
37+
"file://*/*"
3738
],
3839
"js": [
3940
"shared.js",
@@ -45,7 +46,7 @@
4546
}
4647
],
4748
"web_accessible_resources": [
48-
"*.png"
49+
"logo.png"
4950
],
5051
"commands": {
5152
"newChat": {

0 commit comments

Comments
 (0)