unofficial port of the ln.ht bookmarklet to a chromium extension because i use arc and can't use bookmarklets >:C

initial commit yay

images/icon-128.png

This is a binary file and will not be displayed.

images/icon-16.png

This is a binary file and will not be displayed.

images/icon-32.png

This is a binary file and will not be displayed.

images/icon-64.png

This is a binary file and will not be displayed.

lnht.png

This is a binary file and will not be displayed.

+8
lnht.svg
···
···
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+
<svg xmlns="http://www.w3.org/2000/svg" height="84" width="84">
+
<rect x="1" y="1" height="41" width="41" fill="#FFD700" />
+
<rect x="42" y="42" height="41" width="41" fill="#FFD700" />
+
<rect x="1" y="42" height="41" width="41" fill="#2B2B2B" />
+
<rect x="42" y="1" height="41" width="41" fill="#2B2B2B" />
+
<rect x="1" y="1" height="82" width="82" fill="none" stroke="#2B2B2B" stroke-width="1" stroke-linejoin="round" />
+
</svg>
+19
manifest.json
···
···
+
{
+
"name": "ln.ht",
+
"description": "Unofficial port of the linkhut bookmarklet to a chrome extension",
+
"version": "1.0",
+
"manifest_version": 3,
+
"permissions": ["activeTab", "scripting"],
+
"action": {
+
"default_icon": "lnht.png"
+
},
+
"background": {
+
"service_worker": "service-worker.js"
+
},
+
"icons": {
+
"16": "images/icon-16.png",
+
"32": "images/icon-32.png",
+
"64": "images/icon-64.png",
+
"128": "images/icon-128.png"
+
}
+
}
+12
service-worker.js
···
···
+
function openLnHt () {
+
window.open(`https://ln.ht/_/add?url=${encodeURIComponent(document.location)}&title=${encodeURIComponent(document.title)}&notes=${document.querySelector('meta[name="description"]') !== null ? document.querySelector('meta[name="description"]').content : ''}&tags=${document.querySelector('meta[name="keywords"]') !== null ? document.querySelector('meta[name="keywords"]').content : ''}`);
+
}
+
+
chrome.action.onClicked.addListener((tab) => {
+
if (!tab.url.includes('chrome://')) {
+
chrome.scripting.executeScript({
+
target: { tabId: tab.id },
+
function: openLnHt
+
});
+
}
+
});