Skip to content

Instantly share code, notes, and snippets.

@cori
Last active March 30, 2023 03:50
Show Gist options
  • Save cori/609d4fb67335383253285d7a9ffada49 to your computer and use it in GitHub Desktop.
Save cori/609d4fb67335383253285d7a9ffada49 to your computer and use it in GitHub Desktop.
Roam Quick Capture with Page Title Userscript
// ==UserScript==
// @name Roam Quick Note with Page Title
// @version 0.0.1
// @description Quick notes selected text to Roam.
// @author cori schlegel
// @match *
// @grant GM.registerButton
// @grant GM.openInTab
// @noframes
// ==/UserScript==
(() => {
let selection = '';
document.onselectionchange = () => {
if (!document.getSelection()?.toString()) { return; }
selection = document.getSelection().toString();
};
let text = `[${document.title}](${window.location.href}) - ^^${encodeURIComponent(selection)}^^`;
const callback = () => GM.openInTab(`https://roamresearch.com?text=${text}#quick-capture`);
GM.registerButton('roam-quick-note', 'Quick note to Roam', null, callback);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment