Greasy Fork is available in English.

BvS Forum Ninja Lookup

Adds links to quickly access the BvS ninja lookup page from the forum.

  1. // ==UserScript==
  2. // @name BvS Forum Ninja Lookup
  3. // @namespace BvS
  4. // @version 1.2
  5. // @history 1.2 New domain - animecubedgaming.com - Channel28
  6. // @history 1.1 Now https compatible (Updated by Channel28)
  7. // @include http*://*animecubed.com/billy/forum/*
  8. // @include http*://*animecubedgaming.com/billy/forum/*
  9. // @description Adds links to quickly access the BvS ninja lookup page from the forum.
  10. // @grant none
  11. // ==/UserScript==
  12. /*
  13. Copyright (c) 2009 Daniel Karlsson
  14.  
  15. Permission is hereby granted, free of charge, to any person
  16. obtaining a copy of this software and associated documentation
  17. files (the "Software"), to deal in the Software without
  18. restriction, including without limitation the rights to use,
  19. copy, modify, merge, publish, distribute, sublicense, and/or sell
  20. copies of the Software, and to permit persons to whom the
  21. Software is furnished to do so, subject to the following
  22. conditions:
  23.  
  24. The above copyright notice and this permission notice shall be
  25. included in all copies or substantial portions of the Software.
  26.  
  27. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  28. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  29. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  30. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  31. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  32. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  33. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  34. OTHER DEALINGS IN THE SOFTWARE.
  35. */
  36.  
  37. function lookupLink(name)
  38. {
  39. // Create link
  40. var link = document.createElement("a");
  41. if (name == "McMasters")
  42. name = "11DBHK";
  43. link.setAttribute("href", "/billy/bvs/lookup.html?player=" + name);
  44. link.setAttribute("title", "Lookup " + name);
  45. link.innerHTML = "<img src='./images/icons/smile/info.gif' height='11px' width='11px' alt='(i)'/>";
  46. return link;
  47. }
  48.  
  49. function linkifyPostAuthor()
  50. {
  51. // <b class="postauthor">Name</b>
  52. var links = document.evaluate("//b[@class='postauthor']", document, null,
  53. XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  54.  
  55. for (var i = 0; i < links.snapshotLength; i++) {
  56. var link = links.snapshotItem(i);
  57. var name = link.innerHTML;
  58. var sibling = link.nextSibling;
  59. if (sibling)
  60. link.parentNode.insertBefore(lookupLink(name), sibling);
  61. else
  62. link.parentNode.appendChild(lookupLink(name));
  63. }
  64. }
  65.  
  66. function linkifyViewProfile()
  67. {
  68. // <a href="./memberlist.php?mode=viewprofile&amp;u=xxx">Name</a>
  69. var links = document.evaluate("//a[@href]", document, null,
  70. XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  71.  
  72. for (var i = 0; i < links.snapshotLength; i++) {
  73. var link = links.snapshotItem(i);
  74. // Skip images
  75. if (link.childElementCount > 0)
  76. continue;
  77. if (/memberlist.php.mode.viewprofile/.test(link.getAttribute("href"))) {
  78. var name = link.innerHTML;
  79. var sibling = link.nextSibling;
  80. if (link.parentNode) {
  81. if (sibling)
  82. link.parentNode.insertBefore(lookupLink(name), sibling);
  83. else
  84. link.parentNode.appendChild(lookupLink(name));
  85. }
  86. }
  87. }
  88. }
  89.  
  90. (function() {
  91. linkifyPostAuthor();
  92. linkifyViewProfile();
  93. }());