aboutsummaryrefslogtreecommitdiffhomepage
path: root/addon/background.js
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-10-20 20:42:20 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-10-20 20:42:20 +0800
commit62e7f371168917d005af1b3e6935716c1ff3d4a7 (patch)
treeea194842f036e53246aeb662d7121a7ac0168f17 /addon/background.js
parent42ffc1bce9eb31146880d4920d52d7a33b61c30c (diff)
feat: add menu items
Diffstat (limited to 'addon/background.js')
-rw-r--r--addon/background.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/addon/background.js b/addon/background.js
index 24771aa..42e0c8d 100644
--- a/addon/background.js
+++ b/addon/background.js
@@ -2,15 +2,25 @@ console.log('background')
2 2
3browser.contextMenus.create( 3browser.contextMenus.create(
4 { 4 {
5 id: 'map-inline', 5 id: 'map-inline-add',
6 title: 'MapInline', 6 title: 'Add Links and Maps by content',
7 contexts: ['page'],
8 },
9 () => void browser.runtime.lastError,
10)
11
12browser.contextMenus.create(
13 {
14 id: 'map-inline-open',
15 title: 'Open in DumbyMap',
7 contexts: ['page', 'selection'], 16 contexts: ['page', 'selection'],
8 }, 17 },
9 () => void browser.runtime.lastError, 18 () => void browser.runtime.lastError,
10) 19)
11 20
12browser.contextMenus.onClicked.addListener((info, tab) => { 21browser.contextMenus.onClicked.addListener((info, tab) => {
13 if (info.menuItemId !== 'map-inline') return 22 const id = info.menuItemId
23 if (!id.match(/^map-inline/)) return
14 24
15 browser.tabs.sendMessage(tab.id, 'map-inline') 25 browser.tabs.sendMessage(tab.id, id)
16}) 26})