RoamResearch Bookmarklet

This bookmarklet:

  1. copies whatever text you have selected into the clipboard,
  2. and adds the page title and url
  3. so that you can paste it into your second brain.

This bookmarklet is based on the original Roam bookmarklet from NESSLABS extened using this tip.

Readable


javascript: (
function () {
	let text = "empty";
	if (window.getSelection() != '') {
		text = window.getSelection().toString();
	}
	textWithRef = "%5F%5F" + text + "%5F%5F%20%E2%80%94%20via%20%5B" + document.title + "%5D%28" + location.href + "%29";
	var b = document.createElement("textarea"), c = document.getSelection();
	b.textContent = textWithRef, document.body.appendChild(b), c.removeAllRanges(), b.select(), document.execCommand("copy"), c.removeAllRanges(), document.body.removeChild(b)
}
)()

Minified


javascript:(function(){let e="empty";""!=window.getSelection()&&(e=window.getSelection().toString()),textWithRef="%5F%5F"+e+"%5F%5F%20%E2%80%94%20via%20%5B"+document.title+"%5D%28"+location.href+"%29";var t=document.createElement("textarea"),o=document.getSelection();t.textContent=textWithRef,document.body.appendChild(t),o.removeAllRanges(),t.select(),document.execCommand("copy"),o.removeAllRanges(),document.body.removeChild(t)}();)