Skip to content

Instantly share code, notes, and snippets.

@titangene
Created October 27, 2019 03:55
Show Gist options
  • Save titangene/cd548df45fbde3928b82ef9455b0daf7 to your computer and use it in GitHub Desktop.
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
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