Stories
Slash Boxes
Comments

SoylentNews is people

Log In

Log In

Create Account  |  Retrieve Password


Soylent Upgrade Greasemonkey/Tampermonkey extension v3

Posted by takyon on Thursday May 21 2015, @11:05PM (#1231)
1 Comment
Code

// ==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);

Soylent Upgrade Greasemonkey/Tampermonkey extension

Posted by takyon on Thursday May 21 2015, @12:48AM (#1230)
0 Comments
Code

// ==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*
// ==/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("onmousedown","addBlockquote(document.getElementsByTagName('textarea')["+x+"]);");
    toolbar.appendChild(tempbutton);
    // Bold button
    var tempbutton = document.createElement("input");
    tempbutton.setAttribute("type","button");
    tempbutton.setAttribute("value","B");
    tempbutton.setAttribute("style","font-weight:bold;");
    tempbutton.setAttribute("onmousedown","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("style","font-style:italic;");
    tempbutton.setAttribute("onmousedown","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("style","text-decoration:line-through;");
    tempbutton.setAttribute("onmousedown","addStrike(document.getElementsByTagName('textarea')["+x+"]);");
    toolbar.appendChild(tempbutton);
    boxes[x].parentNode.insertBefore(toolbar, boxes[x].nextSibling);
}

var temp = document.createElement("script");
temp.appendChild(document.createTextNode("function addBlockquote(area) { var sel = getSelection(); if (sel.length != 0) { area.value = area.value.replace(sel,'<blockquote>'+sel+'<\/blockquote>'); } } function addBold(area) { var sel = getSelection(); if (sel.length != 0) { area.value = area.value.replace(sel,'<b>'+sel+'<\/b>'); } } function addItalic(area) { var sel = getSelection(); if (sel.length != 0) { area.value = area.value.replace(sel,'<em>'+sel+'<\/em>'); } } function addStrike(area) { var sel = getSelection(); if (sel.length != 0) { area.value = area.value.replace(sel,'<strike>'+sel+'<\/strike>'); } }"));
document.getElementsByTagName('head')[0].appendChild(temp);

function getSelection() {
    return (!!document.getSelection) ? document.getSelection() :
           (!!window.getSelection)   ? window.getSelection() :
           document.selection.createRange().text;
}

Who Wants to See My Wang?

Posted by Sir Finkus on Tuesday May 12 2015, @08:01PM (#1217)
6 Comments
Answers

I've recently come into possession of a Wang 720A/B Reference manual. My late uncle owned the Wang and hadn't been able to find a manual anywhere. Turns out, it was at my Grandmother's house. I was a bit suspicious because Grandpa had been dead for more than a decade, but I didn't ask any questions.

I don't understand why a Wang would need a reference manual in the first place, (even your mother can use one with little to no training or instruction) but here I am looking at one.

Does anyone have any suggestions on discussion groups / websites that might be interested in seeing pictures of my Wang (Reference Manual). Although demand for my Wang (Reference Manual) is at record low levels, I suspect a niche group somewhere has been itching for this.

Maybe the sad reality is that nobody cares about my Wang (reference manual). Sometimes it can feel that way.

Soylent Upgrade user extension for Chrome

Posted by takyon on Tuesday May 12 2015, @01:34AM (#1215)
7 Comments
Code

// ==UserScript==
// @name Soylent Upgrade
// @match http://soylentnews.org/submit.pl
// @match https://soylentnews.org/submit.pl
// @match http://soylentnews.org/submit.pl?op=viewsub&subid=*
// @match https://soylentnews.org/submit.pl?op=viewsub&subid=*
// @match http://soylentnews.org/admin.pl
// @match https://soylentnews.org/admin.pl
// @match http://soylentnews.org/admin.pl?op=edit&sid=*
// @match https://soylentnews.org/admin.pl?op=edit&sid=*
// @match http://soylentnews.org/comments.pl*
// ==/UserScript==

var simplifyChars = true;

var boxes = document.getElementsByTagName("textarea");
for (var x=0; x<boxes.length; x++)
{
    if (boxes[x].name == "introtext" || boxes[x].name == "bodytext")
    {
        var temp = boxes[x].value;
        temp = temp.replace(/<\/p><p>/g,"<\/p>\n\n<p>");
        temp = temp.replace(/<br>\s?<br>/g,"<\/p>\n\n<p>");
        temp = temp.replace(/<\/blockquote><p>/g,"<\/blockquote>\n\n<p>");
        temp = temp.replace(/<\/p><blockquote>/g,"<\/p>\n\n<blockquote>");
        temp = temp.replace(/<blockquote><div><p>/g,"<blockquote><div>\n\n<p>");
        temp = temp.replace(/<\/p><\/div><\/blockquote>/g,"<\/p>\n\n<\/div><\/blockquote>");
        temp = temp.replace(/<\/blockquote><blockquote>/g,"<\/blockquote>\n\n<blockquote>");
        temp = temp.replace(/<p class="byline">\s/i,"<p class=\"byline\">");
        temp = temp.replace(/<p>\s/g,"<p>");
        temp = temp.replace(/\s<\/p>/g,"<\/p>");
        temp = temp.replace(/<\/li><li>/g,"<\/li>\n<li>");
        temp = temp.replace(/<\/li><\/ul>/g,"<\/li>\n<\/ul>");
        temp = temp.replace(/<\/p><ul>/g,"<\/p>\n\n<ul>");
        temp = temp.replace(/  /g," ");
        if (simplifyChars)
        {
            temp = temp.replace(/\u2018/g,"'");
            temp = temp.replace(/\u2019/g,"'");
            temp = temp.replace(/\u201C/g,"\"");
            temp = temp.replace(/\u201D/g,"\"");
            temp = temp.replace(/\u2026/g,"..."); // ellipsis
        }
        boxes[x].value = temp;
        boxes[x].rows = 32;
    }
    var toolbar = document.createElement("div");
    var tempbutton = document.createElement("input");
    tempbutton.setAttribute("type","button");
    tempbutton.setAttribute("value","Blockquote");
    tempbutton.setAttribute("onmousedown","addBlockquote(document.getElementsByTagName('textarea')["+x+"]);");
    toolbar.appendChild(tempbutton);
    boxes[x].parentNode.insertBefore(toolbar, boxes[x].nextSibling);
}

var temp = document.createElement("script");
temp.appendChild(document.createTextNode("function addBlockquote(area) { var sel = getSelection(); if (sel.length != 0) { area.value = area.value.replace(sel,'<blockquote>'+sel+'<\/blockquote>'); } }"));
document.getElementsByTagName('head')[0].appendChild(temp);

function getSelection() {
    return (!!document.getSelection) ? document.getSelection() :
           (!!window.getSelection)   ? window.getSelection() :
           document.selection.createRange().text;
}

So we might be homeless in a couple days.

Posted by Subsentient on Thursday May 07 2015, @07:25PM (#1205)
5 Comments
/dev/random

I've been staying in a motel the last week, because we had an arrangement where an apartment would become available on the 15th. That has fallen through and I don't have anywhere to go. I can't afford another week at this extended stay motel. I have $300 in my checking account. The motel takes $350 a week for me, my 67 year old mother, and two cats.

The fault is partly ours, and partly the wishy-washy landlord.
She guaranteed us the previous tenants would move out since they had given notice, and they did not. My mother is the one who decided to take this arrangement despite my concerns, god bless her, but now it seems my fears were accurate. The next place needs to be in my name I think.

I'm in Mesa Arizona.
Can anyone hear my quiet gurgling for help?

My email is thinkingrodent@gmail.com if anyone wants to help me financially. That's what my paypal is linked to.

Squeak.

Edit: Thank you to NORCOM and Krishna. You've given me a huge help. I am the author of the Epoch Init System, something I didn't mention before, so perhaps your kindness will allow me the stability to improve Epoch.

VT100 CSS Fix

Posted by takyon on Monday May 04 2015, @11:50PM (#1196)
0 Comments
Code

blockquote {border-left:3px solid #0F0 !important; padding-left:1em !important;}

/* Submissions */

.data .status0 {background:#FFF !important; color:#080 !important;}
.data .status0 a {color:#080 !important;}
.data .status0 a:visited {color:#0A0 !important;}
.data .status0 a:hover {color:#0C0 !important;}
.data .status1 {background:#800 !important;}
.data .status2 {background:#256625 !important;}

A nu Linux

Posted by meisterister on Monday April 27 2015, @02:52PM (#1185)
10 Comments
OS

I think that it's time to build a new distribution of Linux, one focused on getting the job done. I think that most distros have basically lost the point of building a linux distro: to have your own unique ecosystem which provides for a specific set of needs.

I'm naming my small, hobby-level efforts to build a distro "nu", as it both provides a very nice logo to work with and because it as a symbol is used to represent "Degrees of freedom" in statistics.

Since this is effectively just a hobby-level of effort, don't expect big things of my distro (unlike a certain Debian fork), but if it works, it should provide a fairly decent starting base for the development of a solid server and development OS.

Some intended features of nu are:
1. nupack, a package manager that effectively just wraps shell scripts and data in a gzip'd tarball.
2. nuinit, an experimental (read: based on random speculation/ideas that I have) that uses makefiles to start and stop the system. If this works properly, it should provide all of the benefits of a certain invasive init system (ie. multithreaded execution) and a model for managing dependencies that is already tried and tested. If this doesn't pan out, I'll likely search for another init system starting with Epoch.
3. nubus. I understand that this was the name of a system bus from the late '80s and early '90s, though I'll likely come up with a better name later. This would start as a re-badged dbus with future revisions actually being their own thing.
4. Either the alsa or jack sound systems.

Because the primary aim of this project is to make a serious operating system, I don't intend to include bloat such as KDE or GNOME. The user is, of course, free to build and install these things for themselves, but they shouldn't expect me to support it.

Project status:
I'm currently trawling through Linux From Scratch, which will provide me with a base system to do various experiments and development on. Since LFS is a very small and basic system in and of itself, it will make it far easier to test out various init systems and implement my package manager.

Future work:
I'm going to implement the package manager first, since it should be fundamentally "easier" than the rest. Thankfully my computer can do the LFS Standard Build Unit in about a minute, so builds have been very fast and straightforward.

"Just pick out the meat"

Posted by Subsentient on Saturday April 25 2015, @09:04AM (#1179)
7 Comments
/dev/random

I can't tell you how many times, being a vegetarian, that I was told I can just "pick out the meat" of whatever meal. Most recently I was complaining that I could find no vegetarian top ramen, which I loved when I was a kid. I was told "well you can just not add the meat sauce".

Let me clear this and some other stuff about us veggies up for you.

I don't eat meat because I consider it unethical, not because I don't like the taste. To buy the ramen and then not use the meat packet is even worse than just eating it all, because not only have I then contributed to the demise of something, I've wasted that food and therefore any suffering.

While I started writing this journal entry only for the above paragraph, I decided to take the time to answer some other comments I get frequently.
Next on my list is "you need protein to be healthy".

That's probably true. That's why I eat a lot of beans, peanut butter, etc. I even buy the special vegetarian refried beans that don't have lard in them. Betcha didn't know that they had lard in em eh? Rosarita makes the ones clearly labeled "vegetarian" with a purple ribbon label. I've been vegetarian since shortly after I turned 17 years old. I'm 20 going on 21. I'm not dead, or hallucinating, or particularly pale. My health has not gotten noticably worse. I feel fine. And no, I don't make exceptions or occasionally "treat myself". I don't eat fish or chicken or any of that. For me, "nothing with a brain". I don't bend that rule.

Next, "I like the taste of meat too much".
Whatever. I used to be one of those people. Then I saw how horrible it really gets for these critters and finally grasped what was really going on there in my heart as well as my mind. Go look up animal cruelty in slaughter houses. It's extremely common. Think of thousands of chickens with untreated broken legs because they're too fat to walk.

Next is "humans evolved with big brains because of meat".
I don't feel any dumber.

and finally, "but animals eat each other"
Yeah, they also do lots of other horrific things because they are ANIMALS and while they are capable of emotion and feeling, they are not very good at rational thought. Humans are supposed to be better than animals, and I can no longer justify such suffering that is not necessary for my survival.

SoylentNews, Unicode, UTF-8, and HTML

Posted by martyb on Friday April 24 2015, @12:08AM (#1176)
0 Comments
Code

NOTE: This is a work-in-progress; read at your own risk/confusion. It is an attempt to gather together bookmarks, tabs, and information pertaining to Unicode, UTF-8, HTML, and 'characters'.

It would seem to be a simple enough question to answer, but things are not always as they seem:

What characters should SoylentNews support?

Motivation: as many of you are aware, one of the early improvements that SoylentNews made to its base source code was to support Unicode characters. (Thanks to the heroic efforts of The Mighty Buzzard.) The underlying code only supported ASCII (American Standard Code for Information Interchange) characters. Which was just fine for as far as it went. It just didn't go far enough for us...

I took on the task of testing our implementation of UTF-8 support. Little did I know what I was getting into! It has been a fascinating journey, indeed!

What is Unicode?

This is taken from What is Unicode?:

Fundamentally, computers just deal with numbers. They store letters and other characters by assigning a number for each one. Before Unicode was invented, there were hundreds of different encoding systems for assigning these numbers. No single encoding could contain enough characters: for example, the European Union alone requires several different encodings to cover all its languages. Even for a single language like English no single encoding was adequate for all the letters, punctuation, and technical symbols in common use.

These encoding systems also conflict with one another. That is, two encodings can use the same number for two different characters, or use different numbers for the same character. Any given computer (especially servers) needs to support many different encodings; yet whenever data is passed between different encodings or platforms, that data always runs the risk of corruption.

Unicode is changing all that!

Unicode provides a unique number for every character, no matter what the platform, no matter what the program, no matter what the language. The Unicode Standard has been adopted by such industry leaders as Apple, HP, IBM, JustSystems, Microsoft, Oracle, SAP, Sun, Sybase, Unisys and many others. Unicode is required by modern standards such as XML, Java, ECMAScript (JavaScript), LDAP, CORBA 3.0, WML, etc., and is the official way to implement ISO/IEC 10646. It is supported in many operating systems, all modern browsers, and many other products. The emergence of the Unicode Standard, and the availability of tools supporting it, are among the most significant recent global software technology trends.

Here is an excerpt from Wikipedia's entry for Unicode:

Unicode has the explicit aim of transcending the limitations of traditional character encodings, such as those defined by the ISO 8859 standard, which find wide usage in various countries of the world but remain largely incompatible with each other. Many traditional character encodings share a common problem in that they allow bilingual computer processing (usually using Latin characters and the local script), but not multilingual computer processing (computer processing of arbitrary scripts mixed with each other).

Unicode, in intent, encodes the underlying characters—graphemes and grapheme-like units—rather than the variant glyphs (renderings) for such characters. ...

In text processing, Unicode takes the role of providing a unique code point—a number, not a glyph—for each character. In other words, Unicode represents a character in an abstract way and leaves the visual rendering (size, shape, font, or style) to other software, such as a web browser or word processor.

A little more background: There are certain code points in Unicode that are of questionable value in the context of a web page; further, there are code points which are defined to be invalid! And then, just to make things even more interesting, I found a list of invalid characters in an HTML document:

Illegal characters

HTML forbids[6] the use of the characters with Universal Character Set/Unicode code points (in decimal form, preceded by x in hexadecimal form)

  • 0 to 31, except 9, 10, and 13 (C0 control characters)
  • 127 (DEL character)
  • 128 to 159 (x80 – x9F, C1 control characters)
  • 55296 to 57343 (xD800 – xDFFF, the UTF-16 surrogate halves)

The Unicode standard also forbids:

  • 65534 and 65535 (xFFFE – xFFFF), non-characters, related to xFEFF, the byte order mark.

UTF-8; Unicode Transfer Format - 8-bit

Though there are several means by which Unicode characters can be transmitted between contexts, one of the most popular is UTF-8, which is what was chosen for use in SoylentNews.

SoylentNews:

What you see from our site mostly comes via a browser (though we also support Gopher and NNTP; you can have stories e-mailed to you; and we also have an RSS/Atom feeds... wow!)

Our site currently formats web pages as HTML 4.01; here's a representative DOCTYPE:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">

At some point in the future we may want to directly support HTML5; ideally nothing should preclude or complicate that effort.

See also:

Obviously, we need not support the invalid code points. (Enumerate them here).

Unicode and UTF-8

So Unicode is a collection of mappings of code-points (numbers) to 'characters'; UTF-8 is a Unicode Transformation Format, 8-bit, used to transmit/encode Unicode code points.

To be continued...

Finally jumped into the MMO snake pit

Posted by Hairyfeet on Sunday April 19 2015, @06:09AM (#1165)
2 Comments
Software

Sigh, with it becoming harder and harder to find decent single player games, as i am not part of the "dudebro" demographic and therefor do not care for your "Medal Of Dooky: Halo Of Killzone Gears Edition" style of games I decided to jump in and try one that looked the least "dude bro"ish and that game is....War Thunder.

I have to give the designers of the game credit, as nearly ever other "FTP" game I've ever played is either so grindtastic its insane or so badly pay to win its not funny but at least in these early tier 1 games? Its really not, hell you can take the default tank (that you get free repairs on forever so you can be as nutty as you like with it, nice) and actually start getting kills in the first few minutes of the first game, its really all about keeping your head on a swivel and remembering to watch your reload times. Nothing will give you a smile quicker than somebody coming to strafe the tank formation you are in and you blow its wing off with the 20mm of your Panzer II lol.

So if any of you are getting sick of the usual fare and want something a little different? Do NOT be put off by the fact its planes and tanks (and soon to be ships) as its beyond easy to drive with a standard keyboard and mouse. If you can play an FPS? You can play War Thunder. Maybe if a few guys here give it a spin and like it we can get a team together, having :"Team Soybeans" roll the tanks while "Run To The Hills" by Iron Maiden plays? That would be a blast.