Created
May 2, 2013 17:49
-
-
Save boxmein/5503985 to your computer and use it in GitHub Desktop.
The Powder Toy forum now supports Markdown input!
(Not all tags supported. Be wary of speed death.)
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
// ==UserScript== | |
// @id powdertoy.co.uk-f7ac10f4-5ccd-4504-94e8-60ac371ac11a@boxmein.web44.net | |
// @name TPT Markdown inputs | |
// @version 1.1.2 | |
// @namespace boxmein.web44.net | |
// @author boxmein | |
// @description Makes an addition to TPT forum's comment text box for a 'semi-WYSIWYG' textbox via Markdown. Some tags might not work! | |
// @include http://powdertoy.co.uk/* | |
// @run-at document-end | |
// ==/UserScript== | |
// Needed for Markdown.js | |
var markdownjs = document.createElement("script"); | |
markdownjs.src = "http://boxmein.web44.net/rnd/markdown.js"; | |
document.body.appendChild(markdownjs); | |
// Needed for the script to work. | |
var js = document.createElement("script"); | |
// Ugh, script injection | |
js.innerHTML = | |
" var newtext = document.createElement('div'), refreshing = 10; "+ | |
" newtext.id = 'liveprev_f7ac10f4'; "+ | |
" newtext.style = 'background-color: white; border-color: #F0F0F0; width: 770px; height: 150px; margin: 3px; border-radius: 3px; overflow: scroll;';" + | |
" function insertAfter(referenceNode, newNode) { console.log('appending...'); referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); }" + | |
" insertAfter(document.getElementById('AddReplyMessage'), newtext);" + | |
" document.getElementById('AddReplyMessage').onkeyup = function() { refreshing = 10; }; " + | |
" setInterval(function() { if (refreshing > 0) { refreshing -= 1; document.getElementById('liveprev_f7ac10f4').innerHTML = markdown.toHTML(document.getElementById('AddReplyMessage').value)} }, 1000); "; | |
document.body.appendChild(js); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment