Skip to content

Instantly share code, notes, and snippets.

@p-baleine
Created September 26, 2020 03:43
Show Gist options
  • Save p-baleine/1790ea8354c79b592aca00273ac2ffcf to your computer and use it in GitHub Desktop.
Save p-baleine/1790ea8354c79b592aca00273ac2ffcf to your computer and use it in GitHub Desktop.
org-roam capture script
javascript:(function() {
try {
const maxTitleLength = 52;
const title = document.title.length > maxTitleLength ?
`${document.title.slice(0, maxTitleLength)}...` : document.title;
const href = document.location.href;
const hashFragment = document.location.hash ?
` | ${document.location.hash}` : '';
const text = `${title}${hashFragment}`;
const linkText = `[[${href}][${text}]]`;
navigator.clipboard.writeText(linkText);
} catch (e) {
alert(`Failed to clip org-roam link, ${e}`);
}
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment