marky

Lightweight bookmarking + plaintext archive
Log | Files | Refs | README | LICENSE

commit 16e579a2e440dd6fe9b404365dc69f600c63c089
parent 1b3c0589cfcd8cfd57eba0785788942eaa762421
Author: David Eisinger <[email protected]>
Date:   Fri, 10 Oct 2025 14:39:12 -0400

Bookmarklet/referrer bugfixes

Diffstat:
Minternal/api.go | 8++++----
Minternal/web/app.js | 2+-
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/internal/api.go b/internal/api.go @@ -208,10 +208,10 @@ func NewHandlerWithConfig(db *DB, cfg HandlerConfig) (http.Handler, error) { const payload = { url: document.getElementById('url').value.trim(), title: document.getElementById('title').value.trim(), - description: (function(){const v=document.getElementById('desc').value; return v.trim() ? v : null;})(), - referrer: (function(){const v=document.getElementById('ref').value; return v.trim() ? v : (document.referrer||null);})(), - public: document.getElementById('pub').checked - }; + description: (function(){const v=document.getElementById('desc').value; return v.trim() ? v : null;})(), + referrer: (function(){const v=document.getElementById('ref').value; return v.trim() ? v : null;})(), + public: document.getElementById('pub').checked + }; try { const res = await fetch('%[5]s/bookmarks', { method: 'POST', diff --git a/internal/web/app.js b/internal/web/app.js @@ -230,7 +230,7 @@ createApp({ const auth = (this.api.value && this.me && this.me.username) ? `&user=${encodeURIComponent(this.me.username)}&tok=${encodeURIComponent(this.api.value)}` : ''; - const tmpl = "javascript:(function(){try{var d=document,s=encodeURIComponent,u=location.href,t=document.title,sel='';var ae=d.activeElement;if(ae&&((ae.tagName==='TEXTAREA')||(ae.tagName==='INPUT'&&/^(?:text|search|url|tel|email)$/i.test(ae.type)))){var ss=ae.selectionStart||0,se=ae.selectionEnd||0;if(typeof ss==='number'&&typeof se==='number'&&se>ss){sel=ae.value.substring(ss,se)}}if(!sel&&d.getSelection){sel=d.getSelection().toString()}else if(!sel&&window.getSelection){sel=window.getSelection().toString()}else if(!sel&&d.selection){sel=d.selection.createRange().text}var ref=d.referrer||'';var win=window.open('{{ORIGIN}}/bookmarklet?u='+s(u)+'&t='+s(t)+'&d='+s(sel)+'&r='+s(ref)+'{{AUTH}}','marky','width=520,height=520');if(win){win.focus()}}catch(e){alert('Could not open Marky: '+e)}})();"; + const tmpl = "javascript:(function(){try{var d=document,s=encodeURIComponent,u=location.href,t=document.title,sel='';var ae=d.activeElement;if(ae&&((ae.tagName==='TEXTAREA')||(ae.tagName==='INPUT'&&/^(?:text|search|url|tel|email)$/i.test(ae.type)))){var ss=ae.selectionStart||0,se=ae.selectionEnd||0;if(typeof ss==='number'&&typeof se==='number'&&se>ss){sel=ae.value.substring(ss,se)}}if(!sel&&d.getSelection){sel=d.getSelection().toString()}else if(!sel&&window.getSelection){sel=window.getSelection().toString()}else if(!sel&&d.selection){sel=d.selection.createRange().text}var ref=d.referrer||'';try{var ch=location.hostname||'';var rh=ref?new URL(ref).hostname:'';if(rh&&ch&&rh===ch){ref='';}}catch(e){}var win=window.open('{{ORIGIN}}/bookmarklet?u='+s(u)+'&t='+s(t)+'&d='+s(sel)+'&r='+s(ref)+'{{AUTH}}','marky','width=520,height=520');if(win){win.focus()}}catch(e){alert('Could not open Marky: '+e)}})();"; return tmpl.replace('{{ORIGIN}}', origin).replace('{{AUTH}}', auth); }, async copyBookmarklet() {