Last active
May 23, 2019 23:09
-
-
Save jasonseney/70795a85ea2473e81a916690c3b2a8cc to your computer and use it in GitHub Desktop.
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
| var link = '['+ document.title.replace("[","\\[").replace("]","\\]")+'|'+document.location.href+']'; | |
| if (prompt('Press Enter twice to copy', link)) { | |
| var copy = function(e) { | |
| if (e.code == 'Enter') { | |
| var el = document.createElement('textarea'); | |
| el.value = link; | |
| el.setAttribute('readonly', ''); | |
| el.style.position = 'absolute'; | |
| el.style.left = '-9999px'; | |
| document.body.appendChild(el); | |
| document.getSelection().removeAllRanges(); | |
| el.select(); | |
| document.execCommand('copy'); | |
| document.body.removeChild(el); | |
| } | |
| window.removeEventListener('keydown', copy); | |
| }; | |
| window.addEventListener('keydown', copy); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment