commit 077469173cb48b392b59ac8904764399aaff6ceb
parent 544a9c29079b259170c6c1da1fcb7262e0650b98
Author: David Eisinger <[email protected]>
Date: Fri, 10 Oct 2025 10:58:37 -0400
Bookmarklet copy btn
Diffstat:
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/internal/web/app.js b/internal/web/app.js
@@ -16,6 +16,7 @@ createApp({
viewUser: '',
auth: { username: '', password: '' },
api: { value: '', busy: false, copied: false },
+ bmlet: { copied: false },
};
},
mounted() {
@@ -232,6 +233,31 @@ createApp({
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)}})();";
return tmpl.replace('{{ORIGIN}}', origin).replace('{{AUTH}}', auth);
},
+ async copyBookmarklet() {
+ const js = this.bookmarkletHref();
+ try {
+ await navigator.clipboard.writeText(js);
+ this.bmlet.copied = true;
+ setTimeout(()=>{ this.bmlet.copied = false; }, 1500);
+ } catch (e) {
+ // Fallback for browsers without Clipboard API (including some iOS versions)
+ try {
+ const ta = document.createElement('textarea');
+ ta.value = js;
+ ta.style.position = 'fixed';
+ ta.style.opacity = '0';
+ document.body.appendChild(ta);
+ ta.focus();
+ ta.select();
+ document.execCommand('copy');
+ document.body.removeChild(ta);
+ this.bmlet.copied = true;
+ setTimeout(()=>{ this.bmlet.copied = false; }, 1500);
+ } catch {
+ alert('Copy failed. Long‑press the Save to Marky button, copy the link, then paste into a new bookmark.');
+ }
+ }
+ },
formatDate(iso) {
try { return new Date(iso).toLocaleString(); } catch { return iso; }
},
diff --git a/internal/web/settings.html b/internal/web/settings.html
@@ -31,6 +31,10 @@
<a id="bmlet" class="btn" :href="bookmarkletHref()">Save to Marky</a>
</p>
<p class="muted">When clicked on any page, this opens a small form prefilled with the page URL and title. On submit, it saves to your Marky account.</p>
+ <p class="muted" style="margin-top:12px;">On iOS or mobile, tap Copy and paste the link into a new bookmark:</p>
+ <p>
+ <button class="btn" @click.prevent="copyBookmarklet">{{ bmlet.copied ? 'Copied!' : 'Copy' }}</button>
+ </p>
</section>
</main>
</div>