From 1caf56dc0a2bbf4bb484fe4f312b5229a63aace3 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Wed, 16 Oct 2024 16:57:47 +0800 Subject: feat: add simple script to test mapclay * add more options for generateMaps for general purposes * add rollup config for adding script into addon --- addon/manifest.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'addon/manifest.json') diff --git a/addon/manifest.json b/addon/manifest.json index 27433b3..9cc6607 100644 --- a/addon/manifest.json +++ b/addon/manifest.json @@ -11,8 +11,14 @@ "content_scripts": [ { - "matches": ["*://*.mozilla.org/*"], - "js": ["index.mjs"], + "matches": [ + "*://*.mozilla.org/*", + "*://hackmd.io/*" + ], + "js": [ + "dumbymap.mjs", + "index.mjs" + ], "css": [ "css/dumbymap.css" ] -- cgit v1.2.3-70-g09d2 From 42ae19120e9b9e907e405ad1a272de11e0d37e2d Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Wed, 16 Oct 2024 20:44:42 +0800 Subject: feat: include more domains for addon --- addon/manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addon/manifest.json') diff --git a/addon/manifest.json b/addon/manifest.json index 9cc6607..e97ae50 100644 --- a/addon/manifest.json +++ b/addon/manifest.json @@ -13,7 +13,8 @@ { "matches": [ "*://*.mozilla.org/*", - "*://hackmd.io/*" + "*://hackmd.io/*", + "*://*.ptt.cc/*" ], "js": [ "dumbymap.mjs", -- cgit v1.2.3-70-g09d2 From 5502bf29bdbaa054a96794ddf93ab8cf0bcc2f77 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Thu, 17 Oct 2024 10:19:46 +0800 Subject: fix: CRS for addon --- addon/index.mjs | 1 + addon/manifest.json | 5 +++-- src/dumbymap.mjs | 7 +++---- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'addon/manifest.json') diff --git a/addon/index.mjs b/addon/index.mjs index 323edf1..2494ec4 100644 --- a/addon/index.mjs +++ b/addon/index.mjs @@ -12,6 +12,7 @@ const simpleRender = window.mapclay.renderWith(config => ({ })) window.generateMaps(document.querySelector('main') ?? document.body, { + crs: url.searchParams.get('crs') ?? 'EPSG:4326', initialLayout: '', render: simpleRender, }) diff --git a/addon/manifest.json b/addon/manifest.json index e97ae50..2d7b1ed 100644 --- a/addon/manifest.json +++ b/addon/manifest.json @@ -12,7 +12,7 @@ "content_scripts": [ { "matches": [ - "*://*.mozilla.org/*", + "*://developer.mozilla.org/*", "*://hackmd.io/*", "*://*.ptt.cc/*" ], @@ -29,6 +29,7 @@ "permissions": [ "activeTab", "tabs", - "scripting" + "scripting", + "https://epsg.io/*" ] } diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index 55d29d3..cbd44b2 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs @@ -241,10 +241,10 @@ export const generateMaps = (container, { register(proj4) fromEPSGCode(crs).then(() => resolve()) }) - const addGeoSchemeByText = new Promise(resolve => { + const addGeoSchemeByText = (async () => { const coordPatterns = /(-?\d+\.?\d*)([,\x2F\uFF0C])(-?\d+\.?\d*)/ const re = new RegExp(coordPatterns, 'g') - htmlHolder.querySelectorAll('p') + htmlHolder.querySelectorAll('.dumby-block') .forEach(p => { replaceTextNodes(p, re, match => { const a = document.createElement('a') @@ -253,8 +253,7 @@ export const generateMaps = (container, { return a }) }) - resolve() - }) + })() Promise.all([setCRS, addGeoSchemeByText]).then(() => { Array.from(container.querySelectorAll(geoLinkSelector)) -- cgit v1.2.3-70-g09d2