Last active
June 21, 2020 06:57
-
-
Save Bern3rsH/14b9ae3459300a0bd85e36c8f26b2053 to your computer and use it in GitHub Desktop.
自用 Roam Bookmarklet分享,新建一个书签,粘贴进去即可
This file contains hidden or 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
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