// ==UserScript==
// @name Soylent Upgrade
// @match http://soylentnews.org/submit.pl
// @match https://soylentnews.org/submit.pl
// @match http://soylentnews.org/submit.pl?op=viewsub&subid=*
// @match https://soylentnews.org/submit.pl?op=viewsub&subid=*
// @match http://soylentnews.org/admin.pl
// @match https://soylentnews.org/admin.pl
// @match http://soylentnews.org/admin.pl?op=edit&sid=*
// @match https://soylentnews.org/admin.pl?op=edit&sid=*
// @match http://soylentnews.org/comments.pl*
// ==/UserScript==var simplifyChars = true;
var boxes = document.getElementsByTagName("textarea");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext")
{
var temp = boxes[x].value;
temp = temp.replace(/<\/p><p>/g,"<\/p>\n\n<p>");
temp = temp.replace(/<br>\s?<br>/g,"<\/p>\n\n<p>");
temp = temp.replace(/<\/blockquote><p>/g,"<\/blockquote>\n\n<p>");
temp = temp.replace(/<\/p><blockquote>/g,"<\/p>\n\n<blockquote>");
temp = temp.replace(/<blockquote><div><p>/g,"<blockquote><div>\n\n<p>");
temp = temp.replace(/<\/p><\/div><\/blockquote>/g,"<\/p>\n\n<\/div><\/blockquote>");
temp = temp.replace(/<\/blockquote><blockquote>/g,"<\/blockquote>\n\n<blockquote>");
temp = temp.replace(/<p class="byline">\s/i,"<p class=\"byline\">");
temp = temp.replace(/<p>\s/g,"<p>");
temp = temp.replace(/\s<\/p>/g,"<\/p>");
temp = temp.replace(/<\/li><li>/g,"<\/li>\n<li>");
temp = temp.replace(/<\/li><\/ul>/g,"<\/li>\n<\/ul>");
temp = temp.replace(/<\/p><ul>/g,"<\/p>\n\n<ul>");
temp = temp.replace(/ /g," ");
if (simplifyChars)
{
temp = temp.replace(/\u2018/g,"'");
temp = temp.replace(/\u2019/g,"'");
temp = temp.replace(/\u201C/g,"\"");
temp = temp.replace(/\u201D/g,"\"");
temp = temp.replace(/\u2026/g,"..."); // ellipsis
}
boxes[x].value = temp;
boxes[x].rows = 32;
}
var toolbar = document.createElement("div");
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Blockquote");
tempbutton.setAttribute("onmousedown","addBlockquote(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
boxes[x].parentNode.insertBefore(toolbar, boxes[x].nextSibling);
}var temp = document.createElement("script");
temp.appendChild(document.createTextNode("function addBlockquote(area) { var sel = getSelection(); if (sel.length != 0) { area.value = area.value.replace(sel,'<blockquote>'+sel+'<\/blockquote>'); } }"));
document.getElementsByTagName('head')[0].appendChild(temp);function getSelection() {
return (!!document.getSelection) ? document.getSelection() :
(!!window.getSelection) ? window.getSelection() :
document.selection.createRange().text;
}
(Score: 2) by takyon on Thursday May 14 2015, @11:48PM
Send me feature requests and bugs on here and IRC, I will be adding more over time.
[SIG] 10/28/2017: Soylent Upgrade v14 [soylentnews.org]