1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/* global browser */
browser.contextMenus.create(
{
id: 'map-inline-add',
title: 'Add Links and Maps by content',
contexts: ['all'],
},
)
browser.contextMenus.create(
{
id: 'map-inline-menu',
title: 'Enable Menu',
type: 'checkbox',
checked: true,
contexts: ['all'],
},
)
browser.contextMenus.create(
{
type: 'separator',
},
)
browser.contextMenus.create(
{
id: 'map-inline-open',
title: 'Open in DumbyMap',
contexts: ['all'],
},
() => browser.runtime.lastError,
)
browser.contextMenus.onClicked.addListener((info, tab) => {
const id = info.menuItemId
const checked = info.checked
if (!id.match(/^map-inline/)) return
browser.tabs.sendMessage(tab.id, { id, checked })
})
browser.browserAction.onClicked.addListener((info) => {
browser.tabs.sendMessage(info.id, 'map-inline-add')
})
|