Something Awful Single Post Link

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

当前为 2016-06-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Something Awful Single Post Link
  3. // @namespace http://www.mathemaniac.org
  4. // @include *://forum.somethingawful.com/showthread.php?*
  5. // @include *://forums.somethingawful.com/showthread.php?*
  6. // @include *://archives.somethingawful.com/showthread.php?*
  7. // @description To add a link to display that single post on each post.
  8. // @version 1.0.3
  9. // ==/UserScript==
  10.  
  11. // 2nd of August, 2011: Update the script to work with the "Mark as read" links enabled.
  12.  
  13. function insertAfter(newNode, node) {
  14. return node.parentNode.insertBefore(newNode, node.nextSibling);
  15. }
  16.  
  17. var tds = document.getElementsByTagName('td');
  18. for (var i = 0; i < tds.length; i++) {
  19. var curTD = tds[i];
  20. if (curTD.className == 'postdate') {
  21. var atag = curTD.getElementsByTagName('a');
  22. if (atag.length > 0) {
  23. var newA = document.createElement('a');
  24. newA.href="showthread.php?action=showpost&noseen=1&postid="+atag[1].getAttribute('href').replace(/[^0-9]*/,'');
  25. newA.appendChild(document.createTextNode("1"));
  26. insertAfter(newA, atag[1]);
  27. insertAfter(document.createTextNode(" "), atag[1]);
  28. }
  29. }
  30. }