Created
December 9, 2019 21:54
-
-
Save xagronaut/4cb3cd9f23e47d144164fba98dad1ffe to your computer and use it in GitHub Desktop.
Use mrcoles.com/bookmarklet tool to convert this to a bookmarklet! It will open a new window with only the page's title as a hyperlink, pre-selected so you can "rich-copy" it to other tools that accept rich HTML formatting. Some credit for the text selection goes to https://stackoverflow.com/users/7173/jason via https://stackoverflow.com/a/98737…
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 linkWin = window.open('about:blank'); linkWin.document.writeln('<html><head><script>function selectText(node) {\nnode = document.getElementById(node);\nif (document.body.createTextRange) {\nconst range = document.body.createTextRange();\nrange.moveToElementText(node);\nrange.select();\n} else if (window.getSelection) {\nconst selection = window.getSelection();\nconst range = document.createRange();\nrange.selectNodeContents(node);\nselection.removeAllRanges();\nselection.addRange(range);\n} else {\nconsole.warn("Could not select text in node: Unsupported browser.");\n}} function closeSelf(){ self.close(); }</script><body><h1 id="link"><a href="' + window.location.href + '">' + (document.querySelector("title") || { innerHTML: window.location.href }).innerHTML + '</a></body></html>'); linkWin.focus(); linkWin.window.document.onkeyup = function(evt) { linkWin.console.log(evt.key + "|" + evt.keyCode + "|" + evt); if (evt.key == "Escape") linkWin.closeSelf(); }; linkWin.window.selectText('link'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment