27 lines
789 B
JavaScript
27 lines
789 B
JavaScript
document.addEventListener('DOMContentLoaded', function() {
|
|
const linkRels = ['alternate', 'me', 'author'];
|
|
const selector = linkRels.map(rel => `link[rel="${rel}"][type="application/nostr+json"]`).join(',');
|
|
const links = document.querySelectorAll(selector);
|
|
const linkMap = new Map();
|
|
|
|
if (links.length > 0) {
|
|
links.forEach(link => {
|
|
const uri = link.href.replace(/^(nostr|web+nostr):/, "").trim();
|
|
let text = link.title?.trim() || '';
|
|
if (link.rel === "author") text = `Author: ${text}`;
|
|
|
|
linkMap.set(uri, {
|
|
uri: uri,
|
|
text: text,
|
|
rel: link.rel
|
|
// icon: "icon.png"
|
|
});
|
|
});
|
|
|
|
browser.runtime.sendMessage({
|
|
action: "showNostrLinksPageAction",
|
|
links: Array.from(linkMap.values())
|
|
});
|
|
}
|
|
});
|