-
-
Save tzarskyz/6110176 to your computer and use it in GitHub Desktop.
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 () { | |
function callback() { | |
(function ($) { | |
var jQuery = $; | |
$("#loadingp").fadeOut("fast", function () { | |
$(this).remove(); | |
}); | |
var selectMarkdown = function () { | |
var doc = document, | |
text = doc.getElementById("fymdoutput"), | |
range, selection; | |
if (doc.body.createTextRange) { | |
range = doc.body.createTextRange(); | |
range.moveToElementText(text); | |
range.select(); | |
} else if (window.getSelection) { | |
selection = window.getSelection(); | |
range = doc.createRange(); | |
range.selectNodeContents(text); | |
selection.removeAllRanges(); | |
selection.addRange(range); | |
} | |
}, collection = []; | |
$("div,table,article,section,aside").on("mouseover mouseout click", function (a) { | |
a.type === "mouseover" ? $(this).css({ | |
outline: "1px solid rgb(194, 130, 148)" | |
}).addClass("mkhovered") : $("div,table,article,section,aside").css({ | |
outline: "none" | |
}).removeClass("mkhovered"); | |
if (a.type === "click") { | |
a.preventDefault(); | |
$(".mkhovered").css({ | |
outline: "none" | |
}).removeClass("mkhovered"); | |
var $container = $(this); | |
var baselink = window.location.protocol + "//" + window.location.hostname; | |
$container.find('a[href*="twitter.com/intent"],a[href*="app.net/intent"]').remove(); | |
$container.find('a[href^="/"],img[src^="/"]').each(function(){ | |
var $el = $(this), attr = $el.tagName == "A" ? "href" : "src"; | |
$el.attr(attr, baselink + $el.attr(attr)); | |
}); | |
var $form = $("<form>").attr("method", "post").attr("action", "http://heckyesmarkdown.com/go/?callback=?") | |
.append($("<input name=html>").val($container.html())) | |
.append($("<input name=read>").val("0")) | |
.append($("<input name=output>").val("md")) | |
.append($("<input name=showframe>").val("1")); | |
$form.submit(); | |
} | |
}) | |
})(jQuery.noConflict(true)) | |
} | |
var s = document.createElement("script"); | |
s.src = "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"; | |
if (s.addEventListener) { | |
s.addEventListener("load", callback, false) | |
} else if (s.readyState) { | |
s.onreadystatechange = callback | |
} | |
document.body.appendChild(s); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment