Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
7e133cae63 | |||
1fc46a38a8 | |||
aa944e8894 | |||
f04773a3a9 |
12
content.js
12
content.js
@ -1,13 +1,17 @@
|
||||
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();
|
||||
const linkRels = ['alternate', 'me', 'author'];
|
||||
const selectorUntyped = linkRels.map(rel => `link[rel="${rel}"][href^="nostr:"]`).join(',');
|
||||
const selectorTyped = linkRels.map(rel => `link[rel="${rel}"][type="application/nostr+json"]`).join(',');
|
||||
const untypedLinks = document.querySelectorAll(selectorUntyped);
|
||||
const typedLinks = document.querySelectorAll(selectorTyped);
|
||||
const links = [...untypedLinks, ...typedLinks]
|
||||
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 === "me") text = `Me: ${text}`;
|
||||
if (link.rel === "author") text = `Author: ${text}`;
|
||||
|
||||
linkMap.set(uri, {
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "Nostr Links",
|
||||
"version": "1.0.2",
|
||||
"version": "1.1.0",
|
||||
"description": "A web extension to discover Nostr links",
|
||||
"author": "Râu Cao",
|
||||
"homepage_url": "https://gitea.kosmos.org/raucao/nostr-links",
|
||||
|
25
test/example.html
Normal file
25
test/example.html
Normal file
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Example page</title>
|
||||
<link rel="me" href="nostr:npub1raustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89svgdees" title="Ru Cao">
|
||||
<link rel="me" type="application/nostr+json" href="nostr:npub1raustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89svgdees" title="Râu Cao">
|
||||
<link rel="author" type="text/html" href="https://nostr.kosmos.org/@jimmy" title="Jimmy">
|
||||
<link rel="author" type="application/nostr+json" href="nostr:nprofile1qyfhwue69uhkcmmrv9kxsmmnwsarwdehxuqzqplp3zsllp7wzuw4z7uw62ah5vd36dzn5rdnk9fhnmq8kujdyvhnmg53sl" title="Jimmy">
|
||||
<link rel="alternate" type="application/nostr+json" href="nostr:naddr1qvzqqqr4gupzqplp3zsllp7wzuw4z7uw62ah5vd36dzn5rdnk9fhnmq8kujdyvhnqyfhwue69uhkcmmrv9kxsmmnwsarwdehxuqq6vfhxgunvwp4x5unwve3xcmz28za" title="Testing my new blog">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Nostr Links Examples</h1>
|
||||
<p>(Inspect link tags in source)</p>
|
||||
<article>
|
||||
<h2>Testing my new blog</h2>
|
||||
<div class="meta"><p>By Jimmy, published on October 23, 2024</p></div>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. <a href="https://njump.me/nprofile1qyt8wumn8ghj7mn0wd68yetvd96x2uewdaexwtcpz4mhxue69uhhyetvv9ujuat50phjummwv5hsqgqmcu9qzj9n7vtd5vl78jyly037wxkyl7vcqflvwy4eqhxjfa4yzyzh27uu" rel="noopener noreferrer">Excepteur</a> sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||
<p>Lorem ipsum dolor sit amet, <a href="https://en.wikipedia.org/wiki/Lorem_ipsum" rel="noopener noreferrer">consectetur</a> adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo <a href="https://njump.me/naddr1qvzqqqr4gupzpwcpwjhzrfk2cxs2nj9543htlkjkeegkqhp3tvvzf9ctcf6lwgu6qqgrjvmyv93nwcmxvvukgdmxxfjn2eqwafx" rel="noopener noreferrer">consequat</a>.</p>
|
||||
<h3>A sub heading goes a long way</h3>
|
||||
<p>Lorem ipsum dolor sit amet, <a href="https://en.wikipedia.org/wiki/Lorem_ipsum" rel="noopener noreferrer">consectetur</a> adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut <a href="npub1qlsc3g0lsl8pw8230w8d9wm6xxcax3f6pkemz5measrmwfxjxteslf2hac" rel="noopener noreferrer">aliquip ex</a> ea commodo <a href="nprofile1qy2hwumn8ghj7un9d3shjtnyv9kh2uewd9hj7qgkwaehxw309aex2mrp0yhx6mmnw3ezuur4vghsqgq8uxy2rlu8ect365tm3mftk733k8f52wsdkwc4x70vq7mjf53j7v7hknv0" rel="noopener noreferrer">consequat</a>.</p>
|
||||
</article>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user