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:
fiatjaf
2023-01-14 16:24:02 -03:00
parent 9817ce90a6
commit 8830ce1b55

View File

@@ -66,11 +66,9 @@ window.addEventListener('message', message => {
// hack to replace nostr:nprofile.../etc links with something else
let replacing = null
let links = document.querySelectorAll('a[href^="nostr:"]')
for (let i = 0; i < links.length; i++) {
links[i].addEventListener('mouseenter', replaceNostrSchemeLink)
}
document.addEventListener('mousedown', replaceNostrSchemeLink)
async function replaceNostrSchemeLink(e) {
if (e.target.tagName !== 'A' || !e.target.href.startsWith('nostr:')) return
if (replacing === false) return
let response = await window.nostr._call('replaceURL', {url: e.target.href})