aboutsummaryrefslogtreecommitdiffhomepage
path: root/addon
diff options
context:
space:
mode:
Diffstat (limited to 'addon')
-rw-r--r--addon/background.js16
-rw-r--r--addon/index.mjs12
-rw-r--r--addon/manifest.json8
3 files changed, 35 insertions, 1 deletions
diff --git a/addon/background.js b/addon/background.js
new file mode 100644
index 0000000..24771aa
--- /dev/null
+++ b/addon/background.js
@@ -0,0 +1,16 @@
1console.log('background')
2
3browser.contextMenus.create(
4 {
5 id: 'map-inline',
6 title: 'MapInline',
7 contexts: ['page', 'selection'],
8 },
9 () => void browser.runtime.lastError,
10)
11
12browser.contextMenus.onClicked.addListener((info, tab) => {
13 if (info.menuItemId !== 'map-inline') return
14
15 browser.tabs.sendMessage(tab.id, 'map-inline')
16})
diff --git a/addon/index.mjs b/addon/index.mjs
index 5776a18..b9fc349 100644
--- a/addon/index.mjs
+++ b/addon/index.mjs
@@ -1,3 +1,13 @@
1browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
2 console.log('receive message', message)
3 sendResponse('received')
4 if (message === 'map-inline') {
5 alert('map')
6 return Promise.resolve('done')
7 }
8 return false
9})
10
1const url = new URL(window.location) 11const url = new URL(window.location)
2const use = url.searchParams.get('use') 12const use = url.searchParams.get('use')
3if (url.host === 'www.ptt.cc') { 13if (url.host === 'www.ptt.cc') {
@@ -41,6 +51,6 @@ if (!document.querySelector('.Dumby')) {
41 addBlocks, 51 addBlocks,
42 initialLayout: 'sticky', 52 initialLayout: 'sticky',
43 render: simpleRender, 53 render: simpleRender,
44 autoMap: true, 54 autoMap: false,
45 }) 55 })
46} 56}
diff --git a/addon/manifest.json b/addon/manifest.json
index b95fd4b..c354f65 100644
--- a/addon/manifest.json
+++ b/addon/manifest.json
@@ -27,10 +27,18 @@
27 } 27 }
28 ], 28 ],
29 29
30 "background": {
31 "scripts": [
32 "background.js"
33 ],
34 "persistent": false
35 },
36
30 "permissions": [ 37 "permissions": [
31 "activeTab", 38 "activeTab",
32 "tabs", 39 "tabs",
33 "scripting", 40 "scripting",
41 "contextMenus",
34 "https://epsg.io/*", 42 "https://epsg.io/*",
35 "https://cdn.jsdelivr.net/*" 43 "https://cdn.jsdelivr.net/*"
36 ] 44 ]