Add link rel=me and rel=author, filter unique URIs
This commit is contained in:
parent
0dd0f8bf3d
commit
d6ef7cdd5e
28
content.js
28
content.js
@ -1,20 +1,26 @@
|
|||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const alternateLinks = document.querySelectorAll('link[rel="alternate"][type="application/nostr+json"]');
|
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 (alternateLinks.length > 0) {
|
if (links.length > 0) {
|
||||||
console.debug("[nostr-links] Found:", alternateLinks);
|
links.forEach(link => {
|
||||||
|
const uri = link.href.replace(/^(nostr|web+nostr):/, "").trim();
|
||||||
|
let text = link.title?.trim() || '';
|
||||||
|
if (link.rel === "author") text = `Author: ${text}`;
|
||||||
|
|
||||||
const links = Array.from(alternateLinks).map((link, index) => ({
|
linkMap.set(uri, {
|
||||||
uri: link.href.replace(/^(nostr|web+nostr):/, ""),
|
uri: uri,
|
||||||
text: link.title.trim()
|
text: text,
|
||||||
// icon: "icon.png"
|
rel: link.rel
|
||||||
}));
|
// icon: "icon.png"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
browser.runtime.sendMessage({
|
browser.runtime.sendMessage({
|
||||||
action: "showNostrLinksPageAction",
|
action: "showNostrLinksPageAction",
|
||||||
links: links
|
links: Array.from(linkMap.values())
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
console.debug("[nostr-links] No nostr links found");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user