Last active
March 30, 2023 03:50
-
-
Save cori/609d4fb67335383253285d7a9ffada49 to your computer and use it in GitHub Desktop.
Roam Quick Capture with Page Title Userscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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