Created
October 27, 2019 03:55
-
-
Save titangene/cd548df45fbde3928b82ef9455b0daf7 to your computer and use it in GitHub Desktop.
Convert Notion's note title and URL to Markdown link format and copy to clipboard
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
urlIconSelector = 'path[d*="M3.73333,3.86667 L7.46667"]'; | |
urlIcons = document.querySelectorAll(urlIconSelector); | |
blocks = Array.prototype.map.call(urlIcons, icon => { | |
urlTitleNode = icon.parentNode.parentNode.nextSibling; | |
if (urlTitleNode.textContent === 'URL') { | |
urlValueNode = urlTitleNode.parentNode.parentNode.parentNode.nextSibling; | |
if (urlValueNode.textContent[0] !== 'Empty') | |
return urlValueNode.querySelector('span'); | |
} | |
}); | |
var textArea = document.createElement('textarea'); | |
copyUrl = blocks[0].textContent; | |
copyText = '[' + document.title + '](' + copyUrl + ')'; | |
textArea.value = copyText; | |
document.body.appendChild(textArea); | |
textArea.select(); | |
document.execCommand('Copy'); | |
textArea.remove(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment