Something Awful Single Post Link

To add a link to display that single post on each post.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           Something Awful Single Post Link
// @namespace      http://www.mathemaniac.org
// @include        *://forum.somethingawful.com/showthread.php?*
// @include        *://forums.somethingawful.com/showthread.php?*
// @include        *://archives.somethingawful.com/showthread.php?*
// @description    To add a link to display that single post on each post.
// @version        1.0.3
// ==/UserScript==

// 2nd of August, 2011: Update the script to work with the "Mark as read" links enabled.

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[1].getAttribute('href').replace(/[^0-9]*/,'');
            newA.appendChild(document.createTextNode("1"));
            insertAfter(newA, atag[1]);
            insertAfter(document.createTextNode(" "), atag[1]);
        }
    }
}