Created
June 19, 2015 21:06
-
-
Save admataz/92bc7f98e7b3042f4399 to your computer and use it in GitHub Desktop.
markdown URL bookmarklet
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
| function collectWebItemData() { | |
| var webItem = {}; | |
| var linkTitle = (document.title); | |
| var linkLocation = (window.location); | |
| var selectedText = ''; | |
| if (window.getSelection) { | |
| selectedText = window.getSelection(); | |
| } else if (document.getSelection) { | |
| selectedText = document.getSelection(); | |
| } else if (document.selection) { | |
| selectedText = document.selection.createRange().text; | |
| } | |
| webItem.url = linkLocation.toString(); | |
| webItem.title = linkTitle.toString(); | |
| webItem.content = selectedText.toString(); | |
| return "["+webItem.title+"]("+webItem.url+") - "+webItem.content; | |
| } | |
| window.prompt("link", collectWebItemData() ); | |
| // javascript:function collectWebItemData(){var webItem={};var linkTitle=document.title;var linkLocation=window.location;var selectedText="";if(window.getSelection){selectedText=window.getSelection()}else if(document.getSelection){selectedText=document.getSelection()}else if(document.selection){selectedText=document.selection.createRange().text}webItem.url=linkLocation.toString();webItem.title=linkTitle.toString();webItem.content=selectedText.toString();return"["+webItem.title+"]("+webItem.url+") - "+webItem.content}window.prompt("link",collectWebItemData()); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment