Last active
December 7, 2019 08:05
-
-
Save xilin/fc2ea8bc151f6a9c248733290b629299 to your computer and use it in GitHub Desktop.
copy desc in leetcode for notion
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
var l = getEventListeners(document).copy[0]; | |
document.removeEventListener('copy', l.listener, l.useCapture); | |
// change format so that codes inside `PRE` tag can show correctly in notion | |
for (let strong of [...document.getElementsByTagName('code')].filter(i => i.parentNode.tagName === 'PRE')) { | |
const textNode = document.createElement('span'); | |
textNode.innerHTML = strong.innerHTML; | |
strong.parentNode.replaceChild(textNode, strong); | |
} | |
for (let strong of [...document.getElementsByTagName('strong')].filter(i => i.parentNode.tagName === 'PRE')) { | |
const textNode = document.createElement('span'); | |
textNode.innerHTML = strong.innerHTML; | |
strong.parentNode.replaceChild(textNode, strong); | |
} | |
for (let strong of [...document.getElementsByTagName('em')].filter(i => i.parentNode.tagName === 'PRE')) { | |
const textNode = document.createElement('span'); | |
textNode.innerHTML = strong.innerHTML; | |
strong.parentNode.replaceChild(textNode, strong); | |
} | |
// select© | |
var elem = document.getElementsByClassName('content__1Y2H')[0]; | |
var range = document.createRange(); | |
range.selectNode(elem); | |
getSelection().removeAllRanges(); | |
getSelection().addRange(range); | |
document.execCommand('copy'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment