Created
December 9, 2016 09:39
-
-
Save khajavi/db96c052a0e309096d5a421ca4fda29c to your computer and use it in GitHub Desktop.
Copy Titlt and URL in markdown format in clipboard
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
| javascript:(function () { | |
| var text = "[" + document.title + '](' + document.URL + ')'; | |
| if (window.clipboardData && window.clipboardData.setData) { | |
| return clipboardData.setData("Text", text); | |
| } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) { | |
| var textarea = document.createElement("textarea"); | |
| textarea.textContent = text; | |
| textarea.style.position = "fixed"; | |
| document.body.appendChild(textarea); | |
| textarea.select(); | |
| try { | |
| return document.execCommand("copy"); | |
| } catch (ex) { | |
| console.warn("Copy to clipboard failed.", ex); | |
| return false; | |
| } finally { | |
| document.body.removeChild(textarea); | |
| } | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment