A bookmarklet to copy the document title and page URL to the clipboard. If you select/highlight text on the web page, the text is appended to the beginning of the text.
Full version:
javascript: (
function () {
let selection = "";
if (window.getSelection() != '') {
selection = window.getSelection().toString();
}
text = selection + " " + document.title + " " + location.href;
var b = document.createElement("textarea"), c = document.getSelection();
b.textContent = text, document.body.appendChild(b), c.removeAllRanges(), b.select(), document.execCommand("copy"), c.removeAllRanges(), document.body.removeChild(b)
}
)()
Bookmarklet version:
javascript:( function () { let selection = ""; if (window.getSelection() != '') { selection = window.getSelection().toString(); } text = selection + " " + document.title + " " + location.href; var b = document.createElement("textarea"), c = document.getSelection(); b.textContent = text, document.body.appendChild(b), c.removeAllRanges(), b.select(), document.execCommand("copy"), c.removeAllRanges(), document.body.removeChild(b) } )()
Modified from https://michalparkola.com/roam-bookmarklet.
Convert JavaScript to bookmarklets with http://js.do/blog/bookmarklets/.