Compare commits

..

No commits in common. "master" and "v1.0.1" have entirely different histories.

5 changed files with 12 additions and 89 deletions

24
LICENSE
View File

@ -1,24 +0,0 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org/>

View File

@ -1,18 +0,0 @@
# Nostr Links Web Extension
A browser extension for discovering and opening Nostr links.
![Screenshot](https://gitea.kosmos.org/attachments/178357a0-65e9-40ee-a9e5-55be8eef7d35)
Details described in this article: https://nostr.kosmos.org/@raucao/link-rel-nostr
## ngit
This repo is also available via ngit:
git clone nostr://raucao@kosmos.org/nostr-links
[Issues and PRs](https://gitworkshop.dev/raucao@kosmos.org/nostr-links/prs)
are also accepted this way.
Quick start: https://gitworkshop.dev/quick-start

View File

@ -1,30 +1,20 @@
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
const linkRels = ['alternate', 'me', 'author']; const alternateLinks = document.querySelectorAll('link[rel="alternate"][type="application/nostr+json"]');
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) { if (alternateLinks.length > 0) {
links.forEach(link => { console.debug("[nostr-links] Found:", alternateLinks);
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, { const links = Array.from(alternateLinks).map((link, index) => ({
uri: uri, uri: link.href.replace(/^(nostr|web+nostr):/, ""),
text: text, text: link.title.trim()
rel: link.rel // icon: "icon.png"
// icon: "icon.png" }));
});
});
browser.runtime.sendMessage({ browser.runtime.sendMessage({
action: "showNostrLinksPageAction", action: "showNostrLinksPageAction",
links: Array.from(linkMap.values()) links: links
}); });
} else {
console.debug("[nostr-links] No nostr links found");
} }
}); });

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 3, "manifest_version": 3,
"name": "Nostr Links", "name": "Nostr Links",
"version": "1.1.0", "version": "1.0.1",
"description": "A web extension to discover Nostr links", "description": "A web extension to discover Nostr links",
"author": "Râu Cao", "author": "Râu Cao",
"homepage_url": "https://gitea.kosmos.org/raucao/nostr-links", "homepage_url": "https://gitea.kosmos.org/raucao/nostr-links",

View File

@ -1,25 +0,0 @@
<!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>