Created
June 19, 2019 18:46
-
-
Save tomcritchlow/92ec5f069b5b9bc35cf1fbd7dcbefd1d to your computer and use it in GitHub Desktop.
A bookmarklet for turning selected text into a quote for markdown blogs
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
function getSelectionText() { | |
var text = ""; | |
if (window.getSelection) { | |
text = window.getSelection().toString(); | |
} else if (document.selection && document.selection.type != "Control") { | |
text = document.selection.createRange().text; | |
} | |
return text; | |
} | |
function blogquote() { | |
var title = document.title; | |
var url = document.location; | |
var host = location.hostname; | |
var quote = getSelectionText(); | |
var mdfile = ">"+quote+"\n\nsource: ["+title+"]("+url+")"; | |
prompt("copy",mdfile); | |
} | |
blogquote() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment