Something Awful Single Post Link

By Sebastian Paaske Last update Oct 5, 2007 — Installed 289 times. Daily Installs: 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
// ==UserScript==
// @name           Something Awful Single Post Link
// @namespace      http://www.mathemaniac.org
// @include        http://forum.somethingawful.com/showthread.php?*
// @include        http://forums.somethingawful.com/showthread.php?*
// @include        http://archives.somethingawful.com/showthread.php?*
// @description    To add a link to display that single post on each post.
// ==/UserScript==

// [6th of October 2007: Added "noseen=1" so it doesn't register post as seen.]

function insertAfter(newNode, node) {
  return node.parentNode.insertBefore(newNode, node.nextSibling);
}

var tds = document.getElementsByTagName('td');
for (var i = 0; i < tds.length; i++)
{
    var curTD = tds[i];
    if (curTD.className == 'postdate')
    {
        var atag = curTD.getElementsByTagName('a');
        if (atag.length > 0)
        {
            var newA = document.createElement('a');
            newA.href="showthread.php?action=showpost&noseen=1&postid="+atag[0].getAttribute('href').replace(/[^0-9]*/,'');
            newA.appendChild(document.createTextNode("#"));
            insertAfter(newA,atag[0]);
        }
    }
}