replace all links on mousedown instead of mouseenter -- and this allows us to track nostr: links added later to the page without any overhead.
This commit is contained in:
@@ -66,11 +66,9 @@ window.addEventListener('message', message => {
|
|||||||
|
|
||||||
// hack to replace nostr:nprofile.../etc links with something else
|
// hack to replace nostr:nprofile.../etc links with something else
|
||||||
let replacing = null
|
let replacing = null
|
||||||
let links = document.querySelectorAll('a[href^="nostr:"]')
|
document.addEventListener('mousedown', replaceNostrSchemeLink)
|
||||||
for (let i = 0; i < links.length; i++) {
|
|
||||||
links[i].addEventListener('mouseenter', replaceNostrSchemeLink)
|
|
||||||
}
|
|
||||||
async function replaceNostrSchemeLink(e) {
|
async function replaceNostrSchemeLink(e) {
|
||||||
|
if (e.target.tagName !== 'A' || !e.target.href.startsWith('nostr:')) return
|
||||||
if (replacing === false) return
|
if (replacing === false) return
|
||||||
|
|
||||||
let response = await window.nostr._call('replaceURL', {url: e.target.href})
|
let response = await window.nostr._call('replaceURL', {url: e.target.href})
|
||||||
|
|||||||
Reference in New Issue
Block a user