// Marker, a bookmarklet for Markdownifying webpage selections // javascript:(function(){var p=document.createElement("p");p.innerHTML="Loading…";p.id="loadingp";p.style.padding="20px";p.style.background="#fff";p.style.left="20px";p.style.top=0;p.style.position="fixed";p.style.zIndex="9999999";p.style.opacity=".85";document.body.appendChild(p);document.body.appendChild(document.createElement("script")).src="https://gist.github.com/ttscoff/8078727/raw/Marker.js?x="+(Math.random());})(); (function () { function callback() { (function ($) { var raw, userSelection; if (window.getSelection) { // W3C Ranges userSelection = window.getSelection (); // Get the range: if (userSelection.getRangeAt) var range = userSelection.getRangeAt (0); else { var range = document.createRange (); range.setStart (userSelection.anchorNode, userSelection.anchorOffset); range.setEnd (userSelection.focusNode, userSelection.focusOffset); } // And the HTML: var clonedSelection = range.cloneContents (); var div = document.createElement ('div'); div.appendChild (clonedSelection); raw = div.innerHTML; } else if (document.selection) { // Explorer selection, return the HTML userSelection = document.selection.createRange (); raw = userSelection.htmlText; } else { raw = ""; } raw = raw.replace(/(src|href)=\"(.*?)\"/g, function(match, p1, p2, offset, string) { if (!/^http/.test(p2)) { if (/^\//.test(p2)) var baselink = window.location.protocol + "//" + window.location.hostname; else var baselink = window.location.href.split("/").slice(0,-1).join("/") + "/"; return [p1,"=\"",baselink+p2,"\""].join(''); } return match; }) var showFrame = "0"; if (window.markerShowFrame !== undefined) { switch (window.markerShowFrame) { case 0: case false: showFrame = "0"; break; default: showFrame = "1"; } } var $form = $("