// ==UserScript==
// @name Soylent Upgrade
// @match http://soylentnews.org/*article.pl*
// @match https://soylentnews.org/*article.pl*
// @match http://soylentnews.org/submit.pl*
// @match https://soylentnews.org/submit.pl*
// @match http://soylentnews.org/admin.pl*
// @match https://soylentnews.org/admin.pl*
// @match http://soylentnews.org/*comments.pl*
// @match https://soylentnews.org/*comments.pl*
// @match http://soylentnews.org/journal.pl*
// @match https://soylentnews.org/journal.pl*
// ==/UserScript==// User Options:
var simplifyChars = true; // Change to false if you don't want stylized quotation marks, ellipses, etc. to be replaced
var stripEmail = false; // Remove auto-filled email from submission// End User Options
/* ! http://mths.be/fromcodepoint v0.1.0 by @mathias */
if (!String.fromCodePoint) { (function() { var defineProperty = (function() { try { var object = {}; var $defineProperty = Object.defineProperty; var result = $defineProperty(object, object, object) && $defineProperty; } catch(error) {} return result; }()); var stringFromCharCode = String.fromCharCode; var floor = Math.floor; var fromCodePoint = function() { var MAX_SIZE = 0x4000; var codeUnits = []; var highSurrogate; var lowSurrogate; var index = -1; var length = arguments.length; if (!length) { return ''; } var result = ''; while (++index < length) { var codePoint = Number(arguments[index]); if ( !isFinite(codePoint) || codePoint < 0 || codePoint > 0x10FFFF || floor(codePoint) != codePoint ) { throw RangeError('Invalid code point: ' + codePoint); } if (codePoint <= 0xFFFF) { codeUnits.push(codePoint); } else { codePoint -= 0x10000; highSurrogate = (codePoint >> 10) + 0xD800; lowSurrogate = (codePoint % 0x400) + 0xDC00; codeUnits.push(highSurrogate, lowSurrogate); } if (index + 1 == length || codeUnits.length > MAX_SIZE) { result += stringFromCharCode.apply(null, codeUnits); codeUnits.length = 0; } } return result; }; if (defineProperty) { defineProperty(String, 'fromCodePoint', { 'value': fromCodePoint, 'configurable': true, 'writable': true }); } else { String.fromCodePoint = fromCodePoint; } }()); }// Add "Quote This" buttons to all initially visible comments
var spans = document.getElementsByTagName("span");
for (var x=0; x<spans.length; x++)
{
if (spans[x].id.indexOf("reply_link_")==0)
{
var button = document.createElement("span");
button.setAttribute("class","nbutton");
var p = document.createElement("p");
var b = document.createElement("b");
var a = document.createElement("a");
// Set the href of the "Quote This" button to the href of the "Reply to This" button, with the escaped contents of the post added to URL and any [domain.names] following links in the post cut out:
a.setAttribute("href",spans[x].getElementsByTagName("a")[0].href.replace("#post_comment","&postercomment="+escape("<blockquote>"+document.getElementById("comment_body_"+spans[x].id.replace("reply_link_","")).innerHTML.replace(/<\/a>\s\[.*?\..*?\]/g,"<\/a>")+"<\/blockquote>\n\n")+"#post_comment"));
// To Do: Shorten URLs longer than 2000 characters
a.appendChild(document.createTextNode("Quote This"));
b.appendChild(a);
p.appendChild(b);
button.appendChild(p);
spans[x].parentNode.insertBefore(button, spans[x].nextSibling);
spans[x].parentNode.insertBefore(document.createTextNode(" "), spans[x].nextSibling); // Divider
}
}if (stripEmail && window.location.href.search(/http(s)?\:\/\/soylentnews\.org\/submit\.pl/)!=-1) // Empty email input area, but only on submission page
{
var boxes = document.getElementsByTagName("input");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "email")
{
boxes[x].value = "";
}
}
}// Add title case button next to title/subj field on Story Submissions, Submission Preview, and Story Preview
if (window.location.href.search(/http(s)?\:\/\/soylentnews\.org\/(submit|admin)\.pl/)!=-1)
{
var boxes = document.getElementsByTagName("input");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "title" || boxes[x].name == "subj")
{
boxes[x].id = "storyTitle";
var button = document.createElement("input");
button.setAttribute("type","button");
button.setAttribute("value","Title Case");
button.setAttribute("title","Convert title to title case.");
button.setAttribute("onclick","document.getElementById('storyTitle').value=document.getElementById('storyTitle').value.replace(/\\b([a-z])/gi,function(m, p1){return p1.toUpperCase();}).replace(/\\b(at|of|is|and|to|in|by|as|its|be|the|on|a|an|but|or|for)\\b/gi,function(m, p1){return p1.toLowerCase();}).replace(/^([a-z])/gi,function(m, p1){return p1.toUpperCase();}).replace(/:\\s([a-z])/gi,function(m, p1){return ': '+p1.toUpperCase();}).replace(/\\bx(86|64)\\b/gi,'x$1');");
boxes[x].parentNode.insertBefore(button, boxes[x].nextSibling);
if (window.location.href.search(/http(s)?\:\/\/soylentnews\.org\/admin\.pl/)!=-1 || boxes[x].name == "subj")
{
boxes[x].parentNode.insertBefore(document.createElement("br"), boxes[x].nextSibling);
}
else
{
boxes[x].parentNode.insertBefore(document.createTextNode(" "), boxes[x].nextSibling);
}
}
}
}var boxes = document.getElementsByTagName("textarea");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var temp = boxes[x].value; // Retrieve textarea contents
temp = temp.replace(/<\/p><p>/g,"<\/p>\n\n<p>"); // Add newlines between paragraphs
temp = temp.replace(/<br>\s?<br>/g,"<\/p>\n\n<p>"); // Convert double break tags to paragraph tags
temp = temp.replace(/<\/blockquote><p>/g,"<\/blockquote>\n\n<p>"); // Add newlines after blockquotes
temp = temp.replace(/<\/p><blockquote>/g,"<\/p>\n\n<blockquote>"); // Add newlines before blockquotes
temp = temp.replace(/<blockquote><div><p>/g,"<blockquote><div>\n\n<p>"); // Add newlines within start of blockquotes
temp = temp.replace(/<\/p><\/div><\/blockquote>/g,"<\/p>\n\n<\/div><\/blockquote>"); // Add newlines within end of blockquotes
temp = temp.replace(/<\/blockquote><blockquote>/g,"<\/blockquote>\n\n<blockquote>"); // Add newlines between two blockquotes
temp = temp.replace(/<p class="byline">\s/i,"<p class=\"byline\">"); // Remove extra space from byline
temp = temp.replace(/<p>\s/g,"<p>"); // Remove extra space from start of paragraph
temp = temp.replace(/\s<\/p>/g,"<\/p>"); // Remove extra space from end of paragraph
temp = temp.replace(/<\/li><li>/g,"<\/li>\n<li>"); // Add newlines between list items
temp = temp.replace(/(<\/li>)(<\/[u|o]l>)/g,'$1\n$2'); // Add newline after last list item
temp = temp.replace(/(<\/p>)(<[u|o]l>)/g,'$1\n$2'); // Add newlines before lists
temp = temp.replace(/<p>\[...\]/g,"<p>[...] "); // Add space within beginning of foreshortened paragraph
while (temp.indexOf(" ")!=-1)
{
temp = temp.replace(/ /g," "); // Replace double spaces with single spaces
}
if (simplifyChars)
{
temp = temp.replace(/\u2018/g,"'"); // 'LEFT SINGLE QUOTATION MARK' (U+2018) to (U+0027)
temp = temp.replace(/\u2019/g,"'"); // 'RIGHT SINGLE QUOTATION MARK' (U+2019) to (U+0027)
temp = temp.replace(/\u201C/g,"\""); // 'LEFT DOUBLE QUOTATION MARK' (U+201C) to (U+0022)
temp = temp.replace(/\u201D/g,"\""); // 'RIGHT DOUBLE QUOTATION MARK' (U+201D) to (U+0022)
temp = temp.replace(/\u2026/g,"..."); // 'HORIZONTAL ELLIPSIS' (U+2026) to (U+002E) x3
}
boxes[x].value = temp;
boxes[x].rows = 32; // Expand textarea height to 32 rows
}
var toolbar = document.createElement("div");// Blockquote button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Blockquote");
tempbutton.setAttribute("title","Wrap \u003Cblockquote\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addBlockquote(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Paragraph and Line break buttons
var tempspan = document.createElement("span");
tempspan.setAttribute("id","htmlFormatButtons");
if (document.getElementById("posttype") && document.getElementById("posttype").selectedIndex == 0)
{
tempspan.setAttribute("style","display:none;"); // Hide if initial post type option is "Plain Old Text"
}
if (document.getElementById("posttype"))
{
document.getElementById("posttype").addEventListener("change", function() {if (document.getElementById('posttype').selectedIndex == 0) {document.getElementById('htmlFormatButtons').style.display = 'none'} else {document.getElementById('htmlFormatButtons').style.display = 'inline'}}); // Change visibility of these buttons based on value of post type
}
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","P");
tempbutton.setAttribute("title","Wrap \u003Cp\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addPara(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","BR");
tempbutton.setAttribute("title","Insert a line break.");
tempbutton.setAttribute("onclick","addBreak(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);// HR button, if editing a story
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","HR");
tempbutton.setAttribute("title","Insert a horizontal rule.");
tempbutton.setAttribute("style","text-decoration:underline overline;");
tempbutton.setAttribute("onclick","addHRule(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);
}// URL button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","URL");
tempbutton.setAttribute("title","Create a hyperlink around the selected text.");
tempbutton.setAttribute("style","text-decoration:underline;");
tempbutton.setAttribute("onclick","addHyperlink(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));// Bold button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","B");
tempbutton.setAttribute("title","Bold");
tempbutton.setAttribute("style","font-weight:bold;");
tempbutton.setAttribute("onclick","addBold(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Italic button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","I");
tempbutton.setAttribute("title","Italic");
tempbutton.setAttribute("style","font-style:italic;");
tempbutton.setAttribute("onclick","addItalic(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Strike button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","S");
tempbutton.setAttribute("title","Strikethrough");
tempbutton.setAttribute("style","text-decoration:line-through;");
tempbutton.setAttribute("onclick","addStrike(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Code button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Code");
tempbutton.setAttribute("title","Wrap \u003Cecode\u003E tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addEcode(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Teletype button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","TT");
tempbutton.setAttribute("title","Wrap \u003Ctt\u003E (teletype, i.e. monospace) tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addTT(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Small button, if editing a story
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u0073\u1D0D\u1D00\u029F\u029F");
tempbutton.setAttribute("title","Wrap \u003Csmall\u003E tags around the selected text.");
// tempbutton.setAttribute("style","font-size:75%;");
tempbutton.setAttribute("onclick","addSmall(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
}toolbar.appendChild(document.createTextNode(" ")); // Divider
// Superscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u00B2");
tempbutton.setAttribute("title","Superscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSuper(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Subscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u2082");
tempbutton.setAttribute("title","Subscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSubsc(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Ordered list button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","1. List");
tempbutton.setAttribute("title","Insert an ordered list or convert newline-separated text into an ordered list.");
tempbutton.setAttribute("onclick","addOrdlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Unordered list button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u2022 List");
tempbutton.setAttribute("title","Insert an unordered list or convert newline-separated text into an unordered list.");
tempbutton.setAttribute("onclick","addUnordlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createElement("br")); // Divider
// Create 7 macro buttons
for (var i=1; i<=7; i++)
{
// Create macros if they don't exist
if(!localStorage.getItem("soymacro"+i))
{
localStorage.setItem("soymacro"+i,JSON.stringify(["M"+i,"string","Sample Text"]));
//localStorage.setItem("soymacro"+i,JSON.stringify(["M"+i,"regexp","/a/gi","b"]));
}
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("id","soymacros"+x+"button"+i);
tempbutton.setAttribute("value",JSON.parse(localStorage.getItem("soymacro"+i))[0]);
if (JSON.parse(localStorage.getItem("soymacro"+i))[1]=="string")
{
if (JSON.parse(localStorage.getItem("soymacro"+i))[2].length < 40)
{
tempbutton.setAttribute("title","Insert or replace selected text with: " + JSON.parse(localStorage.getItem("soymacro"+i))[2]);
}
else
{
tempbutton.setAttribute("title","Insert or replace selected text with: " + JSON.parse(localStorage.getItem("soymacro"+i))[2].substring(0,40)+"...");
}
tempbutton.setAttribute("onclick","macroChoose(document.getElementsByTagName('textarea')["+x+"],"+i+");");
}
else
{
tempbutton.setAttribute("title","Replace text matched by the regular expression: " + JSON.parse(localStorage.getItem("soymacro"+i))[2] + " with: " + JSON.parse(localStorage.getItem("soymacro"+i))[3]);
tempbutton.setAttribute("onclick","macroChoose(document.getElementsByTagName('textarea')["+x+"],"+i+");");
}
toolbar.appendChild(tempbutton);
}
// Create macros edit button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Edit");
tempbutton.setAttribute("title","Configure user macros or discard changes.");
tempbutton.setAttribute("onclick","if (document.getElementById('macrobar"+x+"').style.display == 'none') {document.getElementById('macrobar"+x+"').style.display = 'block'; macrobarInit("+x+");} else {document.getElementById('macrobar"+x+"').style.display = 'none'; if (p = document.getElementById('postercomment')) { var x = p.offsetTop; while (p = p.offsetParent) {x += p.offsetLeft;} window.scrollTo(0,x-75);}}");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createElement("br")); // Divider
// Despace button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Despace");
tempbutton.setAttribute("title","Delete newlines within the selection.");
tempbutton.setAttribute("onclick","despace(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Symbol button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value",":-)");
tempbutton.setAttribute("title","Insert a symbol.");
tempbutton.setAttribute("onclick","if (document.getElementById('smilebar"+x+"').style.display == 'none') {document.getElementById('smilebar"+x+"').style.display = 'block'} else {document.getElementById('smilebar"+x+"').style.display = 'none'; if (p = document.getElementById('postercomment')) { var x = p.offsetTop; while (p = p.offsetParent) {x += p.offsetLeft;} window.scrollTo(0,x-75); } }");
toolbar.appendChild(tempbutton);
boxes[x].parentNode.insertBefore(toolbar, boxes[x].nextSibling);// Symbol list
var smilebar = document.createElement("div");
smilebar.setAttribute("style","-moz-user-select:none; -webkit-user-select:none; display:none; font-size:16pt; max-height:240px; overflow:auto; padding:0.5em;");
smilebar.setAttribute("id","smilebar"+x);
var smiles = ["\u0026amp;","\u0026lt;","\u0026gt;"];var codes = [[161,169],[171,172],[174],[176,177],[180,183],[187,191],[215],[224,255],[402],[629],[632],[916],[920],[931],[934],[937],[945,946],[956],[960],[963],[8216,8221],[8226],[8230],[8251],[8364],[8478],[8482],[8528,8542],[8585],[8592,8652],[8712,8716],[8721],[8730],[8733,8734],[8736],[8743,8749],[8756,8757],[8773],[8776],[8800,8805],[8834,8837],[8984],[9760],[9762,9765],[9770],[9773,9775],[9784,9794],[9812,9831],[9833,9842],[9850],[9855,9861],[9874,9877],[9882,9885],[9888,9893],[9913],[9940],[9962],[9971],[9981],[9992,10087],[65533],[127744,127756],[127759],[127775,127776],[127797],[127801],[127804,127812],[127817],[127820,127822],[127828,127831],[127838,127839],[127843],[127849],[127855],[127860,127867],[127891],[127904,127911],[127918],[127939],[127942],[127977],[128025],[128074,128078],[128123,128131],[128137,128142],[128148,128150],[128152],[128158],[128161,128164],[128168,128170],[128172],[128176,128177],[128187],[128189,128190],[128193,128194],[128197],[128203,128204],[128206],[128214],[128225,128227],[128231,128233],[128241],[128244],[128246],[128250,128252],[128259],[128266,128270],[128273,128276],[128278,128280],[128286],[128293,128299],[128302,128303],[128509,128510],[128659],[128684,128685]];
for (var i=0; i<codes.length; i++) { if (codes[i].length > 1) { for (var j=codes[i][0]; j<=codes[i][1]; j++) { smiles[smiles.length] = String.fromCodePoint(j); } } else { smiles[smiles.length] = String.fromCodePoint(codes[i][0]); } } // Populate smiles array with code ranges converted to individual characters
smiles = smiles.concat(["xD",":-)",":^)","(^_^;)","\u0028\u00A0\u0361\u00B0\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029","\u0028\u00A0\u0361\u007E\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029\uFEFF","\u00AF\u005C\u005F\u0028\u30C4\u0029\u005F\u002F\u00AF","\u0028\u256F\u00B0\u25A1\u00B0\uFF09\u256F\uFE35\u00A0\u253B\u2501\u253B","\u0028\u30CE\u0CA0\u76CA\u0CA0\u0029\u30CE\u5F61\u253B\u2501\u253B","\u0028\u0060\uFF65\u03C9\uFF65\u00B4\u0029","\u0CA0_\u0CA0","\u0295\u2022\u1D25\u2022\u0294","\u0028\u3065\uFFE3\u00A0\u00B3\uFFE3\u0029\u3065","\u0669\u0028\u204E\u275B\u1D17\u275B\u204E\u0029\u06F6","\u30FD\u0F3C\u0E88\u0644\u035C\u0E88\u0F3D\uFF89"]); // Add in arbitrary emoticons
for (var i=0; i<smiles.length; i++)
{
var smile = document.createElement("span");
smile.setAttribute("style","cursor:pointer; padding:2px; white-space:nowrap;");
smile.setAttribute("onclick","addSmile(document.getElementsByTagName('textarea')["+x+"],'"+smiles[i].replace("\u005C","\u005C\u005C")+"');");
smile.appendChild(document.createTextNode(smiles[i]));
smilebar.appendChild(smile);
if (i+1<smiles.length)
{
smilebar.appendChild(document.createTextNode(" "));
}
}
toolbar.parentNode.insertBefore(smilebar, toolbar.nextSibling);// Create macro configuration interface
var macrobar = document.createElement("div");
macrobar.setAttribute("style","display:none; padding:0.5em;");
macrobar.setAttribute("id","macrobar"+x);
var table = document.createElement("table");
var tr = document.createElement("tr");
var th = document.createElement("th");
th.appendChild(document.createTextNode("Name"));
tr.appendChild(th);
var th = document.createElement("th");
th.appendChild(document.createTextNode("Type"));
tr.appendChild(th);
var th = document.createElement("th");
th.appendChild(document.createTextNode("String | Expression"));
tr.appendChild(th);
var th = document.createElement("th");
th.setAttribute("title","Only used with expressions. Parenthesized substring matches (e.g. '$1') can be used.");
th.setAttribute("style","cursor:help;");
th.appendChild(document.createTextNode("Expression Replace"));
tr.appendChild(th);
table.appendChild(tr);
for (var i=1; i<=7; i++)
{
var tr = document.createElement("tr");// Macro name
var td = document.createElement("td");
var name = document.createElement("input");
name.setAttribute("type","text");
name.setAttribute("id","soymacros"+x+"name"+i);
td.appendChild(name);
tr.appendChild(td);// Macro type
var td = document.createElement("td");
var rad = document.createElement("input");
rad.setAttribute("type","radio");
rad.setAttribute("name","soymacros"+x+"type"+i);
rad.setAttribute("id","soymacros"+x+"type"+i+"S");
td.appendChild(rad);
td.appendChild(document.createTextNode(" String "));
var rad = document.createElement("input");
rad.setAttribute("type","radio");
rad.setAttribute("name","soymacros"+x+"type"+i);
rad.setAttribute("id","soymacros"+x+"type"+i+"E");
td.appendChild(rad);
td.appendChild(document.createTextNode(" Expression "));
tr.appendChild(td);// Field A
var td = document.createElement("td");
var f1 = document.createElement("input");
f1.setAttribute("type","text");
f1.setAttribute("id","soymacros"+x+"fieldA"+i);
td.appendChild(f1);
tr.appendChild(td);// Field B
var td = document.createElement("td");
var f1 = document.createElement("input");
f1.setAttribute("type","text");
f1.setAttribute("id","soymacros"+x+"fieldB"+i);
td.appendChild(f1);
tr.appendChild(td);table.appendChild(tr);
}
macrobar.appendChild(table);var p = document.createElement("p");
var save = document.createElement("input");
save.setAttribute("type","button");
save.setAttribute("value","Save");
save.setAttribute("title","Save any edits to the macro configuration.");
save.setAttribute("onclick","macrobarSave("+x+");");
p.appendChild(save);
p.appendChild(document.createTextNode(" "));
var guide = document.createElement("a");
guide.setAttribute("href","https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions");
guide.setAttribute("target","_blank");
guide.appendChild(document.createTextNode("Regexp Guide"));
p.appendChild(guide);
macrobar.appendChild(p);toolbar.parentNode.insertBefore(macrobar, toolbar.nextSibling);
}var temp = document.createElement("script");
// Add selection handling function
temp.appendChild(document.createTextNode("function getSelection(textarea) { if ('selectionStart' in textarea) { if (textarea.selectionStart != textarea.selectionEnd) { return [textarea.selectionStart,textarea.selectionEnd]; } } } "));// Add comment formatting buttons
temp.appendChild(document.createTextNode("function addBlockquote(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<blockquote>'+area.value.substring(sel[0],sel[1])+'<\/blockquote>' + area.value.substring(sel[1]); } } function addPara(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<p>'+area.value.substring(sel[0],sel[1])+'<\/p>' + area.value.substring(sel[1]); } } function addBreak(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<br>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHRule(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<hr>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHyperlink(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { url = prompt('URL:', 'https://'); area.value = area.value.substring(0,sel[0]) + '<a href=\"'+url+'\">'+area.value.substring(sel[0],sel[1])+'<\/a>' + area.value.substring(sel[1]); } } function addBold(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<b>'+area.value.substring(sel[0],sel[1])+'<\/b>' + area.value.substring(sel[1]); } } function addItalic(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<em>'+area.value.substring(sel[0],sel[1])+'<\/em>' + area.value.substring(sel[1]); } } function addStrike(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<strike>'+area.value.substring(sel[0],sel[1])+'<\/strike>' + area.value.substring(sel[1]); } } function addEcode(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<ecode>'+area.value.substring(sel[0],sel[1])+'<\/ecode>' + area.value.substring(sel[1]); } } function addTT(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<tt>'+area.value.substring(sel[0],sel[1])+'<\/tt>' + area.value.substring(sel[1]); } } function addSmall(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<small>'+area.value.substring(sel[0],sel[1])+'<\/small>' + area.value.substring(sel[1]); } } function addSuper(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sup>'+area.value.substring(sel[0],sel[1])+'<\/sup>' + area.value.substring(sel[1]); } } function addSubsc(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sub>'+area.value.substring(sel[0],sel[1])+'<\/sub>' + area.value.substring(sel[1]); } } "));// Add list creation functions
temp.appendChild(document.createTextNode("function addOrdlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ol><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>').replace(/\\n<li><\\/li>/g,'') + '<\/li><\/ol>' + area.value.substring(area.selectionEnd); } else { temp = '<ol>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>\\n'; } area.value = area.value.substring(0,area.selectionStart) + temp.substring(0,temp.length-1) + '<\/ol>' + area.value.substring(area.selectionStart); } } } function addUnordlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ul><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>').replace(/\\n<li><\\/li>/g,'') + '<\/li><\/ul>' + area.value.substring(area.selectionEnd); } else { temp = '<ul>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>\\n'; } area.value = area.value.substring(0,area.selectionStart) + temp.substring(0,temp.length-1) + '<\/ul>' + area.value.substring(area.selectionStart); } } }"));// Add macro functions
temp.appendChild(document.createTextNode("function macroChoose(area,x) { if (JSON.parse(localStorage.getItem('soymacro'+x))[1]=='string') { macroString(area,x); } else { macroRegexp(area,x); } }"));
temp.appendChild(document.createTextNode("function macroString(area,x) { var sel = getSelection(area); if (sel && sel[0] != sel[1]) { area.value = area.value.substring(0,sel[0]) + JSON.parse(localStorage.getItem('soymacro'+x))[2] + area.value.substring(sel[1]); } else if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + JSON.parse(localStorage.getItem('soymacro'+x))[2] + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+JSON.parse(localStorage.getItem('soymacro'+x))[2].length,pos+JSON.parse(localStorage.getItem('soymacro'+x))[2].length); } }"));
temp.appendChild(document.createTextNode("function macroRegexp(area,x) { var sel = getSelection(area); if (sel && sel[0] != sel[1]) { var reg = JSON.parse(localStorage.getItem('soymacro'+x))[2]; area.value = area.value.substring(0,sel[0]) + area.value.substring(sel[0],sel[1]).replace(new RegExp(reg.substring(reg.indexOf('/')+1,reg.lastIndexOf('/')), reg.substring(reg.lastIndexOf('/')+1)),JSON.parse(localStorage.getItem('soymacro'+x))[3]) + area.value.substring(sel[1]); } }"));
temp.appendChild(document.createTextNode("function macrobarInit(x) { for (var y=1; y<=7; y++) { document.getElementById('soymacros'+x+'name'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[0]; if (JSON.parse(localStorage.getItem('soymacro'+y))[1]=='string') { document.getElementById('soymacros'+x+'type'+y+'S').checked = true; } else { document.getElementById('soymacros'+x+'type'+y+'E').checked = true; } document.getElementById('soymacros'+x+'fieldA'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[2]; if (JSON.parse(localStorage.getItem('soymacro'+y))[1]!='string') { document.getElementById('soymacros'+x+'fieldB'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[3]; } else { document.getElementById('soymacros'+x+'fieldB'+y).value = ''; } } }"));
temp.appendChild(document.createTextNode("function macrobarSave(x) { for (var y=1; y<=7; y++) { if (document.getElementById('soymacros'+x+'type'+y+'S').checked == true) { localStorage.setItem('soymacro'+y,JSON.stringify([document.getElementById('soymacros'+x+'name'+y).value,'string',document.getElementById('soymacros'+x+'fieldA'+y).value])); } else { localStorage.setItem('soymacro'+y,JSON.stringify([document.getElementById('soymacros'+x+'name'+y).value,'regexp',document.getElementById('soymacros'+x+'fieldA'+y).value,document.getElementById('soymacros'+x+'fieldB'+y).value])); } } document.getElementById('macrobar'+x).style.display = 'none'; var boxes = document.getElementsByTagName('textarea'); for (var z=0; z<boxes.length; z++) { for (var y=1; y<=7; y++) { document.getElementById('soymacros'+z+'button'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[0]; if (JSON.parse(localStorage.getItem('soymacro'+y))[1]=='string') { if (JSON.parse(localStorage.getItem('soymacro'+y))[2].length < 40) { document.getElementById('soymacros'+z+'button'+y).title = 'Insert or replace selected text with: ' + JSON.parse(localStorage.getItem('soymacro'+y))[2]; } else { document.getElementById('soymacros'+z+'button'+y).title = 'Insert or replace selected text with: ' + JSON.parse(localStorage.getItem('soymacro'+y))[2].substring(0,40)+'...'; } } else { document.getElementById('soymacros'+z+'button'+y).title = 'Replace text matched by the regular expression: ' + JSON.parse(localStorage.getItem('soymacro'+y))[2] + ' with: ' + JSON.parse(localStorage.getItem('soymacro'+y))[3]; } } } }"));// Add despace function
temp.appendChild(document.createTextNode("function despace(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + area.value.substring(sel[0],sel[1]).replace(/\\r/g,' ').replace(/\\n/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ') + area.value.substring(sel[1]); } }"));// Add unicode insertion function
temp.appendChild(document.createTextNode("function addSmile(area, smile) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,pos) + smile + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+smile.length,pos+smile.length) } }"));document.getElementsByTagName('head')[0].appendChild(temp); // Add script to page
// ==UserScript==
// @name Soylent Upgrade
// @match http://soylentnews.org/*article.pl*
// @match https://soylentnews.org/*article.pl*
// @match http://soylentnews.org/submit.pl*
// @match https://soylentnews.org/submit.pl*
// @match http://soylentnews.org/admin.pl*
// @match https://soylentnews.org/admin.pl*
// @match http://soylentnews.org/*comments.pl*
// @match https://soylentnews.org/*comments.pl*
// @match http://soylentnews.org/journal.pl*
// @match https://soylentnews.org/journal.pl*
// ==/UserScript==// User Options:
var simplifyChars = true; // Change to false if you don't want stylized quotation marks, ellipses, etc. to be replaced
var stripEmail = false; // Remove auto-filled email from submission// End User Options
/* ! http://mths.be/fromcodepoint v0.1.0 by @mathias */
if (!String.fromCodePoint) { (function() { var defineProperty = (function() { try { var object = {}; var $defineProperty = Object.defineProperty; var result = $defineProperty(object, object, object) && $defineProperty; } catch(error) {} return result; }()); var stringFromCharCode = String.fromCharCode; var floor = Math.floor; var fromCodePoint = function() { var MAX_SIZE = 0x4000; var codeUnits = []; var highSurrogate; var lowSurrogate; var index = -1; var length = arguments.length; if (!length) { return ''; } var result = ''; while (++index < length) { var codePoint = Number(arguments[index]); if ( !isFinite(codePoint) || codePoint < 0 || codePoint > 0x10FFFF || floor(codePoint) != codePoint ) { throw RangeError('Invalid code point: ' + codePoint); } if (codePoint <= 0xFFFF) { codeUnits.push(codePoint); } else { codePoint -= 0x10000; highSurrogate = (codePoint >> 10) + 0xD800; lowSurrogate = (codePoint % 0x400) + 0xDC00; codeUnits.push(highSurrogate, lowSurrogate); } if (index + 1 == length || codeUnits.length > MAX_SIZE) { result += stringFromCharCode.apply(null, codeUnits); codeUnits.length = 0; } } return result; }; if (defineProperty) { defineProperty(String, 'fromCodePoint', { 'value': fromCodePoint, 'configurable': true, 'writable': true }); } else { String.fromCodePoint = fromCodePoint; } }()); }// Add "Quote This" buttons to all initially visible comments
var spans = document.getElementsByTagName("span");
for (var x=0; x<spans.length; x++)
{
if (spans[x].id.indexOf("reply_link_")==0)
{
var button = document.createElement("span");
button.setAttribute("class","nbutton");
var p = document.createElement("p");
var b = document.createElement("b");
var a = document.createElement("a");
// Set the href of the "Quote This" button to the href of the "Reply to This" button, with the escaped contents of the post added to URL and any [domain.names] following links in the post cut out:
a.setAttribute("href",spans[x].getElementsByTagName("a")[0].href.replace("#post_comment","&postercomment="+escape("<blockquote>"+document.getElementById("comment_body_"+spans[x].id.replace("reply_link_","")).innerHTML.replace(/<\/a>\s\[.*?\..*?\]/g,"<\/a>")+"<\/blockquote>\n\n")+"#post_comment"));
// To Do: Shorten URLs longer than 2000 characters
a.appendChild(document.createTextNode("Quote This"));
b.appendChild(a);
p.appendChild(b);
button.appendChild(p);
spans[x].parentNode.insertBefore(button, spans[x].nextSibling);
spans[x].parentNode.insertBefore(document.createTextNode(" "), spans[x].nextSibling); // Divider
}
}if (stripEmail && window.location.href.search(/http(s)?\:\/\/soylentnews\.org\/submit\.pl/)!=-1) // Empty email input area, but only on submission page
{
var boxes = document.getElementsByTagName("input");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "email")
{
boxes[x].value = "";
}
}
}// Add title case button next to title/subj field on Story Submissions, Submission Preview, and Story Preview
if (window.location.href.search(/http(s)?\:\/\/soylentnews\.org\/(submit|admin)\.pl/)!=-1)
{
var boxes = document.getElementsByTagName("input");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "title" || boxes[x].name == "subj")
{
boxes[x].id = "storyTitle";
var button = document.createElement("input");
button.setAttribute("type","button");
button.setAttribute("value","Title Case");
button.setAttribute("title","Convert title to title case.");
button.setAttribute("onclick","document.getElementById('storyTitle').value=document.getElementById('storyTitle').value.replace(/\\b([a-z])/gi,function(m, p1){return p1.toUpperCase();}).replace(/\\b(at|of|is|and|to|in|by|as|its|be|the|on|a|an|but|or|for)\\b/gi,function(m, p1){return p1.toLowerCase();}).replace(/^([a-z])/gi,function(m, p1){return p1.toUpperCase();}).replace(/:\\s([a-z])/gi,function(m, p1){return ': '+p1.toUpperCase();}).replace(/\\bx(86|64)\\b/gi,'x$1');");
boxes[x].parentNode.insertBefore(button, boxes[x].nextSibling);
if (window.location.href.search(/http(s)?\:\/\/soylentnews\.org\/admin\.pl/)!=-1 || boxes[x].name == "subj")
{
boxes[x].parentNode.insertBefore(document.createElement("br"), boxes[x].nextSibling);
}
else
{
boxes[x].parentNode.insertBefore(document.createTextNode(" "), boxes[x].nextSibling);
}
}
}
}var boxes = document.getElementsByTagName("textarea");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var temp = boxes[x].value; // Retrieve textarea contents
temp = temp.replace(/<\/p><p>/g,"<\/p>\n\n<p>"); // Add newlines between paragraphs
temp = temp.replace(/<br>\s?<br>/g,"<\/p>\n\n<p>"); // Convert double break tags to paragraph tags
temp = temp.replace(/<\/blockquote><p>/g,"<\/blockquote>\n\n<p>"); // Add newlines after blockquotes
temp = temp.replace(/<\/p><blockquote>/g,"<\/p>\n\n<blockquote>"); // Add newlines before blockquotes
temp = temp.replace(/<blockquote><div><p>/g,"<blockquote><div>\n\n<p>"); // Add newlines within start of blockquotes
temp = temp.replace(/<\/p><\/div><\/blockquote>/g,"<\/p>\n\n<\/div><\/blockquote>"); // Add newlines within end of blockquotes
temp = temp.replace(/<\/blockquote><blockquote>/g,"<\/blockquote>\n\n<blockquote>"); // Add newlines between two blockquotes
temp = temp.replace(/<p class="byline">\s/i,"<p class=\"byline\">"); // Remove extra space from byline
temp = temp.replace(/<p>\s/g,"<p>"); // Remove extra space from start of paragraph
temp = temp.replace(/\s<\/p>/g,"<\/p>"); // Remove extra space from end of paragraph
temp = temp.replace(/<\/li><li>/g,"<\/li>\n<li>"); // Add newlines between list items
temp = temp.replace(/<\/li><\/ul>/g,"<\/li>\n(<\/ul>|<\/ol>)"); // Add newline after last list item
temp = temp.replace(/<\/p><ul>/g,"<\/p>\n\n(<ul>|<ol>)"); // Add newlines before lists
temp = temp.replace(/<p>\[...\]/g,"<p>[...] "); // Add space within beginning of foreshortened paragraph
while (temp.indexOf(" ")!=-1)
{
temp = temp.replace(/ /g," "); // Replace double spaces with single spaces
}
if (simplifyChars)
{
temp = temp.replace(/\u2018/g,"'"); // 'LEFT SINGLE QUOTATION MARK' (U+2018) to (U+0027)
temp = temp.replace(/\u2019/g,"'"); // 'RIGHT SINGLE QUOTATION MARK' (U+2019) to (U+0027)
temp = temp.replace(/\u201C/g,"\""); // 'LEFT DOUBLE QUOTATION MARK' (U+201C) to (U+0022)
temp = temp.replace(/\u201D/g,"\""); // 'RIGHT DOUBLE QUOTATION MARK' (U+201D) to (U+0022)
temp = temp.replace(/\u2026/g,"..."); // 'HORIZONTAL ELLIPSIS' (U+2026) to (U+002E) x3
}
boxes[x].value = temp;
boxes[x].rows = 32; // Expand textarea height to 32 rows
}
var toolbar = document.createElement("div");// Blockquote button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Blockquote");
tempbutton.setAttribute("title","Wrap \u003Cblockquote\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addBlockquote(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Paragraph and Line break buttons
var tempspan = document.createElement("span");
tempspan.setAttribute("id","htmlFormatButtons");
if (document.getElementById("posttype") && document.getElementById("posttype").selectedIndex == 0)
{
tempspan.setAttribute("style","display:none;"); // Hide if initial post type option is "Plain Old Text"
}
if (document.getElementById("posttype"))
{
document.getElementById("posttype").addEventListener("change", function() {if (document.getElementById('posttype').selectedIndex == 0) {document.getElementById('htmlFormatButtons').style.display = 'none'} else {document.getElementById('htmlFormatButtons').style.display = 'inline'}}); // Change visibility of these buttons based on value of post type
}
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","P");
tempbutton.setAttribute("title","Wrap \u003Cp\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addPara(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","BR");
tempbutton.setAttribute("title","Insert a line break.");
tempbutton.setAttribute("onclick","addBreak(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);// HR button, if editing a story
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","HR");
tempbutton.setAttribute("title","Insert a horizontal rule.");
tempbutton.setAttribute("style","text-decoration:underline overline;");
tempbutton.setAttribute("onclick","addHRule(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);
}// URL button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","URL");
tempbutton.setAttribute("title","Create a hyperlink around the selected text.");
tempbutton.setAttribute("style","text-decoration:underline;");
tempbutton.setAttribute("onclick","addHyperlink(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));// Bold button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","B");
tempbutton.setAttribute("title","Bold");
tempbutton.setAttribute("style","font-weight:bold;");
tempbutton.setAttribute("onclick","addBold(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Italic button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","I");
tempbutton.setAttribute("title","Italic");
tempbutton.setAttribute("style","font-style:italic;");
tempbutton.setAttribute("onclick","addItalic(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Strike button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","S");
tempbutton.setAttribute("title","Strikethrough");
tempbutton.setAttribute("style","text-decoration:line-through;");
tempbutton.setAttribute("onclick","addStrike(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Code button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Code");
tempbutton.setAttribute("title","Wrap \u003Cecode\u003E tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addEcode(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Teletype button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","TT");
tempbutton.setAttribute("title","Wrap \u003Ctt\u003E (teletype, i.e. monospace) tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addTT(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Small button, if editing a story
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u0073\u1D0D\u1D00\u029F\u029F");
tempbutton.setAttribute("title","Wrap \u003Csmall\u003E tags around the selected text.");
// tempbutton.setAttribute("style","font-size:75%;");
tempbutton.setAttribute("onclick","addSmall(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
}toolbar.appendChild(document.createTextNode(" ")); // Divider
// Superscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u00B2");
tempbutton.setAttribute("title","Superscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSuper(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Subscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u2082");
tempbutton.setAttribute("title","Subscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSubsc(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Ordered list button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","1. List");
tempbutton.setAttribute("title","Insert an ordered list or convert newline-separated text into an ordered list.");
tempbutton.setAttribute("onclick","addOrdlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Unordered list button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u2022 List");
tempbutton.setAttribute("title","Insert an unordered list or convert newline-separated text into an unordered list.");
tempbutton.setAttribute("onclick","addUnordlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createElement("br")); // Divider
// Create 7 macro buttons
for (var i=1; i<=7; i++)
{
// Create macros if they don't exist
if(!localStorage.getItem("soymacro"+i))
{
localStorage.setItem("soymacro"+i,JSON.stringify(["M"+i,"string","Sample Text"]));
//localStorage.setItem("soymacro"+i,JSON.stringify(["M"+i,"regexp","/a/gi","b"]));
}
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("id","soymacros"+x+"button"+i);
tempbutton.setAttribute("value",JSON.parse(localStorage.getItem("soymacro"+i))[0]);
if (JSON.parse(localStorage.getItem("soymacro"+i))[1]=="string")
{
if (JSON.parse(localStorage.getItem("soymacro"+i))[2].length < 40)
{
tempbutton.setAttribute("title","Insert or replace selected text with: " + JSON.parse(localStorage.getItem("soymacro"+i))[2]);
}
else
{
tempbutton.setAttribute("title","Insert or replace selected text with: " + JSON.parse(localStorage.getItem("soymacro"+i))[2].substring(0,40)+"...");
}
tempbutton.setAttribute("onclick","macroChoose(document.getElementsByTagName('textarea')["+x+"],"+i+");");
}
else
{
tempbutton.setAttribute("title","Replace text matched by the regular expression: " + JSON.parse(localStorage.getItem("soymacro"+i))[2] + " with: " + JSON.parse(localStorage.getItem("soymacro"+i))[3]);
tempbutton.setAttribute("onclick","macroChoose(document.getElementsByTagName('textarea')["+x+"],"+i+");");
}
toolbar.appendChild(tempbutton);
}
// Create macros edit button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Edit");
tempbutton.setAttribute("title","Configure user macros or discard changes.");
tempbutton.setAttribute("onclick","if (document.getElementById('macrobar"+x+"').style.display == 'none') {document.getElementById('macrobar"+x+"').style.display = 'block'; macrobarInit("+x+");} else {document.getElementById('macrobar"+x+"').style.display = 'none'; if (p = document.getElementById('postercomment')) { var x = p.offsetTop; while (p = p.offsetParent) {x += p.offsetLeft;} window.scrollTo(0,x-75);}}");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createElement("br")); // Divider
// Despace button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Despace");
tempbutton.setAttribute("title","Delete newlines within the selection.");
tempbutton.setAttribute("onclick","despace(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Symbol button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value",":-)");
tempbutton.setAttribute("title","Insert a symbol.");
tempbutton.setAttribute("onclick","if (document.getElementById('smilebar"+x+"').style.display == 'none') {document.getElementById('smilebar"+x+"').style.display = 'block'} else {document.getElementById('smilebar"+x+"').style.display = 'none'; if (p = document.getElementById('postercomment')) { var x = p.offsetTop; while (p = p.offsetParent) {x += p.offsetLeft;} window.scrollTo(0,x-75); } }");
toolbar.appendChild(tempbutton);
boxes[x].parentNode.insertBefore(toolbar, boxes[x].nextSibling);// Symbol list
var smilebar = document.createElement("div");
smilebar.setAttribute("style","-moz-user-select:none; -webkit-user-select:none; display:none; font-size:16pt; max-height:240px; overflow:auto; padding:0.5em;");
smilebar.setAttribute("id","smilebar"+x);
var smiles = ["\u0026amp;","\u0026lt;","\u0026gt;"];var codes = [[161,169],[171,172],[174],[176,177],[180,183],[187,191],[215],[224,255],[402],[629],[632],[916],[920],[931],[934],[937],[945,946],[956],[960],[963],[8216,8221],[8226],[8230],[8251],[8364],[8478],[8482],[8528,8542],[8585],[8592,8652],[8712,8716],[8721],[8730],[8733,8734],[8736],[8743,8749],[8756,8757],[8773],[8776],[8800,8805],[8834,8837],[8984],[9760],[9762,9765],[9770],[9773,9775],[9784,9794],[9812,9831],[9833,9842],[9850],[9855,9861],[9874,9877],[9882,9885],[9888,9893],[9913],[9940],[9962],[9971],[9981],[9992,10087],[65533],[127744,127756],[127759],[127775,127776],[127797],[127801],[127804,127812],[127817],[127820,127822],[127828,127831],[127838,127839],[127843],[127849],[127855],[127860,127867],[127891],[127904,127911],[127918],[127939],[127942],[127977],[128025],[128074,128078],[128123,128131],[128137,128142],[128148,128150],[128152],[128158],[128161,128164],[128168,128170],[128172],[128176,128177],[128187],[128189,128190],[128193,128194],[128197],[128203,128204],[128206],[128214],[128225,128227],[128231,128233],[128241],[128244],[128246],[128250,128252],[128259],[128266,128270],[128273,128276],[128278,128280],[128286],[128293,128299],[128302,128303],[128509,128510],[128659],[128684,128685]];
for (var i=0; i<codes.length; i++) { if (codes[i].length > 1) { for (var j=codes[i][0]; j<=codes[i][1]; j++) { smiles[smiles.length] = String.fromCodePoint(j); } } else { smiles[smiles.length] = String.fromCodePoint(codes[i][0]); } } // Populate smiles array with code ranges converted to individual characters
smiles = smiles.concat(["xD",":-)",":^)","(^_^;)","\u0028\u00A0\u0361\u00B0\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029","\u0028\u00A0\u0361\u007E\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029\uFEFF","\u00AF\u005C\u005F\u0028\u30C4\u0029\u005F\u002F\u00AF","\u0028\u256F\u00B0\u25A1\u00B0\uFF09\u256F\uFE35\u00A0\u253B\u2501\u253B","\u0028\u30CE\u0CA0\u76CA\u0CA0\u0029\u30CE\u5F61\u253B\u2501\u253B","\u0028\u0060\uFF65\u03C9\uFF65\u00B4\u0029","\u0CA0_\u0CA0","\u0295\u2022\u1D25\u2022\u0294","\u0028\u3065\uFFE3\u00A0\u00B3\uFFE3\u0029\u3065","\u0669\u0028\u204E\u275B\u1D17\u275B\u204E\u0029\u06F6","\u30FD\u0F3C\u0E88\u0644\u035C\u0E88\u0F3D\uFF89"]); // Add in arbitrary emoticons
for (var i=0; i<smiles.length; i++)
{
var smile = document.createElement("span");
smile.setAttribute("style","cursor:pointer; padding:2px; white-space:nowrap;");
smile.setAttribute("onclick","addSmile(document.getElementsByTagName('textarea')["+x+"],'"+smiles[i].replace("\u005C","\u005C\u005C")+"');");
smile.appendChild(document.createTextNode(smiles[i]));
smilebar.appendChild(smile);
if (i+1<smiles.length)
{
smilebar.appendChild(document.createTextNode(" "));
}
}
toolbar.parentNode.insertBefore(smilebar, toolbar.nextSibling);// Create macro configuration interface
var macrobar = document.createElement("div");
macrobar.setAttribute("style","display:none; padding:0.5em;");
macrobar.setAttribute("id","macrobar"+x);
var table = document.createElement("table");
var tr = document.createElement("tr");
var th = document.createElement("th");
th.appendChild(document.createTextNode("Name"));
tr.appendChild(th);
var th = document.createElement("th");
th.appendChild(document.createTextNode("Type"));
tr.appendChild(th);
var th = document.createElement("th");
th.appendChild(document.createTextNode("String | Expression"));
tr.appendChild(th);
var th = document.createElement("th");
th.setAttribute("title","Only used with expressions. Parenthesized substring matches (e.g. '$1') can be used.");
th.setAttribute("style","cursor:help;");
th.appendChild(document.createTextNode("Expression Replace"));
tr.appendChild(th);
table.appendChild(tr);
for (var i=1; i<=7; i++)
{
var tr = document.createElement("tr");// Macro name
var td = document.createElement("td");
var name = document.createElement("input");
name.setAttribute("type","text");
name.setAttribute("id","soymacros"+x+"name"+i);
td.appendChild(name);
tr.appendChild(td);// Macro type
var td = document.createElement("td");
var rad = document.createElement("input");
rad.setAttribute("type","radio");
rad.setAttribute("name","soymacros"+x+"type"+i);
rad.setAttribute("id","soymacros"+x+"type"+i+"S");
td.appendChild(rad);
td.appendChild(document.createTextNode(" String "));
var rad = document.createElement("input");
rad.setAttribute("type","radio");
rad.setAttribute("name","soymacros"+x+"type"+i);
rad.setAttribute("id","soymacros"+x+"type"+i+"E");
td.appendChild(rad);
td.appendChild(document.createTextNode(" Expression "));
tr.appendChild(td);// Field A
var td = document.createElement("td");
var f1 = document.createElement("input");
f1.setAttribute("type","text");
f1.setAttribute("id","soymacros"+x+"fieldA"+i);
td.appendChild(f1);
tr.appendChild(td);// Field B
var td = document.createElement("td");
var f1 = document.createElement("input");
f1.setAttribute("type","text");
f1.setAttribute("id","soymacros"+x+"fieldB"+i);
td.appendChild(f1);
tr.appendChild(td);table.appendChild(tr);
}
macrobar.appendChild(table);var p = document.createElement("p");
var save = document.createElement("input");
save.setAttribute("type","button");
save.setAttribute("value","Save");
save.setAttribute("title","Save any edits to the macro configuration.");
save.setAttribute("onclick","macrobarSave("+x+");");
p.appendChild(save);
p.appendChild(document.createTextNode(" "));
var guide = document.createElement("a");
guide.setAttribute("href","https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions");
guide.setAttribute("target","_blank");
guide.appendChild(document.createTextNode("Regexp Guide"));
p.appendChild(guide);
macrobar.appendChild(p);toolbar.parentNode.insertBefore(macrobar, toolbar.nextSibling);
}var temp = document.createElement("script");
// Add selection handling function
temp.appendChild(document.createTextNode("function getSelection(textarea) { if ('selectionStart' in textarea) { if (textarea.selectionStart != textarea.selectionEnd) { return [textarea.selectionStart,textarea.selectionEnd]; } } } "));// Add comment formatting buttons
temp.appendChild(document.createTextNode("function addBlockquote(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<blockquote>'+area.value.substring(sel[0],sel[1])+'<\/blockquote>' + area.value.substring(sel[1]); } } function addPara(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<p>'+area.value.substring(sel[0],sel[1])+'<\/p>' + area.value.substring(sel[1]); } } function addBreak(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<br>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHRule(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<hr>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHyperlink(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { url = prompt('URL:', 'https://'); area.value = area.value.substring(0,sel[0]) + '<a href=\"'+url+'\">'+area.value.substring(sel[0],sel[1])+'<\/a>' + area.value.substring(sel[1]); } } function addBold(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<b>'+area.value.substring(sel[0],sel[1])+'<\/b>' + area.value.substring(sel[1]); } } function addItalic(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<em>'+area.value.substring(sel[0],sel[1])+'<\/em>' + area.value.substring(sel[1]); } } function addStrike(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<strike>'+area.value.substring(sel[0],sel[1])+'<\/strike>' + area.value.substring(sel[1]); } } function addEcode(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<ecode>'+area.value.substring(sel[0],sel[1])+'<\/ecode>' + area.value.substring(sel[1]); } } function addTT(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<tt>'+area.value.substring(sel[0],sel[1])+'<\/tt>' + area.value.substring(sel[1]); } } function addSmall(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<small>'+area.value.substring(sel[0],sel[1])+'<\/small>' + area.value.substring(sel[1]); } } function addSuper(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sup>'+area.value.substring(sel[0],sel[1])+'<\/sup>' + area.value.substring(sel[1]); } } function addSubsc(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sub>'+area.value.substring(sel[0],sel[1])+'<\/sub>' + area.value.substring(sel[1]); } } "));// Add list creation functions
temp.appendChild(document.createTextNode("function addOrdlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ol><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>').replace(/\\n<li><\\/li>/g,'') + '<\/li><\/ol>' + area.value.substring(area.selectionEnd); } else { temp = '<ol>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>\\n'; } area.value = area.value.substring(0,area.selectionStart) + temp.substring(0,temp.length-1) + '<\/ol>' + area.value.substring(area.selectionStart); } } } function addUnordlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ul><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>').replace(/\\n<li><\\/li>/g,'') + '<\/li><\/ul>' + area.value.substring(area.selectionEnd); } else { temp = '<ul>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>\\n'; } area.value = area.value.substring(0,area.selectionStart) + temp.substring(0,temp.length-1) + '<\/ul>' + area.value.substring(area.selectionStart); } } }"));// Add macro functions
temp.appendChild(document.createTextNode("function macroChoose(area,x) { if (JSON.parse(localStorage.getItem('soymacro'+x))[1]=='string') { macroString(area,x); } else { macroRegexp(area,x); } }"));
temp.appendChild(document.createTextNode("function macroString(area,x) { var sel = getSelection(area); if (sel && sel[0] != sel[1]) { area.value = area.value.substring(0,sel[0]) + JSON.parse(localStorage.getItem('soymacro'+x))[2] + area.value.substring(sel[1]); } else if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + JSON.parse(localStorage.getItem('soymacro'+x))[2] + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+JSON.parse(localStorage.getItem('soymacro'+x))[2].length,pos+JSON.parse(localStorage.getItem('soymacro'+x))[2].length); } }"));
temp.appendChild(document.createTextNode("function macroRegexp(area,x) { var sel = getSelection(area); if (sel && sel[0] != sel[1]) { var reg = JSON.parse(localStorage.getItem('soymacro'+x))[2]; area.value = area.value.substring(0,sel[0]) + area.value.substring(sel[0],sel[1]).replace(new RegExp(reg.substring(reg.indexOf('/')+1,reg.lastIndexOf('/')), reg.substring(reg.lastIndexOf('/')+1)),JSON.parse(localStorage.getItem('soymacro'+x))[3]) + area.value.substring(sel[1]); } }"));
temp.appendChild(document.createTextNode("function macrobarInit(x) { for (var y=1; y<=7; y++) { document.getElementById('soymacros'+x+'name'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[0]; if (JSON.parse(localStorage.getItem('soymacro'+y))[1]=='string') { document.getElementById('soymacros'+x+'type'+y+'S').checked = true; } else { document.getElementById('soymacros'+x+'type'+y+'E').checked = true; } document.getElementById('soymacros'+x+'fieldA'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[2]; if (JSON.parse(localStorage.getItem('soymacro'+y))[1]!='string') { document.getElementById('soymacros'+x+'fieldB'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[3]; } else { document.getElementById('soymacros'+x+'fieldB'+y).value = ''; } } }"));
temp.appendChild(document.createTextNode("function macrobarSave(x) { for (var y=1; y<=7; y++) { if (document.getElementById('soymacros'+x+'type'+y+'S').checked == true) { localStorage.setItem('soymacro'+y,JSON.stringify([document.getElementById('soymacros'+x+'name'+y).value,'string',document.getElementById('soymacros'+x+'fieldA'+y).value])); } else { localStorage.setItem('soymacro'+y,JSON.stringify([document.getElementById('soymacros'+x+'name'+y).value,'regexp',document.getElementById('soymacros'+x+'fieldA'+y).value,document.getElementById('soymacros'+x+'fieldB'+y).value])); } } document.getElementById('macrobar'+x).style.display = 'none'; var boxes = document.getElementsByTagName('textarea'); for (var z=0; z<boxes.length; z++) { for (var y=1; y<=7; y++) { document.getElementById('soymacros'+z+'button'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[0]; if (JSON.parse(localStorage.getItem('soymacro'+y))[1]=='string') { if (JSON.parse(localStorage.getItem('soymacro'+y))[2].length < 40) { document.getElementById('soymacros'+z+'button'+y).title = 'Insert or replace selected text with: ' + JSON.parse(localStorage.getItem('soymacro'+y))[2]; } else { document.getElementById('soymacros'+z+'button'+y).title = 'Insert or replace selected text with: ' + JSON.parse(localStorage.getItem('soymacro'+y))[2].substring(0,40)+'...'; } } else { document.getElementById('soymacros'+z+'button'+y).title = 'Replace text matched by the regular expression: ' + JSON.parse(localStorage.getItem('soymacro'+y))[2] + ' with: ' + JSON.parse(localStorage.getItem('soymacro'+y))[3]; } } } }"));// Add despace function
temp.appendChild(document.createTextNode("function despace(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + area.value.substring(sel[0],sel[1]).replace(/\\r/g,' ').replace(/\\n/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ') + area.value.substring(sel[1]); } }"));// Add unicode insertion function
temp.appendChild(document.createTextNode("function addSmile(area, smile) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,pos) + smile + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+smile.length,pos+smile.length) } }"));document.getElementsByTagName('head')[0].appendChild(temp); // Add script to page
// ==UserScript==
// @name Soylent Upgrade
// @match http://soylentnews.org/*article.pl*
// @match https://soylentnews.org/*article.pl*
// @match http://soylentnews.org/submit.pl*
// @match https://soylentnews.org/submit.pl*
// @match http://soylentnews.org/admin.pl*
// @match https://soylentnews.org/admin.pl*
// @match http://soylentnews.org/*comments.pl*
// @match https://soylentnews.org/*comments.pl*
// @match http://soylentnews.org/journal.pl*
// @match https://soylentnews.org/journal.pl*
// ==/UserScript==/* ! http://mths.be/fromcodepoint v0.1.0 by @mathias */
if (!String.fromCodePoint) { (function() { var defineProperty = (function() { try { var object = {}; var $defineProperty = Object.defineProperty; var result = $defineProperty(object, object, object) && $defineProperty; } catch(error) {} return result; }()); var stringFromCharCode = String.fromCharCode; var floor = Math.floor; var fromCodePoint = function() { var MAX_SIZE = 0x4000; var codeUnits = []; var highSurrogate; var lowSurrogate; var index = -1; var length = arguments.length; if (!length) { return ''; } var result = ''; while (++index < length) { var codePoint = Number(arguments[index]); if ( !isFinite(codePoint) || codePoint < 0 || codePoint > 0x10FFFF || floor(codePoint) != codePoint ) { throw RangeError('Invalid code point: ' + codePoint); } if (codePoint <= 0xFFFF) { codeUnits.push(codePoint); } else { codePoint -= 0x10000; highSurrogate = (codePoint >> 10) + 0xD800; lowSurrogate = (codePoint % 0x400) + 0xDC00; codeUnits.push(highSurrogate, lowSurrogate); } if (index + 1 == length || codeUnits.length > MAX_SIZE) { result += stringFromCharCode.apply(null, codeUnits); codeUnits.length = 0; } } return result; }; if (defineProperty) { defineProperty(String, 'fromCodePoint', { 'value': fromCodePoint, 'configurable': true, 'writable': true }); } else { String.fromCodePoint = fromCodePoint; } }()); }// Add "Quote This" buttons to all initially visible comments
var spans = document.getElementsByTagName("span");
for (var x=0; x<spans.length; x++)
{
if (spans[x].id.indexOf("reply_link_")==0)
{
var button = document.createElement("span");
button.setAttribute("class","nbutton");
var p = document.createElement("p");
var b = document.createElement("b");
var a = document.createElement("a");
// Set the href of the "Quote This" button to the href of the "Reply to This" button, with the escaped contents of the post added to URL and any [domain.names] following links in the post cut out:
a.setAttribute("href",spans[x].getElementsByTagName("a")[0].href.replace("#post_comment","&postercomment="+escape("<blockquote>"+document.getElementById("comment_body_"+spans[x].id.replace("reply_link_","")).innerHTML.replace(/<\/a>\s\[.*?\..*?\]/g,"<\/a>")+"<\/blockquote>\n\n")+"#post_comment"));
// To Do: Shorten URLs longer than 2000 characters
a.appendChild(document.createTextNode("Quote This"));
b.appendChild(a);
p.appendChild(b);
button.appendChild(p);
spans[x].parentNode.insertBefore(button, spans[x].nextSibling);
spans[x].parentNode.insertBefore(document.createTextNode(" "), spans[x].nextSibling); // Divider
}
}var simplifyChars = true; // Change to false if you don't want stylized quotation marks, ellipses, etc. to be replaced
var stripEmail = false; // Remove auto-filled email from submissionif (stripEmail && window.location.href.search(/http(s)?\:\/\/soylentnews\.org\/submit\.pl/)!=-1) // Empty email input area, but only on submission page
{
var boxes = document.getElementsByTagName("input");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "email")
{
boxes[x].value = "";
}
}
}var boxes = document.getElementsByTagName("textarea");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var temp = boxes[x].value; // Retrieve textarea contents
temp = temp.replace(/<\/p><p>/g,"<\/p>\n\n<p>"); // Add newlines between paragraphs
temp = temp.replace(/<br>\s?<br>/g,"<\/p>\n\n<p>"); // Convert double break tags to paragraph tags
temp = temp.replace(/<\/blockquote><p>/g,"<\/blockquote>\n\n<p>"); // Add newlines after blockquotes
temp = temp.replace(/<\/p><blockquote>/g,"<\/p>\n\n<blockquote>"); // Add newlines before blockquotes
temp = temp.replace(/<blockquote><div><p>/g,"<blockquote><div>\n\n<p>"); // Add newlines within start of blockquotes
temp = temp.replace(/<\/p><\/div><\/blockquote>/g,"<\/p>\n\n<\/div><\/blockquote>"); // Add newlines within end of blockquotes
temp = temp.replace(/<\/blockquote><blockquote>/g,"<\/blockquote>\n\n<blockquote>"); // Add newlines between two blockquotes
temp = temp.replace(/<p class="byline">\s/i,"<p class=\"byline\">"); // Remove extra space from byline
temp = temp.replace(/<p>\s/g,"<p>"); // Remove extra space from start of paragraph
temp = temp.replace(/\s<\/p>/g,"<\/p>"); // Remove extra space from end of paragraph
temp = temp.replace(/<\/li><li>/g,"<\/li>\n<li>"); // Add newlines between list items
temp = temp.replace(/<\/li><\/ul>/g,"<\/li>\n(<\/ul>|<\/ol>)"); // Add newline after last list item
temp = temp.replace(/<\/p><ul>/g,"<\/p>\n\n(<ul>|<ol>)"); // Add newlines before lists
temp = temp.replace(/<p>\[...\]/g,"<p>[...] "); // Add space within beginning of foreshortened paragraph
while (temp.indexOf(" ")!=-1)
{
temp = temp.replace(/ /g," "); // Replace double spaces with single spaces
}
if (simplifyChars)
{
temp = temp.replace(/\u2018/g,"'"); // 'LEFT SINGLE QUOTATION MARK' (U+2018) to (U+0027)
temp = temp.replace(/\u2019/g,"'"); // 'RIGHT SINGLE QUOTATION MARK' (U+2019) to (U+0027)
temp = temp.replace(/\u201C/g,"\""); // 'LEFT DOUBLE QUOTATION MARK' (U+201C) to (U+0022)
temp = temp.replace(/\u201D/g,"\""); // 'RIGHT DOUBLE QUOTATION MARK' (U+201D) to (U+0022)
temp = temp.replace(/\u2026/g,"..."); // 'HORIZONTAL ELLIPSIS' (U+2026) to (U+002E) x3
}
boxes[x].value = temp;
boxes[x].rows = 32; // Expand textarea height to 32 rows
}
var toolbar = document.createElement("div");// Blockquote button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Blockquote");
tempbutton.setAttribute("title","Wrap \u003Cblockquote\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addBlockquote(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Paragraph and Line break buttons
var tempspan = document.createElement("span");
tempspan.setAttribute("id","htmlFormatButtons");
if (document.getElementById("posttype") && document.getElementById("posttype").selectedIndex == 0)
{
tempspan.setAttribute("style","display:none;"); // Hide if initial post type option is "Plain Old Text"
}
if (document.getElementById("posttype"))
{
document.getElementById("posttype").addEventListener("change", function() {if (document.getElementById('posttype').selectedIndex == 0) {document.getElementById('htmlFormatButtons').style.display = 'none'} else {document.getElementById('htmlFormatButtons').style.display = 'inline'}}); // Change visibility of these buttons based on value of post type
}
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","P");
tempbutton.setAttribute("title","Wrap \u003Cp\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addPara(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","BR");
tempbutton.setAttribute("title","Insert a line break.");
tempbutton.setAttribute("onclick","addBreak(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);// HR button, if editing a story
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","HR");
tempbutton.setAttribute("title","Insert a horizontal rule.");
tempbutton.setAttribute("style","text-decoration:underline overline;");
tempbutton.setAttribute("onclick","addHRule(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);
}// URL button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","URL");
tempbutton.setAttribute("title","Create a hyperlink around the selected text.");
tempbutton.setAttribute("style","text-decoration:underline;");
tempbutton.setAttribute("onclick","addHyperlink(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));// Bold button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","B");
tempbutton.setAttribute("title","Bold");
tempbutton.setAttribute("style","font-weight:bold;");
tempbutton.setAttribute("onclick","addBold(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Italic button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","I");
tempbutton.setAttribute("title","Italic");
tempbutton.setAttribute("style","font-style:italic;");
tempbutton.setAttribute("onclick","addItalic(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Strike button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","S");
tempbutton.setAttribute("title","Strikethrough");
tempbutton.setAttribute("style","text-decoration:line-through;");
tempbutton.setAttribute("onclick","addStrike(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Code button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Code");
tempbutton.setAttribute("title","Wrap \u003Cecode\u003E tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addEcode(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Teletype button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","TT");
tempbutton.setAttribute("title","Wrap \u003Ctt\u003E (teletype, i.e. monospace) tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addTT(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Small button, if editing a story
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u0073\u1D0D\u1D00\u029F\u029F");
tempbutton.setAttribute("title","Wrap \u003Csmall\u003E tags around the selected text.");
// tempbutton.setAttribute("style","font-size:75%;");
tempbutton.setAttribute("onclick","addSmall(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
}toolbar.appendChild(document.createTextNode(" ")); // Divider
// Superscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u00B2");
tempbutton.setAttribute("title","Superscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSuper(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Subscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u2082");
tempbutton.setAttribute("title","Subscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSubsc(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Ordered list button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","1. List");
tempbutton.setAttribute("title","Insert an ordered list or convert newline-separated text into an ordered list.");
tempbutton.setAttribute("onclick","addOrdlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Unordered list button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u2022 List");
tempbutton.setAttribute("title","Insert an unordered list or convert newline-separated text into an unordered list.");
tempbutton.setAttribute("onclick","addUnordlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Create 5 macro buttons
for (var i=1; i<=5; i++)
{
// Create macros if they don't exist
if(!localStorage.getItem("soymacro"+i))
{
localStorage.setItem("soymacro"+i,JSON.stringify(["M"+i,"string","Sample Text"]));
//localStorage.setItem("soymacro"+i,JSON.stringify(["M"+i,"regexp","/a/gi","b"]));
}
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("id","soymacros"+x+"button"+i);
tempbutton.setAttribute("value",JSON.parse(localStorage.getItem("soymacro"+i))[0]);
if (JSON.parse(localStorage.getItem("soymacro"+i))[1]=="string")
{
if (JSON.parse(localStorage.getItem("soymacro"+i))[2].length < 40)
{
tempbutton.setAttribute("title","Insert or replace selected text with: " + JSON.parse(localStorage.getItem("soymacro"+i))[2]);
}
else
{
tempbutton.setAttribute("title","Insert or replace selected text with: " + JSON.parse(localStorage.getItem("soymacro"+i))[2].substring(0,40)+"...");
}
tempbutton.setAttribute("onclick","macroChoose(document.getElementsByTagName('textarea')["+x+"],"+i+");");
}
else
{
tempbutton.setAttribute("title","Replace text matched by the regular expression: " + JSON.parse(localStorage.getItem("soymacro"+i))[2] + " with: " + JSON.parse(localStorage.getItem("soymacro"+i))[3]);
tempbutton.setAttribute("onclick","macroChoose(document.getElementsByTagName('textarea')["+x+"],"+i+");");
}
toolbar.appendChild(tempbutton);
}
// Create macros edit button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Edit");
tempbutton.setAttribute("title","Configure user macros or discard changes.");
tempbutton.setAttribute("onclick","if (document.getElementById('macrobar"+x+"').style.display == 'none') {document.getElementById('macrobar"+x+"').style.display = 'block'; macrobarInit("+x+");} else {document.getElementById('macrobar"+x+"').style.display = 'none'; if (p = document.getElementById('postercomment')) { var x = p.offsetTop; while (p = p.offsetParent) {x += p.offsetLeft;} window.scrollTo(0,x-75);}}");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createElement("br")); // Divider
// Despace button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Despace");
tempbutton.setAttribute("title","Delete newlines within the selection.");
tempbutton.setAttribute("onclick","despace(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Symbol button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value",":-)");
tempbutton.setAttribute("title","Insert a symbol.");
tempbutton.setAttribute("onclick","if (document.getElementById('smilebar"+x+"').style.display == 'none') {document.getElementById('smilebar"+x+"').style.display = 'block'} else {document.getElementById('smilebar"+x+"').style.display = 'none'; if (p = document.getElementById('postercomment')) { var x = p.offsetTop; while (p = p.offsetParent) {x += p.offsetLeft;} window.scrollTo(0,x-75); } }");
toolbar.appendChild(tempbutton);
boxes[x].parentNode.insertBefore(toolbar, boxes[x].nextSibling);// Symbol list
var smilebar = document.createElement("div");
smilebar.setAttribute("style","-moz-user-select:none; -webkit-user-select:none; display:none; font-size:16pt; max-height:240px; overflow:auto; padding:0.5em;");
smilebar.setAttribute("id","smilebar"+x);
var smiles = ["<",">"];var codes = [[161,169],[171,172],[174],[176,177],[180,183],[187,191],[215],[224,255],[402],[629],[632],[916],[920],[931],[934],[937],[945,946],[956],[960],[963],[8216,8221],[8226],[8230],[8251],[8364],[8478],[8482],[8528,8542],[8585],[8712,8716],[8721],[8730],[8733,8734],[8736],[8743,8749],[8756,8757],[8773],[8776],[8800,8805],[8834,8837],[8984],[9760],[9762,9765],[9770],[9773,9775],[9784,9794],[9812,9831],[9833,9842],[9850],[9855,9861],[9874,9877],[9882,9885],[9888,9893],[9913],[9940],[9962],[9971],[9981],[9992,10087],[65533],[127744,127756],[127759],[127775,127776],[127797],[127801],[127804,127812],[127817],[127820,127822],[127828,127831],[127838,127839],[127843],[127849],[127855],[127860,127867],[127891],[127904,127911],[127918],[127939],[127942],[127977],[128025],[128074,128078],[128123,128131],[128137,128142],[128148,128150],[128152],[128158],[128161,128164],[128168,128170],[128172],[128176,128177],[128187],[128189,128190],[128193,128194],[128197],[128203,128204],[128206],[128214],[128225,128227],[128231,128233],[128241],[128244],[128246],[128250,128252],[128259],[128266,128270],[128273,128276],[128278,128280],[128286],[128293,128299],[128302,128303],[128509,128510],[128659],[128684,128685]];
for (var i=0; i<codes.length; i++) { if (codes[i].length > 1) { for (var j=codes[i][0]; j<=codes[i][1]; j++) { smiles[smiles.length] = String.fromCodePoint(j); } } else { smiles[smiles.length] = String.fromCodePoint(codes[i][0]); } } // Populate smiles array with code ranges converted to individual characters
smiles = smiles.concat(["xD",":-)",":^)","(^_^;)","\u0028\u00A0\u0361\u00B0\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029","\u0028\u00A0\u0361\u007E\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029\uFEFF","\u00AF\u005C\u005F\u0028\u30C4\u0029\u005F\u002F\u00AF","\u0028\u256F\u00B0\u25A1\u00B0\uFF09\u256F\uFE35\u00A0\u253B\u2501\u253B","\u0028\u30CE\u0CA0\u76CA\u0CA0\u0029\u30CE\u5F61\u253B\u2501\u253B","\u0028\u0060\uFF65\u03C9\uFF65\u00B4\u0029","\u0CA0_\u0CA0","\u0295\u2022\u1D25\u2022\u0294","\u0028\u3065\uFFE3\u00A0\u00B3\uFFE3\u0029\u3065","\u0669\u0028\u204E\u275B\u1D17\u275B\u204E\u0029\u06F6","\u30FD\u0F3C\u0E88\u0644\u035C\u0E88\u0F3D\uFF89"]); // Add in arbitrary emoticons
for (var i=0; i<smiles.length; i++)
{
var smile = document.createElement("span");
smile.setAttribute("style","cursor:pointer; padding:2px; white-space:nowrap;");
smile.setAttribute("onclick","addSmile(document.getElementsByTagName('textarea')["+x+"],'"+smiles[i].replace("\u005C","\u005C\u005C")+"');");
smile.appendChild(document.createTextNode(smiles[i]));
smilebar.appendChild(smile);
if (i+1<smiles.length)
{
smilebar.appendChild(document.createTextNode(" "));
}
}
toolbar.parentNode.insertBefore(smilebar, toolbar.nextSibling);// Create macro configuration interface
var macrobar = document.createElement("div");
macrobar.setAttribute("style","display:none; padding:0.5em;");
macrobar.setAttribute("id","macrobar"+x);
var table = document.createElement("table");
var tr = document.createElement("tr");
var th = document.createElement("th");
th.appendChild(document.createTextNode("Name"));
tr.appendChild(th);
var th = document.createElement("th");
th.appendChild(document.createTextNode("Type"));
tr.appendChild(th);
var th = document.createElement("th");
th.appendChild(document.createTextNode("String | Expression"));
tr.appendChild(th);
var th = document.createElement("th");
th.setAttribute("title","Only used with expressions. Parenthesized substring matches (e.g. '$1') can be used.");
th.setAttribute("style","cursor:help;");
th.appendChild(document.createTextNode("Expression Replace"));
tr.appendChild(th);
table.appendChild(tr);
for (var i=1; i<=5; i++)
{
var tr = document.createElement("tr");// Macro name
var td = document.createElement("td");
var name = document.createElement("input");
name.setAttribute("type","text");
name.setAttribute("id","soymacros"+x+"name"+i);
td.appendChild(name);
tr.appendChild(td);// Macro type
var td = document.createElement("td");
var rad = document.createElement("input");
rad.setAttribute("type","radio");
rad.setAttribute("name","soymacros"+x+"type"+i);
rad.setAttribute("id","soymacros"+x+"type"+i+"S");
td.appendChild(rad);
td.appendChild(document.createTextNode(" String "));
var rad = document.createElement("input");
rad.setAttribute("type","radio");
rad.setAttribute("name","soymacros"+x+"type"+i);
rad.setAttribute("id","soymacros"+x+"type"+i+"E");
td.appendChild(rad);
td.appendChild(document.createTextNode(" Expression "));
tr.appendChild(td);// Field A
var td = document.createElement("td");
var f1 = document.createElement("input");
f1.setAttribute("type","text");
f1.setAttribute("id","soymacros"+x+"fieldA"+i);
td.appendChild(f1);
tr.appendChild(td);// Field B
var td = document.createElement("td");
var f1 = document.createElement("input");
f1.setAttribute("type","text");
f1.setAttribute("id","soymacros"+x+"fieldB"+i);
td.appendChild(f1);
tr.appendChild(td);table.appendChild(tr);
}
macrobar.appendChild(table);var p = document.createElement("p");
var save = document.createElement("input");
save.setAttribute("type","button");
save.setAttribute("value","Save");
save.setAttribute("title","Save any edits to the macro configuration.");
save.setAttribute("onclick","macrobarSave("+x+");");
p.appendChild(save);
p.appendChild(document.createTextNode(" "));
var guide = document.createElement("a");
guide.setAttribute("href","https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions");
guide.setAttribute("target","_blank");
guide.appendChild(document.createTextNode("Regexp Guide"));
p.appendChild(guide);
macrobar.appendChild(p);toolbar.parentNode.insertBefore(macrobar, toolbar.nextSibling);
}var temp = document.createElement("script");
// Add selection handling function
temp.appendChild(document.createTextNode("function getSelection(textarea) { if ('selectionStart' in textarea) { if (textarea.selectionStart != textarea.selectionEnd) { return [textarea.selectionStart,textarea.selectionEnd]; } } } "));// Add comment formatting buttons
temp.appendChild(document.createTextNode("function addBlockquote(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<blockquote>'+area.value.substring(sel[0],sel[1])+'<\/blockquote>' + area.value.substring(sel[1]); } } function addPara(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<p>'+area.value.substring(sel[0],sel[1])+'<\/p>' + area.value.substring(sel[1]); } } function addBreak(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<br>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHRule(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<hr>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHyperlink(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { url = prompt('URL:', 'https://'); area.value = area.value.substring(0,sel[0]) + '<a href=\"'+url+'\">'+area.value.substring(sel[0],sel[1])+'<\/a>' + area.value.substring(sel[1]); } } function addBold(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<b>'+area.value.substring(sel[0],sel[1])+'<\/b>' + area.value.substring(sel[1]); } } function addItalic(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<em>'+area.value.substring(sel[0],sel[1])+'<\/em>' + area.value.substring(sel[1]); } } function addStrike(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<strike>'+area.value.substring(sel[0],sel[1])+'<\/strike>' + area.value.substring(sel[1]); } } function addEcode(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<ecode>'+area.value.substring(sel[0],sel[1])+'<\/ecode>' + area.value.substring(sel[1]); } } function addTT(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<tt>'+area.value.substring(sel[0],sel[1])+'<\/tt>' + area.value.substring(sel[1]); } } function addSmall(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<small>'+area.value.substring(sel[0],sel[1])+'<\/small>' + area.value.substring(sel[1]); } } function addSuper(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sup>'+area.value.substring(sel[0],sel[1])+'<\/sup>' + area.value.substring(sel[1]); } } function addSubsc(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sub>'+area.value.substring(sel[0],sel[1])+'<\/sub>' + area.value.substring(sel[1]); } } "));// Add list creation functions
temp.appendChild(document.createTextNode("function addOrdlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ol><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>').replace(/\\n<li><\\/li>/g,'') + '<\/li><\/ol>' + area.value.substring(area.selectionEnd); } else { temp = '<ol>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>\\n'; } area.value = area.value.substring(0,area.selectionStart) + temp.substring(0,temp.length-1) + '<\/ol>' + area.value.substring(area.selectionStart); } } } function addUnordlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ul><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>').replace(/\\n<li><\\/li>/g,'') + '<\/li><\/ul>' + area.value.substring(area.selectionEnd); } else { temp = '<ul>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>\\n'; } area.value = area.value.substring(0,area.selectionStart) + temp.substring(0,temp.length-1) + '<\/ul>' + area.value.substring(area.selectionStart); } } }"));// Add macro functions
temp.appendChild(document.createTextNode("function macroChoose(area,x) { if (JSON.parse(localStorage.getItem('soymacro'+x))[1]=='string') { macroString(area,x); } else { macroRegexp(area,x); } }"));
temp.appendChild(document.createTextNode("function macroString(area,x) { var sel = getSelection(area); if (sel && sel[0] != sel[1]) { area.value = area.value.substring(0,sel[0]) + JSON.parse(localStorage.getItem('soymacro'+x))[2] + area.value.substring(sel[1]); } else if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + JSON.parse(localStorage.getItem('soymacro'+x))[2] + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+JSON.parse(localStorage.getItem('soymacro'+x))[2].length,pos+JSON.parse(localStorage.getItem('soymacro'+x))[2].length); } }"));
temp.appendChild(document.createTextNode("function macroRegexp(area,x) { var sel = getSelection(area); if (sel && sel[0] != sel[1]) { var reg = JSON.parse(localStorage.getItem('soymacro'+x))[2]; area.value = area.value.substring(0,sel[0]) + area.value.substring(sel[0],sel[1]).replace(new RegExp(reg.substring(reg.indexOf('/')+1,reg.lastIndexOf('/')), reg.substring(reg.lastIndexOf('/')+1)),JSON.parse(localStorage.getItem('soymacro'+x))[3]) + area.value.substring(sel[1]); } }"));
temp.appendChild(document.createTextNode("function macrobarInit(x) { for (var y=1; y<=5; y++) { document.getElementById('soymacros'+x+'name'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[0]; if (JSON.parse(localStorage.getItem('soymacro'+y))[1]=='string') { document.getElementById('soymacros'+x+'type'+y+'S').checked = true; } else { document.getElementById('soymacros'+x+'type'+y+'E').checked = true; } document.getElementById('soymacros'+x+'fieldA'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[2]; if (JSON.parse(localStorage.getItem('soymacro'+y))[1]!='string') { document.getElementById('soymacros'+x+'fieldB'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[3]; } else { document.getElementById('soymacros'+x+'fieldB'+y).value = ''; } } }"));
temp.appendChild(document.createTextNode("function macrobarSave(x) { for (var y=1; y<=5; y++) { if (document.getElementById('soymacros'+x+'type'+y+'S').checked == true) { localStorage.setItem('soymacro'+y,JSON.stringify([document.getElementById('soymacros'+x+'name'+y).value,'string',document.getElementById('soymacros'+x+'fieldA'+y).value])); } else { localStorage.setItem('soymacro'+y,JSON.stringify([document.getElementById('soymacros'+x+'name'+y).value,'regexp',document.getElementById('soymacros'+x+'fieldA'+y).value,document.getElementById('soymacros'+x+'fieldB'+y).value])); } } document.getElementById('macrobar'+x).style.display = 'none'; var boxes = document.getElementsByTagName('textarea'); for (var z=0; z<boxes.length; z++) { for (var y=1; y<=5; y++) { document.getElementById('soymacros'+z+'button'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[0]; if (JSON.parse(localStorage.getItem('soymacro'+y))[1]=='string') { if (JSON.parse(localStorage.getItem('soymacro'+y))[2].length < 40) { document.getElementById('soymacros'+z+'button'+y).title = 'Insert or replace selected text with: ' + JSON.parse(localStorage.getItem('soymacro'+y))[2]; } else { document.getElementById('soymacros'+z+'button'+y).title = 'Insert or replace selected text with: ' + JSON.parse(localStorage.getItem('soymacro'+y))[2].substring(0,40)+'...'; } } else { document.getElementById('soymacros'+z+'button'+y).title = 'Replace text matched by the regular expression: ' + JSON.parse(localStorage.getItem('soymacro'+y))[2] + ' with: ' + JSON.parse(localStorage.getItem('soymacro'+y))[3]; } } } }"));// Add despace function
temp.appendChild(document.createTextNode("function despace(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + area.value.substring(sel[0],sel[1]).replace(/\\r/g,' ').replace(/\\n/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ') + area.value.substring(sel[1]); } }"));// Add unicode insertion function
temp.appendChild(document.createTextNode("function addSmile(area, smile) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,pos) + smile + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+smile.length,pos+smile.length) } }"));document.getElementsByTagName('head')[0].appendChild(temp); // Add script to page
// ==UserScript==
// @name Soylent Upgrade
// @match http://soylentnews.org/article.pl*
// @match https://soylentnews.org/article.pl*
// @match http://soylentnews.org/submit.pl*
// @match https://soylentnews.org/submit.pl*
// @match http://soylentnews.org/admin.pl*
// @match https://soylentnews.org/admin.pl*
// @match http://soylentnews.org/comments.pl*
// @match https://soylentnews.org/comments.pl*
// @match http://soylentnews.org/journal.pl*
// @match https://soylentnews.org/journal.pl*
// ==/UserScript==/* ! http://mths.be/fromcodepoint v0.1.0 by @mathias */
if (!String.fromCodePoint) { (function() { var defineProperty = (function() { try { var object = {}; var $defineProperty = Object.defineProperty; var result = $defineProperty(object, object, object) && $defineProperty; } catch(error) {} return result; }()); var stringFromCharCode = String.fromCharCode; var floor = Math.floor; var fromCodePoint = function() { var MAX_SIZE = 0x4000; var codeUnits = []; var highSurrogate; var lowSurrogate; var index = -1; var length = arguments.length; if (!length) { return ''; } var result = ''; while (++index < length) { var codePoint = Number(arguments[index]); if ( !isFinite(codePoint) || codePoint < 0 || codePoint > 0x10FFFF || floor(codePoint) != codePoint ) { throw RangeError('Invalid code point: ' + codePoint); } if (codePoint <= 0xFFFF) { codeUnits.push(codePoint); } else { codePoint -= 0x10000; highSurrogate = (codePoint >> 10) + 0xD800; lowSurrogate = (codePoint % 0x400) + 0xDC00; codeUnits.push(highSurrogate, lowSurrogate); } if (index + 1 == length || codeUnits.length > MAX_SIZE) { result += stringFromCharCode.apply(null, codeUnits); codeUnits.length = 0; } } return result; }; if (defineProperty) { defineProperty(String, 'fromCodePoint', { 'value': fromCodePoint, 'configurable': true, 'writable': true }); } else { String.fromCodePoint = fromCodePoint; } }()); }// Add "Quote This" buttons to all initially visible comments
var spans = document.getElementsByTagName("span");
for (var x=0; x<spans.length; x++)
{
if (spans[x].id.indexOf("reply_link_")==0)
{
var button = document.createElement("span");
button.setAttribute("class","nbutton");
var p = document.createElement("p");
var b = document.createElement("b");
var a = document.createElement("a");
// Set the href of the "Quote This" button to the href of the "Reply to This" button, with the escaped contents of the post added to URL and any [domain.names] following links in the post cut out:
a.setAttribute("href",spans[x].getElementsByTagName("a")[0].href.replace("#post_comment","&postercomment="+escape("<blockquote>"+document.getElementById("comment_body_"+spans[x].id.replace("reply_link_","")).innerHTML.replace(/<\/a>\s\[.*?\..*?\]/g,"<\/a>")+"<\/blockquote>\n\n")+"#post_comment"));
// To Do: Shorten URLs longer than 2000 characters
a.appendChild(document.createTextNode("Quote This"));
b.appendChild(a);
p.appendChild(b);
button.appendChild(p);
spans[x].parentNode.insertBefore(button, spans[x].nextSibling);
spans[x].parentNode.insertBefore(document.createTextNode(" "), spans[x].nextSibling); // Divider
}
}var simplifyChars = true; // Change to false if you don't want stylized quotation marks, ellipses, etc. to be replaced
var boxes = document.getElementsByTagName("textarea");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var temp = boxes[x].value; // Retrieve textarea contents
temp = temp.replace(/<\/p><p>/g,"<\/p>\n\n<p>"); // Add newlines between paragraphs
temp = temp.replace(/<br>\s?<br>/g,"<\/p>\n\n<p>"); // Convert double break tags to paragraph tags
temp = temp.replace(/<\/blockquote><p>/g,"<\/blockquote>\n\n<p>"); // Add newlines after blockquotes
temp = temp.replace(/<\/p><blockquote>/g,"<\/p>\n\n<blockquote>"); // Add newlines before blockquotes
temp = temp.replace(/<blockquote><div><p>/g,"<blockquote><div>\n\n<p>"); // Add newlines within start of blockquotes
temp = temp.replace(/<\/p><\/div><\/blockquote>/g,"<\/p>\n\n<\/div><\/blockquote>"); // Add newlines within end of blockquotes
temp = temp.replace(/<\/blockquote><blockquote>/g,"<\/blockquote>\n\n<blockquote>"); // Add newlines between two blockquotes
temp = temp.replace(/<p class="byline">\s/i,"<p class=\"byline\">"); // Remove extra space from byline
temp = temp.replace(/<p>\s/g,"<p>"); // Remove extra space from start of paragraph
temp = temp.replace(/\s<\/p>/g,"<\/p>"); // Remove extra space from end of paragraph
temp = temp.replace(/<\/li><li>/g,"<\/li>\n<li>"); // Add newlines between list items
temp = temp.replace(/<\/li><\/ul>/g,"<\/li>\n(<\/ul>|<\/ol>)"); // Add newline after last list item
temp = temp.replace(/<\/p><ul>/g,"<\/p>\n\n(<ul>|<ol>)"); // Add newlines before lists
temp = temp.replace(/<p>\[...\]/g,"<p>[...] "); // Add space within beginning of foreshortened paragraph
while (temp.indexOf(" ")!=-1)
{
temp = temp.replace(/ /g," "); // Replace double spaces with single spaces
}
if (simplifyChars)
{
temp = temp.replace(/\u2018/g,"'"); // 'LEFT SINGLE QUOTATION MARK' (U+2018) to (U+0027)
temp = temp.replace(/\u2019/g,"'"); // 'RIGHT SINGLE QUOTATION MARK' (U+2019) to (U+0027)
temp = temp.replace(/\u201C/g,"\""); // 'LEFT DOUBLE QUOTATION MARK' (U+201C) to (U+0022)
temp = temp.replace(/\u201D/g,"\""); // 'RIGHT DOUBLE QUOTATION MARK' (U+201D) to (U+0022)
temp = temp.replace(/\u2026/g,"..."); // 'HORIZONTAL ELLIPSIS' (U+2026) to (U+002E) x3
}
boxes[x].value = temp;
boxes[x].rows = 32; // Expand textarea height to 32 rows
}
var toolbar = document.createElement("div");// Blockquote button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Blockquote");
tempbutton.setAttribute("title","Wrap \u003Cblockquote\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addBlockquote(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Paragraph and Line break buttons
var tempspan = document.createElement("span");
tempspan.setAttribute("id","htmlFormatButtons");
if (document.getElementById("posttype") && document.getElementById("posttype").selectedIndex == 0)
{
tempspan.setAttribute("style","display:none;"); // Hide if initial post type option is "Plain Old Text"
}
if (document.getElementById("posttype"))
{
document.getElementById("posttype").addEventListener("change", function() {if (document.getElementById('posttype').selectedIndex == 0) {document.getElementById('htmlFormatButtons').style.display = 'none'} else {document.getElementById('htmlFormatButtons').style.display = 'inline'}}); // Change visibility of these buttons based on value of post type
}
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","P");
tempbutton.setAttribute("title","Wrap \u003Cp\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addPara(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","BR");
tempbutton.setAttribute("title","Insert a line break.");
tempbutton.setAttribute("onclick","addBreak(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);// HR button, if editing a story
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","HR");
tempbutton.setAttribute("title","Insert a horizontal rule.");
tempbutton.setAttribute("style","text-decoration:underline overline;");
tempbutton.setAttribute("onclick","addHRule(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);
}// URL button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","URL");
tempbutton.setAttribute("title","Create a hyperlink around the selected text.");
tempbutton.setAttribute("style","text-decoration:underline;");
tempbutton.setAttribute("onclick","addHyperlink(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));// Bold button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","B");
tempbutton.setAttribute("title","Bold");
tempbutton.setAttribute("style","font-weight:bold;");
tempbutton.setAttribute("onclick","addBold(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Italic button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","I");
tempbutton.setAttribute("title","Italic");
tempbutton.setAttribute("style","font-style:italic;");
tempbutton.setAttribute("onclick","addItalic(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Strike button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","S");
tempbutton.setAttribute("title","Strikethrough");
tempbutton.setAttribute("style","text-decoration:line-through;");
tempbutton.setAttribute("onclick","addStrike(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Code button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Code");
tempbutton.setAttribute("title","Wrap \u003Cecode\u003E tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addEcode(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Teletype button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","TT");
tempbutton.setAttribute("title","Wrap \u003Ctt\u003E (teletype, ie. monospace) tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addTT(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Small button, if editing a story
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u0073\u1D0D\u1D00\u029F\u029F");
tempbutton.setAttribute("title","Wrap \u003Csmall\u003E tags around the selected text.");
// tempbutton.setAttribute("style","font-size:75%;");
tempbutton.setAttribute("onclick","addSmall(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
}toolbar.appendChild(document.createTextNode(" ")); // Divider
// Superscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u00B2");
tempbutton.setAttribute("title","Superscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSuper(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Subscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u2082");
tempbutton.setAttribute("title","Subscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSubsc(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Ordered list button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","1. List");
tempbutton.setAttribute("title","Insert an ordered list or convert newline-separated text into an ordered list.");
tempbutton.setAttribute("onclick","addOrdlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Unordered list button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u2022 List");
tempbutton.setAttribute("title","Insert an unordered list or convert newline-separated text into an unordered list.");
tempbutton.setAttribute("onclick","addUnordlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createElement("br")); // Divider
// Despace button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Despace");
tempbutton.setAttribute("title","Delete newlines within the selection.");
tempbutton.setAttribute("onclick","despace(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Symbol button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value",":-)");
tempbutton.setAttribute("title","Insert a symbol.");
tempbutton.setAttribute("onclick","if (document.getElementById('smilebar"+x+"').style.display == 'none') {document.getElementById('smilebar"+x+"').style.display = 'block'} else {document.getElementById('smilebar"+x+"').style.display = 'none'; if (p = document.getElementById('postercomment')) { var x = p.offsetTop; while (p = p.offsetParent) {x += p.offsetLeft;} window.scrollTo(0,x-75);} }");
toolbar.appendChild(tempbutton);
boxes[x].parentNode.insertBefore(toolbar, boxes[x].nextSibling);// Symbol list
var smilebar = document.createElement("div");
smilebar.setAttribute("style","-moz-user-select:none; -webkit-user-select:none; display:none; font-size:16pt; max-height:240px; overflow:auto; padding:0.5em;");
smilebar.setAttribute("id","smilebar"+x);
var smiles = ["<",">"];var codes = [[161,169],[171,172],[174],[176,177],[180,183],[187,191],[215],[224,255],[402],[629],[632],[916],[920],[931],[934],[937],[945,946],[956],[960],[963],[8216,8221],[8226],[8230],[8251],[8364],[8478],[8482],[8528,8542],[8585],[8712,8716],[8721],[8730],[8733,8734],[8736],[8743,8749],[8756,8757],[8773],[8776],[8800,8805],[8834,8837],[8984],[9760],[9762,9765],[9770],[9773,9775],[9784,9794],[9812,9831],[9833,9842],[9850],[9855,9861],[9874,9877],[9882,9885],[9888,9893],[9913],[9940],[9962],[9971],[9981],[9992,10087],[65533],[127744,127756],[127759],[127775,127776],[127797],[127801],[127804,127812],[127817],[127820,127822],[127828,127831],[127838,127839],[127843],[127849],[127855],[127860,127867],[127891],[127904,127911],[127918],[127939],[127942],[127977],[128025],[128074,128078],[128123,128131],[128137,128142],[128148,128150],[128152],[128158],[128161,128164],[128168,128170],[128172],[128176,128177],[128187],[128189,128190],[128193,128194],[128197],[128203,128204],[128206],[128214],[128225,128227],[128231,128233],[128241],[128244],[128246],[128250,128252],[128259],[128266,128270],[128273,128276],[128278,128280],[128286],[128293,128299],[128302,128303],[128509,128510],[128659],[128684,128685]];
for (var i=0; i<codes.length; i++) { if (codes[i].length > 1) { for (var j=codes[i][0]; j<=codes[i][1]; j++) { smiles[smiles.length] = String.fromCodePoint(j); } } else { smiles[smiles.length] = String.fromCodePoint(codes[i][0]); } } // Populate smiles array with code ranges converted to individual characters
smiles = smiles.concat(["xD",":-)",":^)","(^_^;)","\u0028\u00A0\u0361\u00B0\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029","\u0028\u00A0\u0361\u007E\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029\uFEFF","\u00AF\u005C\u005F\u0028\u30C4\u0029\u005F\u002F\u00AF","\u0028\u256F\u00B0\u25A1\u00B0\uFF09\u256F\uFE35\u00A0\u253B\u2501\u253B","\u0028\u30CE\u0CA0\u76CA\u0CA0\u0029\u30CE\u5F61\u253B\u2501\u253B","\u0028\u0060\uFF65\u03C9\uFF65\u00B4\u0029","\u0CA0_\u0CA0","\u0295\u2022\u1D25\u2022\u0294","\u0028\u3065\uFFE3\u00A0\u00B3\uFFE3\u0029\u3065","\u0669\u0028\u204E\u275B\u1D17\u275B\u204E\u0029\u06F6","\u30FD\u0F3C\u0E88\u0644\u035C\u0E88\u0F3D\uFF89"]); // Add in arbitrary emoticons
for (var i=0; i<smiles.length; i++)
{
var smile = document.createElement("span");
smile.setAttribute("style","cursor:pointer; padding:2px; white-space:nowrap;");
smile.setAttribute("onclick","addSmile(document.getElementsByTagName('textarea')["+x+"],'"+smiles[i].replace("\u005C","\u005C\u005C")+"');");
smile.appendChild(document.createTextNode(smiles[i]));
smilebar.appendChild(smile);
if (i+1<smiles.length)
{
smilebar.appendChild(document.createTextNode(" "));
}
}
toolbar.parentNode.insertBefore(smilebar, toolbar.nextSibling);
}var temp = document.createElement("script");
// Add selection handling function
temp.appendChild(document.createTextNode("function getSelection(textarea) { if ('selectionStart' in textarea) { if (textarea.selectionStart != textarea.selectionEnd) { return [textarea.selectionStart,textarea.selectionEnd]; } } } "));// Add comment formatting buttons
temp.appendChild(document.createTextNode("function addBlockquote(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<blockquote>'+area.value.substring(sel[0],sel[1])+'<\/blockquote>' + area.value.substring(sel[1]); } } function addPara(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<p>'+area.value.substring(sel[0],sel[1])+'<\/p>' + area.value.substring(sel[1]); } } function addBreak(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<br>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHRule(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<hr>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHyperlink(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { url = prompt('URL:', 'https://'); area.value = area.value.substring(0,sel[0]) + '<a href=\"'+url+'\">'+area.value.substring(sel[0],sel[1])+'<\/a>' + area.value.substring(sel[1]); } } function addBold(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<b>'+area.value.substring(sel[0],sel[1])+'<\/b>' + area.value.substring(sel[1]); } } function addItalic(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<em>'+area.value.substring(sel[0],sel[1])+'<\/em>' + area.value.substring(sel[1]); } } function addStrike(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<strike>'+area.value.substring(sel[0],sel[1])+'<\/strike>' + area.value.substring(sel[1]); } } function addEcode(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<ecode>'+area.value.substring(sel[0],sel[1])+'<\/ecode>' + area.value.substring(sel[1]); } } function addTT(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<tt>'+area.value.substring(sel[0],sel[1])+'<\/tt>' + area.value.substring(sel[1]); } } function addSmall(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<small>'+area.value.substring(sel[0],sel[1])+'<\/small>' + area.value.substring(sel[1]); } } function addSuper(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sup>'+area.value.substring(sel[0],sel[1])+'<\/sup>' + area.value.substring(sel[1]); } } function addSubsc(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sub>'+area.value.substring(sel[0],sel[1])+'<\/sub>' + area.value.substring(sel[1]); } } "));// Add list creation functions
temp.appendChild(document.createTextNode("function addOrdlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ol><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>').replace(/\\n<li><\\/li>/g,'') + '<\/li><\/ol>' + area.value.substring(area.selectionEnd); } else { temp = '<ol>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>\\n'; } area.value = area.value.substring(0,area.selectionStart) + temp.substring(0,temp.length-1) + '<\/ol>' + area.value.substring(area.selectionStart); } } } function addUnordlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ul><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>').replace(/\\n<li><\\/li>/g,'') + '<\/li><\/ul>' + area.value.substring(area.selectionEnd); } else { temp = '<ul>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>\\n'; } area.value = area.value.substring(0,area.selectionStart) + temp.substring(0,temp.length-1) + '<\/ul>' + area.value.substring(area.selectionStart); } } }"));// Add despace function
temp.appendChild(document.createTextNode("function despace(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + area.value.substring(sel[0],sel[1]).replace(/\\r/g,' ').replace(/\\n/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ') + area.value.substring(sel[1]); } }"));// Add unicode insertion function
temp.appendChild(document.createTextNode("function addSmile(area, smile) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,pos) + smile + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+smile.length,pos+smile.length) } }"));document.getElementsByTagName('head')[0].appendChild(temp); // Add script to page
// ==UserScript==
// @name Soylent Upgrade
// @match http://soylentnews.org/article.pl*
// @match https://soylentnews.org/article.pl*
// @match http://soylentnews.org/submit.pl*
// @match https://soylentnews.org/submit.pl*
// @match http://soylentnews.org/admin.pl*
// @match https://soylentnews.org/admin.pl*
// @match http://soylentnews.org/comments.pl*
// @match https://soylentnews.org/comments.pl*
// @match http://soylentnews.org/journal.pl*
// @match https://soylentnews.org/journal.pl*
// ==/UserScript==/* ! http://mths.be/fromcodepoint v0.1.0 by @mathias */
if (!String.fromCodePoint) { (function() { var defineProperty = (function() { try { var object = {}; var $defineProperty = Object.defineProperty; var result = $defineProperty(object, object, object) && $defineProperty; } catch(error) {} return result; }()); var stringFromCharCode = String.fromCharCode; var floor = Math.floor; var fromCodePoint = function() { var MAX_SIZE = 0x4000; var codeUnits = []; var highSurrogate; var lowSurrogate; var index = -1; var length = arguments.length; if (!length) { return ''; } var result = ''; while (++index < length) { var codePoint = Number(arguments[index]); if ( !isFinite(codePoint) || codePoint < 0 || codePoint > 0x10FFFF || floor(codePoint) != codePoint ) { throw RangeError('Invalid code point: ' + codePoint); } if (codePoint <= 0xFFFF) { codeUnits.push(codePoint); } else { codePoint -= 0x10000; highSurrogate = (codePoint >> 10) + 0xD800; lowSurrogate = (codePoint % 0x400) + 0xDC00; codeUnits.push(highSurrogate, lowSurrogate); } if (index + 1 == length || codeUnits.length > MAX_SIZE) { result += stringFromCharCode.apply(null, codeUnits); codeUnits.length = 0; } } return result; }; if (defineProperty) { defineProperty(String, 'fromCodePoint', { 'value': fromCodePoint, 'configurable': true, 'writable': true }); } else { String.fromCodePoint = fromCodePoint; } }()); }// Add "Quote This" buttons to all initially visible comments
var spans = document.getElementsByTagName("span");
for (var x=0; x<spans.length; x++)
{
if (spans[x].id.indexOf("reply_link_")==0)
{
var button = document.createElement("span");
button.setAttribute("class","nbutton");
var p = document.createElement("p");
var b = document.createElement("b");
var a = document.createElement("a");
// Set the href of the "Quote This" button to the href of the "Reply to This" button, with the escaped contents of the post added to URL and any [domain.names] following links in the post cut out:
a.setAttribute("href",spans[x].getElementsByTagName("a")[0].href.replace("#post_comment","&postercomment="+escape("<blockquote>"+document.getElementById("comment_body_"+spans[x].id.replace("reply_link_","")).innerHTML.replace(/<\/a>\s\[.*?\..*?\]/g,"<\/a>")+"<\/blockquote>\n\n")+"#post_comment"));
// To Do: Shorten URLs longer than 2000 characters
a.appendChild(document.createTextNode("Quote This"));
b.appendChild(a);
p.appendChild(b);
button.appendChild(p);
spans[x].parentNode.insertBefore(button, spans[x].nextSibling);
spans[x].parentNode.insertBefore(document.createTextNode(" "), spans[x].nextSibling); // Divider
}
}var simplifyChars = true; // Change to false if you don't want stylized quotation marks, ellipses, etc. to be replaced
var addSublink = true; // Change to false if you don't want to automatically replace "writes" in the byline with a link to the original submissionvar boxes = document.getElementsByTagName("textarea");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var temp = boxes[x].value; // Retrieve textarea contents
temp = temp.replace(/<\/p><p>/g,"<\/p>\n\n<p>"); // Add newlines between paragraphs
temp = temp.replace(/<br>\s?<br>/g,"<\/p>\n\n<p>"); // Convert double break tags to paragraph tags
temp = temp.replace(/<\/blockquote><p>/g,"<\/blockquote>\n\n<p>"); // Add newlines after blockquotes
temp = temp.replace(/<\/p><blockquote>/g,"<\/p>\n\n<blockquote>"); // Add newlines before blockquotes
temp = temp.replace(/<blockquote><div><p>/g,"<blockquote><div>\n\n<p>"); // Add newlines within start of blockquotes
temp = temp.replace(/<\/p><\/div><\/blockquote>/g,"<\/p>\n\n<\/div><\/blockquote>"); // Add newlines within end of blockquotes
temp = temp.replace(/<\/blockquote><blockquote>/g,"<\/blockquote>\n\n<blockquote>"); // Add newlines between two blockquotes
temp = temp.replace(/<p class="byline">\s/i,"<p class=\"byline\">"); // Remove extra space from byline
temp = temp.replace(/<p>\s/g,"<p>"); // Remove extra space from start of paragraph
temp = temp.replace(/\s<\/p>/g,"<\/p>"); // Remove extra space from end of paragraph
temp = temp.replace(/<\/li><li>/g,"<\/li>\n<li>"); // Add newlines between list items
temp = temp.replace(/<\/li><\/ul>/g,"<\/li>\n(<\/ul>|<\/ol>)"); // Add newline after last list item
temp = temp.replace(/<\/p><ul>/g,"<\/p>\n\n(<ul>|<ol>)"); // Add newlines before lists
temp = temp.replace(/<p>\[...\]/g,"<p>[...] "); // Add space within beginning of foreshortened paragraph
while (temp.indexOf(" ")!=-1)
{
temp = temp.replace(/ /g," "); // Replace double spaces with single spaces
}
if (simplifyChars)
{
temp = temp.replace(/\u2018/g,"'"); // 'LEFT SINGLE QUOTATION MARK' (U+2018) to (U+0027)
temp = temp.replace(/\u2019/g,"'"); // 'RIGHT SINGLE QUOTATION MARK' (U+2019) to (U+0027)
temp = temp.replace(/\u201C/g,"\""); // 'LEFT DOUBLE QUOTATION MARK' (U+201C) to (U+0022)
temp = temp.replace(/\u201D/g,"\""); // 'RIGHT DOUBLE QUOTATION MARK' (U+201D) to (U+0022)
temp = temp.replace(/\u2026/g,"..."); // 'HORIZONTAL ELLIPSIS' (U+2026) to (U+002E) x3
}
if (addSublink)
{
if (document.getElementById("slashstoryform"))
{
var subid = document.getElementById("slashstoryform").elements["subid"].value;
temp = temp.replace(/<p class="byline">(.*?)\s(writes):/g,"<p class=\"byline\">$1 <a href=\"http://soylentnews.org/submit.pl?op=viewsub&subid="+subid+"\">$2</a>:");
}
else if (document.getElementById("adminform"))
{
var subid = document.getElementById("adminform").elements["subid"].value;
temp = temp.replace(/<p class="byline">(.*?)\s(writes):/g,"<p class=\"byline\">$1 <a href=\"http://soylentnews.org/submit.pl?op=viewsub&subid="+subid+"\">$2</a>:");
}}
boxes[x].value = temp;
boxes[x].rows = 32; // Expand textarea height to 32 rows
}
var toolbar = document.createElement("div");// Blockquote button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Blockquote");
tempbutton.setAttribute("title","Wrap \u003Cblockquote\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addBlockquote(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Paragraph and Line break buttons
var tempspan = document.createElement("span");
tempspan.setAttribute("id","htmlFormatButtons");
if (document.getElementById("posttype") && document.getElementById("posttype").selectedIndex == 0)
{
tempspan.setAttribute("style","display:none;"); // Hide if initial post type option is "Plain Old Text"
}
if (document.getElementById("posttype"))
{
document.getElementById("posttype").addEventListener("change", function() {if (document.getElementById('posttype').selectedIndex == 0) {document.getElementById('htmlFormatButtons').style.display = 'none'} else {document.getElementById('htmlFormatButtons').style.display = 'inline'}}); // Change visibility of these buttons based on value of post type
}
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","P");
tempbutton.setAttribute("title","Wrap \u003Cp\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addPara(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","BR");
tempbutton.setAttribute("title","Insert a line break.");
tempbutton.setAttribute("onclick","addBreak(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);// HR button, if editing a story
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","HR");
tempbutton.setAttribute("title","Insert a horizontal rule.");
tempbutton.setAttribute("style","text-decoration:underline overline;");
tempbutton.setAttribute("onclick","addHRule(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);
}// URL button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","URL");
tempbutton.setAttribute("title","Create a hyperlink around the selected text.");
tempbutton.setAttribute("style","text-decoration:underline;");
tempbutton.setAttribute("onclick","addHyperlink(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));// Bold button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","B");
tempbutton.setAttribute("title","Bold");
tempbutton.setAttribute("style","font-weight:bold;");
tempbutton.setAttribute("onclick","addBold(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Italic button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","I");
tempbutton.setAttribute("title","Italic");
tempbutton.setAttribute("style","font-style:italic;");
tempbutton.setAttribute("onclick","addItalic(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Strike button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","S");
tempbutton.setAttribute("title","Strikethrough");
tempbutton.setAttribute("style","text-decoration:line-through;");
tempbutton.setAttribute("onclick","addStrike(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Code button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Code");
tempbutton.setAttribute("title","Wrap \u003Cecode\u003E tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addEcode(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Teletype button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","TT");
tempbutton.setAttribute("title","Wrap \u003Ctt\u003E (teletype, ie. monospace) tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addTT(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Small button, if editing a story
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u0073\u1D0D\u1D00\u029F\u029F");
tempbutton.setAttribute("title","Wrap \u003Csmall\u003E tags around the selected text.");
// tempbutton.setAttribute("style","font-size:75%;");
tempbutton.setAttribute("onclick","addSmall(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
}toolbar.appendChild(document.createTextNode(" ")); // Divider
// Superscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u00B2");
tempbutton.setAttribute("title","Superscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSuper(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Subscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u2082");
tempbutton.setAttribute("title","Subscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSubsc(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Ordered list button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","1. List");
tempbutton.setAttribute("title","Insert an ordered list or convert newline-separated text into an ordered list.");
tempbutton.setAttribute("onclick","addOrdlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Unordered list button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u2022 List");
tempbutton.setAttribute("title","Insert an unordered list or convert newline-separated text into an unordered list.");
tempbutton.setAttribute("onclick","addUnordlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createElement("br")); // Divider
// Despace button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Despace");
tempbutton.setAttribute("title","Delete newlines within the selection.");
tempbutton.setAttribute("onclick","despace(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Symbol button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value",":-)");
tempbutton.setAttribute("title","Insert a symbol.");
tempbutton.setAttribute("onclick","if (document.getElementById('smilebar"+x+"').style.display == 'none') {document.getElementById('smilebar"+x+"').style.display = 'block'} else {document.getElementById('smilebar"+x+"').style.display = 'none'; if (p = document.getElementById('postercomment')) { var x = p.offsetTop; while (p = p.offsetParent) {x += p.offsetLeft;} window.scrollTo(0,x-75);} }");
toolbar.appendChild(tempbutton);
boxes[x].parentNode.insertBefore(toolbar, boxes[x].nextSibling);// Symbol list
var smilebar = document.createElement("div");
smilebar.setAttribute("style","-moz-user-select:none; -webkit-user-select:none; display:none; font-size:16pt; max-height:240px; overflow:auto; padding:0.5em;");
smilebar.setAttribute("id","smilebar"+x);
var smiles = ["<",">"];var codes = [[161,169],[171,172],[174],[176,177],[180,183],[187,191],[215],[224,255],[402],[629],[632],[916],[920],[931],[934],[937],[945,946],[956],[960],[963],[8216,8221],[8226],[8230],[8251],[8364],[8478],[8482],[8528,8542],[8585],[8712,8716],[8721],[8730],[8733,8734],[8736],[8743,8749],[8756,8757],[8773],[8776],[8800,8805],[8834,8837],[8984],[9760],[9762,9765],[9770],[9773,9775],[9784,9794],[9812,9831],[9833,9842],[9850],[9855,9861],[9874,9877],[9882,9885],[9888,9893],[9913],[9940],[9962],[9971],[9981],[9992,10087],[65533],[127744,127756],[127759],[127775,127776],[127797],[127801],[127804,127812],[127817],[127820,127822],[127828,127831],[127838,127839],[127843],[127849],[127855],[127860,127867],[127891],[127904,127911],[127918],[127939],[127942],[127977],[128025],[128074,128078],[128123,128131],[128137,128142],[128148,128150],[128152],[128158],[128161,128164],[128168,128170],[128172],[128176,128177],[128187],[128189,128190],[128193,128194],[128197],[128203,128204],[128206],[128214],[128225,128227],[128231,128233],[128241],[128244],[128246],[128250,128252],[128259],[128266,128270],[128273,128276],[128278,128280],[128286],[128293,128299],[128302,128303],[128509,128510],[128659],[128684,128685]];
for (var i=0; i<codes.length; i++) { if (codes[i].length > 1) { for (var j=codes[i][0]; j<=codes[i][1]; j++) { smiles[smiles.length] = String.fromCodePoint(j); } } else { smiles[smiles.length] = String.fromCodePoint(codes[i][0]); } } // Populate smiles array with code ranges converted to individual characters
smiles = smiles.concat(["xD",":-)",":^)","(^_^;)","\u0028\u00A0\u0361\u00B0\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029","\u0028\u00A0\u0361\u007E\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029\uFEFF","\u00AF\u005C\u005F\u0028\u30C4\u0029\u005F\u002F\u00AF","\u0028\u256F\u00B0\u25A1\u00B0\uFF09\u256F\uFE35\u00A0\u253B\u2501\u253B","\u0028\u30CE\u0CA0\u76CA\u0CA0\u0029\u30CE\u5F61\u253B\u2501\u253B","\u0028\u0060\uFF65\u03C9\uFF65\u00B4\u0029","\u0CA0_\u0CA0","\u0295\u2022\u1D25\u2022\u0294","\u0028\u3065\uFFE3\u00A0\u00B3\uFFE3\u0029\u3065","\u0669\u0028\u204E\u275B\u1D17\u275B\u204E\u0029\u06F6","\u30FD\u0F3C\u0E88\u0644\u035C\u0E88\u0F3D\uFF89"]); // Add in arbitrary emoticons
for (var i=0; i<smiles.length; i++)
{
var smile = document.createElement("span");
smile.setAttribute("style","cursor:pointer; padding:2px; white-space:nowrap;");
smile.setAttribute("onclick","addSmile(document.getElementsByTagName('textarea')["+x+"],'"+smiles[i].replace("\u005C","\u005C\u005C")+"');");
smile.appendChild(document.createTextNode(smiles[i]));
smilebar.appendChild(smile);
if (i+1<smiles.length)
{
smilebar.appendChild(document.createTextNode(" "));
}
}
toolbar.parentNode.insertBefore(smilebar, toolbar.nextSibling);
}var temp = document.createElement("script");
// Add selection handling function
temp.appendChild(document.createTextNode("function getSelection(textarea) { if ('selectionStart' in textarea) { if (textarea.selectionStart != textarea.selectionEnd) { return [textarea.selectionStart,textarea.selectionEnd]; } } } "));// Add comment formatting buttons
temp.appendChild(document.createTextNode("function addBlockquote(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<blockquote>'+area.value.substring(sel[0],sel[1])+'<\/blockquote>' + area.value.substring(sel[1]); } } function addPara(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<p>'+area.value.substring(sel[0],sel[1])+'<\/p>' + area.value.substring(sel[1]); } } function addBreak(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<br>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHRule(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<hr>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHyperlink(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { url = prompt('URL:', 'https://'); area.value = area.value.substring(0,sel[0]) + '<a href=\"'+url+'\">'+area.value.substring(sel[0],sel[1])+'<\/a>' + area.value.substring(sel[1]); } } function addBold(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<b>'+area.value.substring(sel[0],sel[1])+'<\/b>' + area.value.substring(sel[1]); } } function addItalic(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<em>'+area.value.substring(sel[0],sel[1])+'<\/em>' + area.value.substring(sel[1]); } } function addStrike(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<strike>'+area.value.substring(sel[0],sel[1])+'<\/strike>' + area.value.substring(sel[1]); } } function addEcode(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<ecode>'+area.value.substring(sel[0],sel[1])+'<\/ecode>' + area.value.substring(sel[1]); } } function addTT(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<tt>'+area.value.substring(sel[0],sel[1])+'<\/tt>' + area.value.substring(sel[1]); } } function addSmall(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<small>'+area.value.substring(sel[0],sel[1])+'<\/small>' + area.value.substring(sel[1]); } } function addSuper(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sup>'+area.value.substring(sel[0],sel[1])+'<\/sup>' + area.value.substring(sel[1]); } } function addSubsc(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sub>'+area.value.substring(sel[0],sel[1])+'<\/sub>' + area.value.substring(sel[1]); } } "));// Add list creation functions
temp.appendChild(document.createTextNode("function addOrdlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ol><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>').replace(/\\n<li><\\/li>/g,'') + '<\/li><\/ol>' + area.value.substring(area.selectionEnd); } else { temp = '<ol>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>\\n'; } area.value = area.value.substring(0,area.selectionStart) + temp.substring(0,temp.length-1) + '<\/ol>' + area.value.substring(area.selectionStart); } } } function addUnordlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ul><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>').replace(/\\n<li><\\/li>/g,'') + '<\/li><\/ul>' + area.value.substring(area.selectionEnd); } else { temp = '<ul>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>\\n'; } area.value = area.value.substring(0,area.selectionStart) + temp.substring(0,temp.length-1) + '<\/ul>' + area.value.substring(area.selectionStart); } } }"));// Add despace function
temp.appendChild(document.createTextNode("function despace(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + area.value.substring(sel[0],sel[1]).replace(/\\r/g,' ').replace(/\\n/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ') + area.value.substring(sel[1]); } }"));// Add unicode insertion function
temp.appendChild(document.createTextNode("function addSmile(area, smile) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,pos) + smile + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+smile.length,pos+smile.length) } }"));document.getElementsByTagName('head')[0].appendChild(temp); // Add script to page
// ==UserScript==
// @name Soylent Upgrade
// @match http://soylentnews.org/article.pl*
// @match https://soylentnews.org/article.pl*
// @match http://soylentnews.org/submit.pl*
// @match https://soylentnews.org/submit.pl*
// @match http://soylentnews.org/admin.pl*
// @match https://soylentnews.org/admin.pl*
// @match http://soylentnews.org/comments.pl*
// @match https://soylentnews.org/comments.pl*
// @match http://soylentnews.org/journal.pl*
// @match https://soylentnews.org/journal.pl*
// ==/UserScript==/* ! http://mths.be/fromcodepoint v0.1.0 by @mathias */
if (!String.fromCodePoint) { (function() { var defineProperty = (function() { try { var object = {}; var $defineProperty = Object.defineProperty; var result = $defineProperty(object, object, object) && $defineProperty; } catch(error) {} return result; }()); var stringFromCharCode = String.fromCharCode; var floor = Math.floor; var fromCodePoint = function() { var MAX_SIZE = 0x4000; var codeUnits = []; var highSurrogate; var lowSurrogate; var index = -1; var length = arguments.length; if (!length) { return ''; } var result = ''; while (++index < length) { var codePoint = Number(arguments[index]); if ( !isFinite(codePoint) || codePoint < 0 || codePoint > 0x10FFFF || floor(codePoint) != codePoint ) { throw RangeError('Invalid code point: ' + codePoint); } if (codePoint <= 0xFFFF) { codeUnits.push(codePoint); } else { codePoint -= 0x10000; highSurrogate = (codePoint >> 10) + 0xD800; lowSurrogate = (codePoint % 0x400) + 0xDC00; codeUnits.push(highSurrogate, lowSurrogate); } if (index + 1 == length || codeUnits.length > MAX_SIZE) { result += stringFromCharCode.apply(null, codeUnits); codeUnits.length = 0; } } return result; }; if (defineProperty) { defineProperty(String, 'fromCodePoint', { 'value': fromCodePoint, 'configurable': true, 'writable': true }); } else { String.fromCodePoint = fromCodePoint; } }()); }// Add "Quote This" buttons to all initially visible comments
var spans = document.getElementsByTagName("span");
for (var x=0; x<spans.length; x++)
{
if (spans[x].id.indexOf("reply_link_")==0)
{
var button = document.createElement("span");
button.setAttribute("class","nbutton");
var p = document.createElement("p");
var b = document.createElement("b");
var a = document.createElement("a");
// Set the href of the "Quote This" button to the href of the "Reply to This" button, with the escaped contents of the post added to URL and any [domain.names] following links in the post cut out:
a.setAttribute("href",spans[x].getElementsByTagName("a")[0].href.replace("#post_comment","&postercomment="+escape("<blockquote>"+document.getElementById("comment_body_"+spans[x].id.replace("reply_link_","")).innerHTML.replace(/<\/a>\s\[.*?\..*?\]/g,"<\/a>")+"<\/blockquote>\n\n")+"#post_comment"));
// To Do: Shorten URLs longer than 2000 characters
a.appendChild(document.createTextNode("Quote This"));
b.appendChild(a);
p.appendChild(b);
button.appendChild(p);
spans[x].parentNode.insertBefore(button, spans[x].nextSibling);
spans[x].parentNode.insertBefore(document.createTextNode(" "), spans[x].nextSibling); // Divider
}
}var simplifyChars = true; // Change to false if you don't want stylized quotation marks, ellipses, etc. to be replaced
var boxes = document.getElementsByTagName("textarea");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var temp = boxes[x].value; // Retrieve textarea contents
temp = temp.replace(/<\/p><p>/g,"<\/p>\n\n<p>"); // Add newlines between paragraphs
temp = temp.replace(/<br>\s?<br>/g,"<\/p>\n\n<p>"); // Convert double break tags to paragraph tags
temp = temp.replace(/<\/blockquote><p>/g,"<\/blockquote>\n\n<p>"); // Add newlines after blockquotes
temp = temp.replace(/<\/p><blockquote>/g,"<\/p>\n\n<blockquote>"); // Add newlines before blockquotes
temp = temp.replace(/<blockquote><div><p>/g,"<blockquote><div>\n\n<p>"); // Add newlines within start of blockquotes
temp = temp.replace(/<\/p><\/div><\/blockquote>/g,"<\/p>\n\n<\/div><\/blockquote>"); // Add newlines within end of blockquotes
temp = temp.replace(/<\/blockquote><blockquote>/g,"<\/blockquote>\n\n<blockquote>"); // Add newlines between two blockquotes
temp = temp.replace(/<p class="byline">\s/i,"<p class=\"byline\">"); // Remove extra space from byline
temp = temp.replace(/<p>\s/g,"<p>"); // Remove extra space from start of paragraph
temp = temp.replace(/\s<\/p>/g,"<\/p>"); // Remove extra space from end of paragraph
temp = temp.replace(/<\/li><li>/g,"<\/li>\n<li>"); // Add newlines between list items
temp = temp.replace(/<\/li><\/ul>/g,"<\/li>\n(<\/ul>|<\/ol>)"); // Add newline after last list item
temp = temp.replace(/<\/p><ul>/g,"<\/p>\n\n(<ul>|<ol>)"); // Add newlines before lists
temp = temp.replace(/<p>\[...\]/g,"<p>[...] "); // Add space within beginning of foreshortened paragraph
while (temp.indexOf(" ")!=-1)
{
temp = temp.replace(/ /g," "); // Replace double spaces with single spaces
}
if (simplifyChars)
{
temp = temp.replace(/\u2018/g,"'"); // 'LEFT SINGLE QUOTATION MARK' (U+2018) to (U+0027)
temp = temp.replace(/\u2019/g,"'"); // 'RIGHT SINGLE QUOTATION MARK' (U+2019) to (U+0027)
temp = temp.replace(/\u201C/g,"\""); // 'LEFT DOUBLE QUOTATION MARK' (U+201C) to (U+0022)
temp = temp.replace(/\u201D/g,"\""); // 'RIGHT DOUBLE QUOTATION MARK' (U+201D) to (U+0022)
temp = temp.replace(/\u2026/g,"..."); // 'HORIZONTAL ELLIPSIS' (U+2026) to (U+002E) x3
}
boxes[x].value = temp;
boxes[x].rows = 32; // Expand textarea height to 32 rows
}
var toolbar = document.createElement("div");// Blockquote button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Blockquote");
tempbutton.setAttribute("title","Wrap \u003Cblockquote\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addBlockquote(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Paragraph and Line break buttons
var tempspan = document.createElement("span");
tempspan.setAttribute("id","htmlFormatButtons");
if (document.getElementById("posttype") && document.getElementById("posttype").selectedIndex == 0)
{
tempspan.setAttribute("style","display:none;"); // Hide if initial post type option is "Plain Old Text"
}
if (document.getElementById("posttype"))
{
document.getElementById("posttype").addEventListener("change", function() {if (document.getElementById('posttype').selectedIndex == 0) {document.getElementById('htmlFormatButtons').style.display = 'none'} else {document.getElementById('htmlFormatButtons').style.display = 'inline'}}); // Change visibility of these buttons based on value of post type
}
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","P");
tempbutton.setAttribute("title","Wrap \u003Cp\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addPara(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","BR");
tempbutton.setAttribute("title","Insert a line break.");
tempbutton.setAttribute("onclick","addBreak(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);// HR button, if editing a story
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","HR");
tempbutton.setAttribute("title","Insert a horizontal rule.");
tempbutton.setAttribute("style","text-decoration:underline overline;");
tempbutton.setAttribute("onclick","addHRule(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);
}// URL button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","URL");
tempbutton.setAttribute("title","Create a hyperlink around the selected text.");
tempbutton.setAttribute("style","text-decoration:underline;");
tempbutton.setAttribute("onclick","addHyperlink(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));// Bold button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","B");
tempbutton.setAttribute("title","Bold");
tempbutton.setAttribute("style","font-weight:bold;");
tempbutton.setAttribute("onclick","addBold(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Italic button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","I");
tempbutton.setAttribute("title","Italic");
tempbutton.setAttribute("style","font-style:italic;");
tempbutton.setAttribute("onclick","addItalic(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Strike button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","S");
tempbutton.setAttribute("title","Strikethrough");
tempbutton.setAttribute("style","text-decoration:line-through;");
tempbutton.setAttribute("onclick","addStrike(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Code button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Code");
tempbutton.setAttribute("title","Wrap \u003Cecode\u003E tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addEcode(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Teletype button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","TT");
tempbutton.setAttribute("title","Wrap \u003Cett\u003E (teletype, ie. monospace) tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addTT(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Superscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u00B2");
tempbutton.setAttribute("title","Superscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSuper(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Subscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u2082");
tempbutton.setAttribute("title","Subscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSubsc(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Ordered list button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","1. List");
tempbutton.setAttribute("title","Insert an ordered list or convert newline-separated text into an ordered list.");
tempbutton.setAttribute("onclick","addOrdlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Unordered list button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u2022 List");
tempbutton.setAttribute("title","Insert an unordered list or convert newline-separated text into an unordered list.");
tempbutton.setAttribute("onclick","addUnordlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createElement("br")); // Divider
// Despace button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Despace");
tempbutton.setAttribute("title","Delete line breaks within the selection.");
tempbutton.setAttribute("onclick","despace(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Symbol button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value",":-)");
tempbutton.setAttribute("title","Insert a symbol.");
tempbutton.setAttribute("onclick","if (document.getElementById('smilebar"+x+"').style.display == 'none') {document.getElementById('smilebar"+x+"').style.display = 'block'} else {document.getElementById('smilebar"+x+"').style.display = 'none'}");
toolbar.appendChild(tempbutton);
boxes[x].parentNode.insertBefore(toolbar, boxes[x].nextSibling);// Symbol list
var smilebar = document.createElement("div");
smilebar.setAttribute("style","-moz-user-select:none; -webkit-user-select:none; display:none; font-size:16pt; max-height:240px; overflow:auto; padding:0.5em;");
smilebar.setAttribute("id","smilebar"+x);
var smiles = [];var codes = [[161,169],[171,172],[174],[176,177],[180,183],[187,191],[215],[224,255],[402],[629],[632],[916],[920],[931],[934],[937],[945,946],[956],[960],[963],[8216,8221],[8226],[8230],[8251],[8364],[8478],[8482],[8528,8542],[8585],[8712,8716],[8721],[8730],[8733,8734],[8736],[8743,8749],[8756,8757],[8773],[8776],[8800,8805],[8834,8837],[8984],[9760],[9762,9765],[9770],[9773,9775],[9784,9794],[9812,9831],[9833,9842],[9850],[9855,9861],[9874,9877],[9882,9885],[9888,9893],[9913],[9940],[9962],[9971],[9981],[9992,10087],[65533],[127744,127756],[127759],[127775,127776],[127797],[127801],[127804,127812],[127817],[127820,127822],[127828,127831],[127838,127839],[127843],[127849],[127855],[127860,127867],[127891],[127904,127911],[127918],[127939],[127942],[127977],[128025],[128074,128078],[128123,128131],[128137,128142],[128148,128150],[128152],[128158],[128161,128164],[128168,128170],[128172],[128176,128177],[128187],[128189,128190],[128193,128194],[128197],[128203,128204],[128206],[128214],[128225,128227],[128231,128233],[128241],[128244],[128246],[128250,128252],[128259],[128266,128270],[128273,128276],[128278,128280],[128286],[128293,128299],[128302,128303],[128509,128510],[128659],[128684,128685]];
for (var i=0; i<codes.length; i++) { if (codes[i].length > 1) { for (var j=codes[i][0]; j<=codes[i][1]; j++) { smiles[smiles.length] = String.fromCodePoint(j); } } else { smiles[smiles.length] = String.fromCodePoint(codes[i][0]); } } // Populate smiles array with code ranges converted to individual characters
smiles = smiles.concat(["xD",":-)",":^)","(^_^;)","\u0028\u00A0\u0361\u00B0\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029","\u0028\u00A0\u0361\u007E\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029\uFEFF","\u00AF\u005C\u005F\u0028\u30C4\u0029\u005F\u002F\u00AF","\u0028\u256F\u00B0\u25A1\u00B0\uFF09\u256F\uFE35\u00A0\u253B\u2501\u253B","\u0028\u30CE\u0CA0\u76CA\u0CA0\u0029\u30CE\u5F61\u253B\u2501\u253B","\u0028\u0060\uFF65\u03C9\uFF65\u00B4\u0029","\u0CA0_\u0CA0","\u0295\u2022\u1D25\u2022\u0294","\u0028\u3065\uFFE3\u00A0\u00B3\uFFE3\u0029\u3065","\u0669\u0028\u204E\u275B\u1D17\u275B\u204E\u0029\u06F6","\u30FD\u0F3C\u0E88\u0644\u035C\u0E88\u0F3D\uFF89"]); // Add in arbitrary emoticons
for (var i=0; i<smiles.length; i++)
{
var smile = document.createElement("span");
smile.setAttribute("style","cursor:pointer; padding:2px; white-space:nowrap;");
smile.setAttribute("onclick","addSmile(document.getElementsByTagName('textarea')["+x+"],'"+smiles[i].replace("\u005C","\u005C\u005C")+"');");
smile.appendChild(document.createTextNode(smiles[i]));
smilebar.appendChild(smile);
if (i+1<smiles.length)
{
smilebar.appendChild(document.createTextNode(" "));
}
}
toolbar.parentNode.insertBefore(smilebar, toolbar.nextSibling);
}var temp = document.createElement("script");
// Add selection handling function
temp.appendChild(document.createTextNode("function getSelection(textarea) { if ('selectionStart' in textarea) { if (textarea.selectionStart != textarea.selectionEnd) { return [textarea.selectionStart,textarea.selectionEnd]; } } } "));// Add comment formatting buttons
temp.appendChild(document.createTextNode("function addBlockquote(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<blockquote>'+area.value.substring(sel[0],sel[1])+'<\/blockquote>' + area.value.substring(sel[1]); } } function addPara(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<p>'+area.value.substring(sel[0],sel[1])+'<\/p>' + area.value.substring(sel[1]); } } function addBreak(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<br>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHRule(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<hr>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHyperlink(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { url = prompt('URL:', 'https://'); area.value = area.value.substring(0,sel[0]) + '<a href=\"'+url+'\">'+area.value.substring(sel[0],sel[1])+'<\/a>' + area.value.substring(sel[1]); } } function addBold(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<b>'+area.value.substring(sel[0],sel[1])+'<\/b>' + area.value.substring(sel[1]); } } function addItalic(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<em>'+area.value.substring(sel[0],sel[1])+'<\/em>' + area.value.substring(sel[1]); } } function addStrike(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<strike>'+area.value.substring(sel[0],sel[1])+'<\/strike>' + area.value.substring(sel[1]); } } function addEcode(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<ecode>'+area.value.substring(sel[0],sel[1])+'<\/ecode>' + area.value.substring(sel[1]); } } function addTT(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<tt>'+area.value.substring(sel[0],sel[1])+'<\/tt>' + area.value.substring(sel[1]); } } function addSuper(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sup>'+area.value.substring(sel[0],sel[1])+'<\/sup>' + area.value.substring(sel[1]); } } function addSubsc(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sub>'+area.value.substring(sel[0],sel[1])+'<\/sub>' + area.value.substring(sel[1]); } } "));// Add list creation functions
temp.appendChild(document.createTextNode("function addOrdlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ol><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>').replace(/\\n<li><\\/li>/g,'') + '<\/li><\/ol>' + area.value.substring(area.selectionEnd); } else { temp = '<ol>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>'; } area.value = area.value.substring(0,area.selectionStart) + temp + '<\/ol>' + area.value.substring(area.selectionStart); } } } function addUnordlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ul><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>').replace(/\\n<li><\\/li>/g,'') + '<\/li><\/ul>' + area.value.substring(area.selectionEnd); } else { temp = '<ul>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>'; } area.value = area.value.substring(0,area.selectionStart) + temp + '<\/ul>' + area.value.substring(area.selectionStart); } } }"));// Add despace function
temp.appendChild(document.createTextNode("function despace(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + area.value.substring(sel[0],sel[1]).replace(/\\r/g,' ').replace(/\\n/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ') + area.value.substring(sel[1]); } }"));// Add unicode insertion function
temp.appendChild(document.createTextNode("function addSmile(area, smile) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,pos) + smile + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+smile.length,pos+smile.length) } }"));document.getElementsByTagName('head')[0].appendChild(temp); // Add script to page
// ==UserScript==
// @name Soylent Upgrade
// @match http://soylentnews.org/article.pl*
// @match https://soylentnews.org/article.pl*
// @match http://soylentnews.org/submit.pl*
// @match https://soylentnews.org/submit.pl*
// @match http://soylentnews.org/admin.pl*
// @match https://soylentnews.org/admin.pl*
// @match http://soylentnews.org/comments.pl*
// @match https://soylentnews.org/comments.pl*
// @match http://soylentnews.org/journal.pl*
// @match https://soylentnews.org/journal.pl*
// ==/UserScript==/* ! http://mths.be/fromcodepoint v0.1.0 by @mathias */
if (!String.fromCodePoint) { (function() { var defineProperty = (function() { try { var object = {}; var $defineProperty = Object.defineProperty; var result = $defineProperty(object, object, object) && $defineProperty; } catch(error) {} return result; }()); var stringFromCharCode = String.fromCharCode; var floor = Math.floor; var fromCodePoint = function() { var MAX_SIZE = 0x4000; var codeUnits = []; var highSurrogate; var lowSurrogate; var index = -1; var length = arguments.length; if (!length) { return ''; } var result = ''; while (++index < length) { var codePoint = Number(arguments[index]); if ( !isFinite(codePoint) || codePoint < 0 || codePoint > 0x10FFFF || floor(codePoint) != codePoint ) { throw RangeError('Invalid code point: ' + codePoint); } if (codePoint <= 0xFFFF) { codeUnits.push(codePoint); } else { codePoint -= 0x10000; highSurrogate = (codePoint >> 10) + 0xD800; lowSurrogate = (codePoint % 0x400) + 0xDC00; codeUnits.push(highSurrogate, lowSurrogate); } if (index + 1 == length || codeUnits.length > MAX_SIZE) { result += stringFromCharCode.apply(null, codeUnits); codeUnits.length = 0; } } return result; }; if (defineProperty) { defineProperty(String, 'fromCodePoint', { 'value': fromCodePoint, 'configurable': true, 'writable': true }); } else { String.fromCodePoint = fromCodePoint; } }()); }// Add "Quote This" buttons to all initially visible comments
var spans = document.getElementsByTagName("span");
for (var x=0; x<spans.length; x++)
{
if (spans[x].id.indexOf("reply_link_")==0)
{
var button = document.createElement("span");
button.setAttribute("class","nbutton");
var p = document.createElement("p");
var b = document.createElement("b");
var a = document.createElement("a");
a.setAttribute("href",spans[x].getElementsByTagName("a")[0].href.replace("#post_comment","&postercomment="+escape("<blockquote>"+document.getElementById("comment_body_"+spans[x].id.replace("reply_link_","")).innerHTML+"<\/blockquote>\n\n")+"#post_comment"));
a.appendChild(document.createTextNode("Quote This"));
b.appendChild(a);
p.appendChild(b);
button.appendChild(p);
spans[x].parentNode.insertBefore(button, spans[x].nextSibling);
spans[x].parentNode.insertBefore(document.createTextNode(" "), spans[x].nextSibling);
}
}var simplifyChars = true; // Change to false if you don't want stylized quotation marks, ellipses, etc. to be replaced
var boxes = document.getElementsByTagName("textarea");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var temp = boxes[x].value; // Retrieve textarea contents
temp = temp.replace(/<\/p><p>/g,"<\/p>\n\n<p>"); // Add newlines between paragraphs
temp = temp.replace(/<br>\s?<br>/g,"<\/p>\n\n<p>"); // Convert double break tags to paragraph tags
temp = temp.replace(/<\/blockquote><p>/g,"<\/blockquote>\n\n<p>"); // Add newlines after blockquotes
temp = temp.replace(/<\/p><blockquote>/g,"<\/p>\n\n<blockquote>"); // Add newlines before blockquotes
temp = temp.replace(/<blockquote><div><p>/g,"<blockquote><div>\n\n<p>"); // Add newlines within start of blockquotes
temp = temp.replace(/<\/p><\/div><\/blockquote>/g,"<\/p>\n\n<\/div><\/blockquote>"); // Add newlines within end of blockquotes
temp = temp.replace(/<\/blockquote><blockquote>/g,"<\/blockquote>\n\n<blockquote>"); // Add newlines between two blockquotes
temp = temp.replace(/<p class="byline">\s/i,"<p class=\"byline\">"); // Remove extra space from byline
temp = temp.replace(/<p>\s/g,"<p>"); // Remove extra space from start of paragraph
temp = temp.replace(/\s<\/p>/g,"<\/p>"); // Remove extra space from end of paragraph
temp = temp.replace(/<\/li><li>/g,"<\/li>\n<li>"); // Add newlines between list items
temp = temp.replace(/<\/li><\/ul>/g,"<\/li>\n(<\/ul>|<\/ol>)"); // Add newline after last list item
temp = temp.replace(/<\/p><ul>/g,"<\/p>\n\n(<ul>|<ol>)"); // Add newlines before lists
temp = temp.replace(/<p>\[...\]/g,"<p>[...] "); // Add space within beginning of foreshortened paragraph
while (temp.indexOf(" ")!=-1)
{
temp = temp.replace(/ /g," "); // Replace double spaces with single spaces
}
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");// Blockquote button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Blockquote");
tempbutton.setAttribute("title","Wrap \u003Cblockquote\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addBlockquote(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Paragraph and Line break buttons
var tempspan = document.createElement("span");
tempspan.setAttribute("id","htmlFormatButtons");
if (document.getElementById("posttype") && document.getElementById("posttype").selectedIndex == 0)
{
tempspan.setAttribute("style","display:none;"); // Hide if initial post type option is "Plain Old Text"
}
if (document.getElementById("posttype"))
{
document.getElementById("posttype").addEventListener("change", function() {if (document.getElementById('posttype').selectedIndex == 0) {document.getElementById('htmlFormatButtons').style.display = 'none'} else {document.getElementById('htmlFormatButtons').style.display = 'inline'}}); // Change visibility of these buttons based on value of post type
}
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","P");
tempbutton.setAttribute("title","Insert \u003Cp\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addPara(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","BR");
tempbutton.setAttribute("title","Insert a line break.");
tempbutton.setAttribute("onclick","addBreak(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);// URL button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","URL");
tempbutton.setAttribute("title","Insert a hyperlink around the selected text.");
tempbutton.setAttribute("style","text-decoration:underline;");
tempbutton.setAttribute("onclick","addHyperlink(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));// Bold button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","B");
tempbutton.setAttribute("title","Bold");
tempbutton.setAttribute("style","font-weight:bold;");
tempbutton.setAttribute("onclick","addBold(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Italic button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","I");
tempbutton.setAttribute("title","Italic");
tempbutton.setAttribute("style","font-style:italic;");
tempbutton.setAttribute("onclick","addItalic(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Strike button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","S");
tempbutton.setAttribute("title","Strikethrough");
tempbutton.setAttribute("style","text-decoration:line-through;");
tempbutton.setAttribute("onclick","addStrike(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Code button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Code");
tempbutton.setAttribute("title","Wrap \u003Cecode\u003E tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addEcode(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Superscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u00B2");
tempbutton.setAttribute("title","Superscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSuper(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Subscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u2082");
tempbutton.setAttribute("title","Subscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSubsc(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
//Ordered list
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","1. List");
tempbutton.setAttribute("title","Insert an ordered list or convert newline-separated text into an ordered list.");
tempbutton.setAttribute("onclick","addOrdlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);//Unordered list
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u2022 List");
tempbutton.setAttribute("title","Insert an unordered list or convert newline-separated text into an unordered list.");
tempbutton.setAttribute("onclick","addUnordlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createElement("br")); // Divider
// Despace button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Despace");
tempbutton.setAttribute("title","Delete line breaks within the selection.");
tempbutton.setAttribute("onclick","despace(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Symbol button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value",":-)");
tempbutton.setAttribute("title","Insert a symbol.");
tempbutton.setAttribute("onclick","if (document.getElementById('smilebar').style.display == 'none') {document.getElementById('smilebar').style.display = 'block'} else {document.getElementById('smilebar').style.display = 'none'}");
toolbar.appendChild(tempbutton);
boxes[x].parentNode.insertBefore(toolbar, boxes[x].nextSibling);// Symbol list
var smilebar = document.createElement("div");
smilebar.setAttribute("style","-moz-user-select:none; -webkit-user-select:none; display:none; font-size:16pt; max-height:240px; overflow:auto; padding:0.5em;");
smilebar.setAttribute("id","smilebar");
var smiles = [];
var codes = [[161,169],[171,172],[174],[176,177],[180,183],[187,191],[215],[224,255],[402],[629],[632],[916],[920],[931],[934],[937],[945,946],[956],[960],[963],[8216,8221],[8226],[8230],[8251],[8364],[8478],[8482],[8528,8542],[8585],[8712,8716],[8721],[8730],[8733,8734],[8736],[8743,8749],[8757],[8773],[8776],[8800,8805],[8834,8837],[8984],[9760],[9762,9765],[9770],[9773,9775],[9784,9794],[9812,9831],[9833,9842],[9850],[9855,9861],[9874,9877],[9882,9885],[9888,9893],[9913],[9940],[9962],[9971],[9981],[9992,10087],[65533],[127744,127756],[127759],[127775,127776],[127797],[127801],[127804,127812],[127817],[127820,127822],[127828,127831],[127838,127839],[127843],[127849],[127855],[127860,127867],[127891],[127904,127911],[127918],[127939],[127942],[127977],[128025],[128074,128078],[128123,128131],[128137,128142],[128148,128150],[128152],[128158],[128161,128164],[128168,128170],[128172],[128176,128177],[128187],[128189,128190],[128193,128194],[128197],[128203,128204],[128206],[128214],[128225,128227],[128231,128233],[128241],[128244],[128246],[128250,128252],[128259],[128266,128270],[128273,128276],[128278,128280],[128286],[128293,128299],[128302,128303],[128509,128510],[128659],[128684,128685]];
for (var i=0; i<codes.length; i++) { if (codes[i].length > 1) { for (var j=codes[i][0]; j<=codes[i][1]; j++) { smiles[smiles.length] = String.fromCodePoint(j); } } else { smiles[smiles.length] = String.fromCodePoint(codes[i][0]); } } // Populate smiles array with code ranges converted to individual characters
smiles = smiles.concat(["xD",":-)",":^)","(^_^;)","\u0028\u00A0\u0361\u00B0\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029","\u0028\u00A0\u0361\u007E\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029\uFEFF","\u00AF\u005C\u005F\u0028\u30C4\u0029\u005F\u002F\u00AF","\u0028\u256F\u00B0\u25A1\u00B0\uFF09\u256F\uFE35\u00A0\u253B\u2501\u253B","\u0028\u30CE\u0CA0\u76CA\u0CA0\u0029\u30CE\u5F61\u253B\u2501\u253B","\u0028\u0060\uFF65\u03C9\uFF65\u00B4\u0029","\u0CA0_\u0CA0","\u0295\u2022\u1D25\u2022\u0294","\u0028\u3065\uFFE3\u00A0\u00B3\uFFE3\u0029\u3065","\u0669\u0028\u204E\u275B\u1D17\u275B\u204E\u0029\u06F6","\u30FD\u0F3C\u0E88\u0644\u035C\u0E88\u0F3D\uFF89"]); // Add in arbitrary emoticons
for (var i=0; i<smiles.length; i++)
{
var smile = document.createElement("span");
smile.setAttribute("style","cursor:pointer; padding:2px; white-space:nowrap;");
smile.setAttribute("onclick","addSmile(document.getElementsByTagName('textarea')["+x+"],'"+smiles[i].replace("\u005C","\u005C\u005C")+"');");
smile.appendChild(document.createTextNode(smiles[i]));
smilebar.appendChild(smile);
if (i+1<smiles.length)
{
smilebar.appendChild(document.createTextNode(" "));
}
}
toolbar.parentNode.insertBefore(smilebar, toolbar.nextSibling);
}var temp = document.createElement("script");
// Add selection handling function
temp.appendChild(document.createTextNode("function getSelection(textarea) { if ('selectionStart' in textarea) { if (textarea.selectionStart != textarea.selectionEnd) { return [textarea.selectionStart,textarea.selectionEnd]; } } } "));// Add comment formatting buttons
temp.appendChild(document.createTextNode("function addBlockquote(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<blockquote>'+area.value.substring(sel[0],sel[1])+'<\/blockquote>' + area.value.substring(sel[1]); } } function addPara(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<p>'+area.value.substring(sel[0],sel[1])+'<\/p>' + area.value.substring(sel[1]); } } function addBreak(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<br>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHyperlink(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { url = prompt('URL:', 'https://'); area.value = area.value.substring(0,sel[0]) + '<a href=\"'+url+'\">'+area.value.substring(sel[0],sel[1])+'<\/a>' + area.value.substring(sel[1]); } } function addBold(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<b>'+area.value.substring(sel[0],sel[1])+'<\/b>' + area.value.substring(sel[1]); } } function addItalic(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<em>'+area.value.substring(sel[0],sel[1])+'<\/em>' + area.value.substring(sel[1]); } } function addStrike(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<strike>'+area.value.substring(sel[0],sel[1])+'<\/strike>' + area.value.substring(sel[1]); } } function addEcode(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<ecode>'+area.value.substring(sel[0],sel[1])+'<\/ecode>' + area.value.substring(sel[1]); } } function addSuper(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sup>'+area.value.substring(sel[0],sel[1])+'<\/sup>' + area.value.substring(sel[1]); } } function addSubsc(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sub>'+area.value.substring(sel[0],sel[1])+'<\/sub>' + area.value.substring(sel[1]); } } "));// Add list creation functions
temp.appendChild(document.createTextNode("function addOrdlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ol><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>') + '<\/li><\/ol>' + area.value.substring(area.selectionEnd); } else { temp = '<ol>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>'; } area.value = area.value.substring(0,area.selectionStart) + temp + '<\/ol>' + area.value.substring(area.selectionStart); } } } function addUnordlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ul><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>') + '<\/li><\/ul>' + area.value.substring(area.selectionEnd); } else { temp = '<ul>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>'; } area.value = area.value.substring(0,area.selectionStart) + temp + '<\/ul>' + area.value.substring(area.selectionStart); } } }"));// Add despace function
temp.appendChild(document.createTextNode("function despace(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + area.value.substring(sel[0],sel[1]).replace(/\\r/g,' ').replace(/\\n/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ') + area.value.substring(sel[1]); } }"));// Add unicode insertion function
temp.appendChild(document.createTextNode("function addSmile(area, smile) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,pos) + smile + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+smile.length,pos+smile.length) } }"));document.getElementsByTagName('head')[0].appendChild(temp);
A week ago I had a dream in which I was partially lucid, i.e. somewhat aware that I was dreaming but not in control of the dream from within the dream. Then I woke up and started getting out of bed but the dream continued despite of and to the side of being awake. It wasn't in any way any kind of interesting dream (and all I can remember of it now was that is was boring and kind of meaningless) and I think I more or less decided to stop (or rather not continue) dreaming as I stood up (or maybe it just happened naturally) because the dream wasn't going anywhere/petering out.
The period of time of “wakeful lucidity” didn't last long, maybe as little as a few seconds and any mind is very good at tricking itself and/or messing up continuity.
Then I realized maybe I should have tried to keep it going but I might not have been able to. Maybe it was nothing but one “part”/“thread” of my brain waking up more or earlier than another, or maybe one “part”/“thread” kept focusing on memories of the dream while waking up, but it really didn't feel like remembering or memory; it felt active just like any normal dream one has at least partial lucidity in i.e. remembering dreams is (very) different from dreaming.
It's tricky to feel certain what happened but the impression I was left with was that I had kept dreaming (and still perhaps only semi-lucidly) after waking up.
Just an anecdote, I'm wondering if others might have experienced something similar while waking up. I'm not much of a lucid dreamer and have for now decided I'm not going to spend much (or any) time trying to be one either, I need as much rest as I can get and don't want to interfere too much or risk getting even less rest (“rest” to me includes the idea of letting the subconscious, the instinct, the reptilian complex¹, whatever is in charge of “garbage duty”, and so on get on with normal functions). For that matter I “waste” a lot of time trying to catch up with myself when awake too: unfortunately I need a lot of time to let things filter down so that I can be reasonably sure or somewhat confident I know what I've done/am doing (so many people don't seem to need to do any of that, I envy you).
¹ See also the outdated or less popular/unfashionable and currently disregarded/unapproved Triune brain if interested (“Reptilian Complex” and “R-complex” is the same thing in neuroanatomy/neurology as far as I know).
It was either talking about this or talking at least a little bit or maybe just giving a teaser about stunningly beautiful primes and showing a lot of unfinished and slightly messy work that might actually be “common”/published knowledge (I've found some references in this paper that seem likely to answer that and which I need to check). Yes instead of working I've managed to get as far as to go through old Schneier posts :) (I think the paper was the subject of one of his posts last year, only a short one with the link or something like that).
Hmm, I might as well ask: if anyone has an easy (not individual proofs) and recently current and up to date reference to or overview of or summation of or “state of the art on $topic” of the most complete “top-level” or “overall” view of primes/primes research then feel free to share it (not Wikipedia and highly unlikely to be anything out of Wolfram, Wikipedia doesn't really have that nor can they be expected to although the pages they have are decent introductions to particulars). I should probably ask around for the same directly to some specific people at some point but who knows who might be reading Soylent News. What I'm asking for probably doesn't exist.
// ==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*
// @match https://soylentnews.org/comments.pl*
// @match http://soylentnews.org/journal.pl?op=edit
// @match https://soylentnews.org/journal.pl?op=edit
// ==/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" || boxes[x].name == "story")
{
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(/<p>\[...\]/g,"<p>[...] ");
while (temp.indexOf(" ")!=-1)
{
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");
// Blockquote button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Blockquote");
tempbutton.setAttribute("title","Wrap \u003Cblockquote\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addBlockquote(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
// Paragraph and Line break buttons
var tempspan = document.createElement("span");
tempspan.setAttribute("id","htmlFormatButtons");
if (document.getElementById("posttype") && document.getElementById("posttype").selectedIndex == 0)
{
tempspan.setAttribute("style","display:none;");
}
if (document.getElementById("posttype"))
{
document.getElementById("posttype").addEventListener("change", function() {if (document.getElementById('posttype').selectedIndex == 0) {document.getElementById('htmlFormatButtons').style.display = 'none'} else {document.getElementById('htmlFormatButtons').style.display = 'inline'}});
}
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","P");
tempbutton.setAttribute("title","Insert \u003Cp\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addPara(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","BR");
tempbutton.setAttribute("title","Insert a line break.");
tempbutton.setAttribute("onclick","addBreak(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);
// URL button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","URL");
tempbutton.setAttribute("title","Insert a hyperlink around the selected text.");
tempbutton.setAttribute("style","text-decoration:underline;");
tempbutton.setAttribute("onclick","addHyperlink(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));
// Bold button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","B");
tempbutton.setAttribute("title","Bold");
tempbutton.setAttribute("style","font-weight:bold;");
tempbutton.setAttribute("onclick","addBold(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
// Italic button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","I");
tempbutton.setAttribute("title","Italic");
tempbutton.setAttribute("style","font-style:italic;");
tempbutton.setAttribute("onclick","addItalic(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
// Strike button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","S");
tempbutton.setAttribute("title","Strikethrough");
tempbutton.setAttribute("style","text-decoration:line-through;");
tempbutton.setAttribute("onclick","addStrike(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));
// Code button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Code");
tempbutton.setAttribute("title","Wrap \u003Cecode\u003E tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addEcode(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));
// Superscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u00B2");
tempbutton.setAttribute("title","Superscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSuper(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
// Subscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u2082");
tempbutton.setAttribute("title","Subscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSubsc(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));
//Ordered list
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","1. List");
tempbutton.setAttribute("title","Insert an ordered list or convert newline-separated text into an ordered list.");
tempbutton.setAttribute("onclick","addOrdlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
//Unordered list
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u2022 List");
tempbutton.setAttribute("title","Insert an unordered list or convert newline-separated text into an unordered list.");
tempbutton.setAttribute("onclick","addUnordlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createElement("br"));
// Despace button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Despace");
tempbutton.setAttribute("title","Delete line breaks within the selection.");
tempbutton.setAttribute("onclick","despace(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
// Symbol button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value",":-)");
tempbutton.setAttribute("title","Insert a symbol.");
tempbutton.setAttribute("onclick","if (document.getElementById('smilebar').style.display == 'none') {document.getElementById('smilebar').style.display = 'block'} else {document.getElementById('smilebar').style.display = 'none'}");
toolbar.appendChild(tempbutton);
boxes[x].parentNode.insertBefore(toolbar, boxes[x].nextSibling);
var smilebar = document.createElement("div");
smilebar.setAttribute("style","display:none; font-size:16pt; padding:0.5em;");
smilebar.setAttribute("id","smilebar");
var smiles = ["\u00A1","\u00A2","\u00A3","\u00A5","\u00A7","\u00A9","\u00AB","\u00AE","\u00B0","\u00B1","\u00B4","\u00B5","\u00B6","\u00B7","\u00BB","\u00BC","\u00BD","\u00BE","\u00BF","\u00D7","\u00E0","\u00E1","\u00E2","\u00E6","\u00E7","\u00E8","\u00E9","\u00EA","\u00EE","\u00F1","\u00F2","\u00F3","\u00F6","\u00F7","\u0192","\u0275","\u0278","\u0394","\u0398","\u03A3","\u03A6","\u03B1","\u03B2","\u03BC","\u03C0","\u03C3","\u2018","\u2019","\u201C","\u201D","\u2022","\u2026","\u203B","\u20AC","\u211E","\u2122","\u03A9","\u2208","\u2209","\u220B","\u220C","\u2211","\u221A","\u221D","\u221E","\u2220","\u2227","\u2228","\u2229","\u222A","\u222B","\u222C","\u222D","\u2234","\u2235","\u2245","\u2248","\u2260","\u2261","\u2262","\u2263","\u2264","\u2265","\u2282","\u2283","\u2284","\u2285","\u2318","\u2620","\u2622","\u2623","\u2624","\u2625","\u262A","\u262D","\u262E","\u262F","\u2638","\u2639","\u263A","\u263B","\u263C","\u263D","\u263E","\u263F","\u2640","\u2641","\u2642","\u2654","\u2655","\u2656","\u2657","\u2658","\u2659","\u265A","\u265B","\u265C","\u265D","\u265E","\u265F","\u2660","\u2661","\u2662","\u2663","\u2664","\u2665","\u2666","\u2667","\u2669","\u266A","\u266B","\u266C","\u266D","\u266E","\u266F","\u2670","\u2671","\u2672","\u267A","\u267F","\u2680","\u2681","\u2682","\u2683","\u2684","\u2685","\u2692","\u2693","\u2694","\u2695","\u269A","\u269B","\u269C","\u269D","\u26A0","\u26A1","\u26A2","\u26A3","\u26A4","\u26A5","\u26B9","\u26D4","\u26EA","\u26F3","\u26FD","\u2713","\u2728","\u273B","\u273D","\u2743","\u2746","\u274C","\u274E","\u274F","\u2756","\uFFFD","\uD83C\uDF35","\uD83C\uDF39","\uD83C\uDF3C","\uD83C\uDF40","\uD83C\uDF41","\uD83C\uDF49","\uD83C\uDF4C","\uD83C\uDF4E","\uD83C\uDF54","\uD83C\uDF55","\uD83C\uDF56","\uD83C\uDF57","\uD83C\uDF5E","\uD83C\uDF5F","\uD83C\uDF63","\uD83C\uDF69","\uD83C\uDF6F","\uD83C\uDF74","\uD83C\uDF75","\uD83C\uDF76","\uD83C\uDF77","\uD83C\uDF78","\uD83C\uDF79","\uD83C\uDF7A","\uD83C\uDF7B","\uD83C\uDF93","\uD83C\uDFA5","\uD83C\uDFA7","\uD83C\uDFAE","\uD83C\uDFC3","\uD83C\uDFC6","\uD83C\uDFE9","\uD83D\uDC19","\uD83D\uDC4A","\uD83D\uDC4C","\uD83D\uDC4D","\uD83D\uDC4E","\uD83D\uDC7B","\uD83D\uDC7D","\uD83D\uDC83","\uD83D\uDC89","\uD83D\uDC8A","\uD83D\uDC8E","\uD83D\uDC94","\uD83D\uDC95","\uD83D\uDC96","\uD83D\uDC98","\uD83D\uDC9E","\uD83D\uDCA1","\uD83D\uDCA3","\uD83D\uDCA4","\uD83D\uDCA8","\uD83D\uDCA9","\uD83D\uDCAA","\uD83D\uDCAC","\uD83D\uDCB0","\uD83D\uDCBB","\uD83D\uDCBD","\uD83D\uDCBE","\uD83D\uDCC1","\uD83D\uDCC2","\uD83D\uDCC5","\uD83D\uDCCB","\uD83D\uDCCC","\uD83D\uDCCE","\uD83D\uDCD6","\uD83D\uDCE1","\uD83D\uDCE2","\uD83D\uDCE3","\uD83D\uDCE7","\uD83D\uDCE8","\uD83D\uDCE9","\uD83D\uDCF1","\uD83D\uDCF4","\uD83D\uDCF6","\uD83D\uDCFA","\uD83D\uDCFB","\uD83D\uDCFC","\uD83D\uDD03","\uD83D\uDD0A","\uD83D\uDD0B","\uD83D\uDD0C","\uD83D\uDD0D","\uD83D\uDD0E","\uD83D\uDD11","\uD83D\uDD12","\uD83D\uDD13","\uD83D\uDD14","\uD83D\uDD16","\uD83D\uDD17","\uD83D\uDD18","\uD83D\uDD1E","\uD83D\uDD25","\uD83D\uDD27","\uD83D\uDD28","\uD83D\uDD2B","\uD83D\uDDFD","\uD83D\uDDFE","\uD83D\uDE93","\uD83D\uDEAC","\uD83D\uDEAD",":-)","(^_^;)","\u0028\u00A0\u0361\u00B0\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029","\u0028\u00A0\u0361\u007E\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029\uFEFF","\u00AF\u005C\u005F\u0028\u30C4\u0029\u005F\u002F\u00AF","\u0028\u30CE\u0CA0\u76CA\u0CA0\u0029\u30CE\u5F61\u253B\u2501\u253B","\u0028\u0060\uFF65\u03C9\uFF65\u00B4\u0029","\u0CA0_\u0CA0","\u0295\u2022\u1D25\u2022\u0294","\u0028\u3065\uFFE3\u00A0\u00B3\uFFE3\u0029\u3065","\u0669\u0028\u204E\u275B\u1D17\u275B\u204E\u0029\u06F6","\u30FD\u0F3C\u0E88\u0644\u035C\u0E88\u0F3D\uFF89"];
for (var i=0; i<smiles.length; i++)
{
var smile = document.createElement("span");
smile.setAttribute("style","cursor:pointer; padding:2px; white-space:nowrap;");
smile.setAttribute("onclick","addSmile(document.getElementsByTagName('textarea')["+x+"],'"+smiles[i].replace("\u005C","\u005C\u005C")+"');");
smile.appendChild(document.createTextNode(smiles[i]));
smilebar.appendChild(smile);
if (i+1<smiles.length)
{
smilebar.appendChild(document.createTextNode(" "));
}
}
toolbar.parentNode.insertBefore(smilebar, toolbar.nextSibling);
}var temp = document.createElement("script");
temp.appendChild(document.createTextNode("function getSelection(textarea) { if ('selectionStart' in textarea) { if (textarea.selectionStart != textarea.selectionEnd) { return [textarea.selectionStart,textarea.selectionEnd]; } } } "));
temp.appendChild(document.createTextNode("function addBlockquote(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<blockquote>'+area.value.substring(sel[0],sel[1])+'<\/blockquote>' + area.value.substring(sel[1]); } } function addPara(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<p>'+area.value.substring(sel[0],sel[1])+'<\/p>' + area.value.substring(sel[1]); } } function addBreak(area) { if ('selectionStart' in area) { area.value = area.value.substring(0,area.selectionStart) + '<br>' + area.value.substring(area.selectionStart); } } function addHyperlink(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { url = prompt('URL:', 'https://'); area.value = area.value.substring(0,sel[0]) + '<a href=\"'+url+'\">'+area.value.substring(sel[0],sel[1])+'<\/a>' + area.value.substring(sel[1]); } } function addBold(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<b>'+area.value.substring(sel[0],sel[1])+'<\/b>' + area.value.substring(sel[1]); } } function addItalic(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<em>'+area.value.substring(sel[0],sel[1])+'<\/em>' + area.value.substring(sel[1]); } } function addStrike(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<strike>'+area.value.substring(sel[0],sel[1])+'<\/strike>' + area.value.substring(sel[1]); } } function addEcode(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<ecode>'+area.value.substring(sel[0],sel[1])+'<\/ecode>' + area.value.substring(sel[1]); } } function addSuper(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sup>'+area.value.substring(sel[0],sel[1])+'<\/sup>' + area.value.substring(sel[1]); } } function addSubsc(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sub>'+area.value.substring(sel[0],sel[1])+'<\/sub>' + area.value.substring(sel[1]); } } "));
temp.appendChild(document.createTextNode("function addOrdlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ol><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>') + '<\/li><\/ol>' + area.value.substring(area.selectionEnd); } else { temp = '<ol>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>'; } area.value = area.value.substring(0,area.selectionStart) + temp + '<\/ol>' + area.value.substring(area.selectionStart); } } } function addUnordlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ul><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>') + '<\/li><\/ul>' + area.value.substring(area.selectionEnd); } else { temp = '<ul>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>'; } area.value = area.value.substring(0,area.selectionStart) + temp + '<\/ul>' + area.value.substring(area.selectionStart); } } }"));
temp.appendChild(document.createTextNode("function despace(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + area.value.substring(sel[0],sel[1]).replace(/\\r/g,' ').replace(/\\n/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ') + area.value.substring(sel[1]); } }"));
temp.appendChild(document.createTextNode("function addSmile(area, smile) { if ('selectionStart' in area) { area.value = area.value.substring(0,area.selectionStart) + smile + area.value.substring(area.selectionStart); } }"));
document.getElementsByTagName('head')[0].appendChild(temp);
// ==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*
// @match https://soylentnews.org/comments.pl*
// @match http://soylentnews.org/journal.pl?op=edit
// @match https://soylentnews.org/journal.pl?op=edit
// ==/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" || boxes[x].name == "story")
{
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(/<p>\[...\]/g,"<p>[...] ");
while (temp.indexOf(" ")!=-1)
{
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");
// Blockquote button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Blockquote");
tempbutton.setAttribute("title","Wrap \u003Cblockquote\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addBlockquote(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
// Paragraph and Line break buttons
var tempspan = document.createElement("span");
tempspan.setAttribute("id","htmlFormatButtons");
if (document.getElementById("posttype").selectedIndex == 0)
{
tempspan.setAttribute("style","display:none;");
}
document.getElementById("posttype").addEventListener("change", function() {if (document.getElementById('posttype').selectedIndex == 0) {document.getElementById('htmlFormatButtons').style.display = 'none'} else {document.getElementById('htmlFormatButtons').style.display = 'inline'}});
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","P");
tempbutton.setAttribute("title","Insert \u003Cp\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addPara(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","BR");
tempbutton.setAttribute("title","Insert a line break.");
tempbutton.setAttribute("onclick","addBreak(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);
// URL button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","URL");
tempbutton.setAttribute("title","Insert a hyperlink around the selected text.");
tempbutton.setAttribute("style","text-decoration:underline;");
tempbutton.setAttribute("onclick","addHyperlink(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));
// Bold button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","B");
tempbutton.setAttribute("title","Bold");
tempbutton.setAttribute("style","font-weight:bold;");
tempbutton.setAttribute("onclick","addBold(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
// Italic button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","I");
tempbutton.setAttribute("title","Italic");
tempbutton.setAttribute("style","font-style:italic;");
tempbutton.setAttribute("onclick","addItalic(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
// Strike button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","S");
tempbutton.setAttribute("title","Strikethrough");
tempbutton.setAttribute("style","text-decoration:line-through;");
tempbutton.setAttribute("onclick","addStrike(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));
// Code button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Code");
tempbutton.setAttribute("title","Wrap \u003Cecode\u003E tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addEcode(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));
// Superscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u00B2");
tempbutton.setAttribute("title","Superscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSuper(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
// Subscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u2082");
tempbutton.setAttribute("title","Subscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSubsc(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
//Ordered list
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","1. List");
tempbutton.setAttribute("title","Insert an ordered list or convert newline-separated text into an ordered list.");
tempbutton.setAttribute("onclick","addOrdlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
//Unordered list
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u2022 List");
tempbutton.setAttribute("title","Insert an unordered list or convert newline-separated text into an unordered list.");
tempbutton.setAttribute("onclick","addUnordlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createElement("br"));
// Despace button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Despace");
tempbutton.setAttribute("title","Delete line breaks within the selection.");
tempbutton.setAttribute("onclick","despace(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
// Symbol button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value",":-)");
tempbutton.setAttribute("title","Insert a symbol.");
tempbutton.setAttribute("onclick","if (document.getElementById('smilebar').style.display == 'none') {document.getElementById('smilebar').style.display = 'block'} else {document.getElementById('smilebar').style.display = 'none'}");
toolbar.appendChild(tempbutton);
boxes[x].parentNode.insertBefore(toolbar, boxes[x].nextSibling);
var smilebar = document.createElement("div");
smilebar.setAttribute("style","display:none; font-size:16pt; padding:0.5em;");
smilebar.setAttribute("id","smilebar");
var smiles = ["\u00A1","\u00A2","\u00A3","\u00A5","\u00A7","\u00A9","\u00AB","\u00AE","\u00B0","\u00B1","\u00B4","\u00B5","\u00B6","\u00B7","\u00BB","\u00BC","\u00BD","\u00BE","\u00BF","\u00D7","\u00E0","\u00E1","\u00E2","\u00E6","\u00E7","\u00E8","\u00E9","\u00EA","\u00EE","\u00F1","\u00F7","\u2022","\u20AC","\u211E","\u2122","\u03A9","\u2208","\u2209","\u220B","\u220C","\u2211","\u221A","\u221D","\u221E","\u2220","\u2227","\u2228","\u2229","\u222A","\u222B","\u222C","\u222D","\u2234","\u2235","\u2245","\u2248","\u2260","\u2261","\u2262","\u2263","\u2264","\u2265","\u2282","\u2283","\u2284","\u2285","\u2318","\u2620","\u2622","\u2623","\u2624","\u2625","\u262A","\u262D","\u262E","\u262F","\u2638","\u2639","\u263A","\u263B","\u263C","\u263D","\u263E","\u263F","\u2640","\u2641","\u2642","\u2654","\u2655","\u2656","\u2657","\u2658","\u2659","\u265A","\u265B","\u265C","\u265D","\u265E","\u265F","\u2660","\u2661","\u2662","\u2663","\u2664","\u2665","\u2666","\u2667","\u2669","\u266A","\u266B","\u266C","\u266D","\u266E","\u266F","\u2670","\u2671","\u2672","\u267A","\u267F","\u2680","\u2681","\u2682","\u2683","\u2684","\u2685","\u2692","\u2693","\u2694","\u2695","\u269A","\u269B","\u269C","\u269D","\u26A0","\u26A1","\u26A2","\u26A3","\u26A4","\u26A5","\u26B9","\u26D4","\u26EA","\u26F3","\u26FD","\u2713","\uD83C\uDF35","\uD83C\uDF39","\uD83C\uDF3C","\uD83C\uDF40","\uD83C\uDF41","\uD83C\uDF4E","\uD83C\uDF54","\uD83C\uDF55","\uD83C\uDF5F","\uD83C\uDF63","\uD83C\uDF6F","\uD83C\uDF75","\uD83C\uDF76","\uD83C\uDF77","\uD83C\uDF78","\uD83C\uDF79","\uD83C\uDF7A","\uD83C\uDF7B","\uD83C\uDF93","\uD83C\uDFAE","\uD83C\uDFC3","\uD83C\uDFC6","\uD83D\uDC4A","\uD83D\uDC4C","\uD83D\uDC4D","\uD83D\uDC4E","\uD83D\uDC7D","\uD83D\uDC89","\uD83D\uDC8A","\uD83D\uDC94","\uD83D\uDC96","\uD83D\uDCA3","\uD83D\uDCA4","\uD83D\uDCA9","\uD83D\uDCAC","\uD83D\uDCB0","\uD83D\uDCBB","\uD83D\uDCBD","\uD83D\uDCBE","\uD83D\uDCC1","\uD83D\uDCC2","\uD83D\uDCC5","\uD83D\uDCCB","\uD83D\uDCCC","\uD83D\uDCCE","\uD83D\uDCD6","\uD83D\uDCE1","\uD83D\uDCE2","\uD83D\uDCE3","\uD83D\uDCE7","\uD83D\uDCE8","\uD83D\uDCE9","\uD83D\uDCF1","\uD83D\uDCF4","\uD83D\uDCF6","\uD83D\uDCFC","\uD83D\uDD03","\uD83D\uDD0A","\uD83D\uDD0B","\uD83D\uDD0C","\uD83D\uDD0D","\uD83D\uDD0E","\uD83D\uDD11","\uD83D\uDD12","\uD83D\uDD13","\uD83D\uDD14","\uD83D\uDD16","\uD83D\uDD17","\uD83D\uDD18","\uD83D\uDD1E","\uD83D\uDD25","\uD83D\uDD27","\uD83D\uDD28","\uD83D\uDD2B","\uD83D\uDE93",":-)","(^_^;)","\u0028\u00A0\u0361\u00B0\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029","\u0028\u00A0\u0361\u007E\u00A0\u035C\u0296\u00A0\u0361\u00B0\u0029\uFEFF","\u00AF\u005C\u005F\u0028\u30C4\u0029\u005F\u002F\u00AF","\u0028\u30CE\u0CA0\u76CA\u0CA0\u0029\u30CE\u5F61\u253B\u2501\u253B","\u0028\u0060\uFF65\u03C9\uFF65\u00B4\u0029","\u0CA0_\u0CA0"];
for (var i=0; i<smiles.length; i++)
{
var smile = document.createElement("span");
smile.setAttribute("style","cursor:pointer; padding:2px;");
smile.setAttribute("onclick","addSmile(document.getElementsByTagName('textarea')["+x+"],'"+smiles[i].replace("\u005C","\u005C\u005C")+"');");
smile.appendChild(document.createTextNode(smiles[i]));
smilebar.appendChild(smile);
if (i+1<smiles.length)
{
smilebar.appendChild(document.createTextNode(" "));
}
}
toolbar.parentNode.insertBefore(smilebar, toolbar.nextSibling);
}var temp = document.createElement("script");
temp.appendChild(document.createTextNode("function getSelection(textarea) { if ('selectionStart' in textarea) { if (textarea.selectionStart != textarea.selectionEnd) { return [textarea.selectionStart,textarea.selectionEnd]; } } } "));
temp.appendChild(document.createTextNode("function addBlockquote(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<blockquote>'+area.value.substring(sel[0],sel[1])+'<\/blockquote>' + area.value.substring(sel[1]); } } function addPara(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<p>'+area.value.substring(sel[0],sel[1])+'<\/p>' + area.value.substring(sel[1]); } } function addBreak(area) { if ('selectionStart' in area) { area.value = area.value.substring(0,area.selectionStart) + '<br>' + area.value.substring(area.selectionStart); } } function addHyperlink(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { url = prompt('URL:', 'https://'); area.value = area.value.substring(0,sel[0]) + '<a href=\"'+url+'\">'+area.value.substring(sel[0],sel[1])+'<\/a>' + area.value.substring(sel[1]); } } function addBold(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<b>'+area.value.substring(sel[0],sel[1])+'<\/b>' + area.value.substring(sel[1]); } } function addItalic(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<em>'+area.value.substring(sel[0],sel[1])+'<\/em>' + area.value.substring(sel[1]); } } function addStrike(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<strike>'+area.value.substring(sel[0],sel[1])+'<\/strike>' + area.value.substring(sel[1]); } } function addEcode(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<ecode>'+area.value.substring(sel[0],sel[1])+'<\/ecode>' + area.value.substring(sel[1]); } } function addSuper(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sup>'+area.value.substring(sel[0],sel[1])+'<\/sup>' + area.value.substring(sel[1]); } } function addSubsc(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sub>'+area.value.substring(sel[0],sel[1])+'<\/sub>' + area.value.substring(sel[1]); } } "));
temp.appendChild(document.createTextNode("function addOrdlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ol><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>') + '<\/li><\/ol>' + area.value.substring(area.selectionEnd); } else { temp = '<ol>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>'; } area.value = area.value.substring(0,area.selectionStart) + temp + '<\/ol>' + area.value.substring(area.selectionStart); } } } function addUnordlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ul><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>') + '<\/li><\/ul>' + area.value.substring(area.selectionEnd); } else { temp = '<ul>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>'; } area.value = area.value.substring(0,area.selectionStart) + temp + '<\/ul>' + area.value.substring(area.selectionStart); } } }"));
temp.appendChild(document.createTextNode("function despace(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + area.value.substring(sel[0],sel[1]).replace(/\\r/g,' ').replace(/\\n/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ') + area.value.substring(sel[1]); } }"));
temp.appendChild(document.createTextNode("function addSmile(area, smile) { if ('selectionStart' in area) { area.value = area.value.substring(0,area.selectionStart) + smile + area.value.substring(area.selectionStart); } }"));
document.getElementsByTagName('head')[0].appendChild(temp);