Skip to content

Instantly share code, notes, and snippets.

@Bern3rsH
Last active June 21, 2020 06:57
Show Gist options
  • Save Bern3rsH/14b9ae3459300a0bd85e36c8f26b2053 to your computer and use it in GitHub Desktop.
Save Bern3rsH/14b9ae3459300a0bd85e36c8f26b2053 to your computer and use it in GitHub Desktop.
自用 Roam Bookmarklet分享,新建一个书签,粘贴进去即可
javascript:(function(){
var title = document.getElementsByTagName("title")[0].innerHTML;
var url = window.location.href;
var selectText = '';
if (window.getSelection) {
selectText = window.getSelection().toString();
} else if (document.selection) {
selectText = document.selection.createRange().text;
}
var node = document.createElement('textarea');
var selection = document.getSelection();
node.textContent = '__' + selectText + '__' + '[' + title + '](' + url + ')[[to read]]';
document.body.appendChild(node);
selection.removeAllRanges();
node.select();
document.execCommand('copy');
selection.removeAllRanges();
document.body.removeChild(node);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment