Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
bb56e269c4
|
|||
|
d6ef7cdd5e
|
|||
|
0dd0f8bf3d
|
|||
|
f1c2b4a592
|
24
LICENSE
Normal file
24
LICENSE
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
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/>
|
||||||
18
README.md
Normal file
18
README.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Nostr Links Web Extension
|
||||||
|
|
||||||
|
A browser extension for discovering and opening Nostr links.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
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
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Nostr Links",
|
"name": "Nostr Links",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"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",
|
||||||
|
|||||||
Reference in New Issue
Block a user