From f83944444f7d8a65e832575d6cb0235f67879e7e Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Fri, 5 Jan 2024 14:12:08 +0100 Subject: [PATCH] added: simple web clipper --- clipper/clipper.js | 6 ++++++ main.js | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 clipper/clipper.js diff --git a/clipper/clipper.js b/clipper/clipper.js new file mode 100644 index 0000000..873d55d --- /dev/null +++ b/clipper/clipper.js @@ -0,0 +1,6 @@ +javascript: (function() +{ + var notesurl = ""; + var content = document.title + "\n" + document.location; + window.open("https://" + notesurl + "?c=" + encodeURIComponent(content), "_blank", "popup,width=100,height=100"); +})(); diff --git a/main.js b/main.js index 8e2dba8..88e45b3 100644 --- a/main.js +++ b/main.js @@ -34,6 +34,7 @@ var pending = false; var settings = null; var tags = null; var titlemap = {}; +var clip = ""; var stat = { @@ -1179,6 +1180,12 @@ function loadstorage() var title = params.get("n"); var line = params.get("l"); var tags = params.get("t"); + clip = params.get("c"); + + if (clip) + { + title = "bookmarks"; + } if (currentnote) { @@ -1193,6 +1200,12 @@ function loadstorage() currentnote = {title: title, content: newcontent, pos: newcontent.length}; localdata.unshift(currentnote); } + if (clip) + { + hat = headerandtext(currentnote); + var dt = timestamp().substr(0,10); + currentnote.content = hat.header + dt + " " + clip + "\n\n" + hat.text; + } } if (currentnote) @@ -1202,6 +1215,16 @@ function loadstorage() { gotoline(line); } + if (clip) + { + colored.hidden = true; + var msg = document.createElement("div"); + msg.innerText = "Clipping..."; + msg.setAttribute("style", "width:100px;height:100px;top:0;left:0"); + notepage.appendChild(msg); + saved = false; + save(); + } } else { @@ -1809,6 +1832,10 @@ function setsaved() unsavedmark.hidden = true; saved = true; lastsaved = timestamp(); + if (clip) + { + close(); + } } function save()