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
··· 1 + <?xml version="1.0" encoding="UTF-8" standalone="no"?> 2 + <svg xmlns="http://www.w3.org/2000/svg" height="84" width="84"> 3 + <rect x="1" y="1" height="41" width="41" fill="#FFD700" /> 4 + <rect x="42" y="42" height="41" width="41" fill="#FFD700" /> 5 + <rect x="1" y="42" height="41" width="41" fill="#2B2B2B" /> 6 + <rect x="42" y="1" height="41" width="41" fill="#2B2B2B" /> 7 + <rect x="1" y="1" height="82" width="82" fill="none" stroke="#2B2B2B" stroke-width="1" stroke-linejoin="round" /> 8 + </svg>
+19
manifest.json
··· 1 + { 2 + "name": "ln.ht", 3 + "description": "Unofficial port of the linkhut bookmarklet to a chrome extension", 4 + "version": "1.0", 5 + "manifest_version": 3, 6 + "permissions": ["activeTab", "scripting"], 7 + "action": { 8 + "default_icon": "lnht.png" 9 + }, 10 + "background": { 11 + "service_worker": "service-worker.js" 12 + }, 13 + "icons": { 14 + "16": "images/icon-16.png", 15 + "32": "images/icon-32.png", 16 + "64": "images/icon-64.png", 17 + "128": "images/icon-128.png" 18 + } 19 + }
+12
service-worker.js
··· 1 + function openLnHt () { 2 + 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 : ''}`); 3 + } 4 + 5 + chrome.action.onClicked.addListener((tab) => { 6 + if (!tab.url.includes('chrome://')) { 7 + chrome.scripting.executeScript({ 8 + target: { tabId: tab.id }, 9 + function: openLnHt 10 + }); 11 + } 12 + });