BvS Ally Types

Display ally type tags on team and ninja order pages.

  1. // ==UserScript==
  2. // @name BvS Ally Types
  3. // @namespace BvS
  4. // @description Display ally type tags on team and ninja order pages.
  5. // @licence MIT; http://www.opensource.org/licenses/mit-license.php
  6. // @copyright 2009, Daniel Karlsson (http://userscripts.org/users/dtkarlsson)
  7. // @include http*://*animecubed.com/billy/bvs/team*
  8. // @include http*://*animecubed.com/billy/bvs/ninjaorder*
  9. // @include http*://*animecubedgaming.com/billy/bvs/team*
  10. // @include http*://*animecubedgaming.com/billy/bvs/ninjaorder*
  11. // @version 1.2.4
  12. // @history 1.2.4 New domain - animecubedgaming.com - Channel28
  13. // @history 1.2.3 Now https compatible (Updated by Channel28)
  14. // @history 1.2.2 Style & Type declared as objects and spelling mistake (Updated by Channel28 with thanks to Terrec on what & how to fix)
  15. // @history 1.2.1 Added grant permissions (Updated by Channel28)
  16. // @history 1.2.0 More allies, fix typo
  17. // @history 1.1.1 Fix for team page update
  18. // @history 1.1.0 Added PizzaWitch allies
  19. // @grant GM_addStyle
  20. // ==/UserScript==
  21. /*
  22. Copyright (c) 2009 Daniel Karlsson
  23.  
  24. Permission is hereby granted, free of charge, to any person
  25. obtaining a copy of this software and associated documentation
  26. files (the "Software"), to deal in the Software without
  27. restriction, including without limitation the rights to use,
  28. copy, modify, merge, publish, distribute, sublicense, and/or sell
  29. copies of the Software, and to permit persons to whom the
  30. Software is furnished to do so, subject to the following
  31. conditions:
  32.  
  33. The above copyright notice and this permission notice shall be
  34. included in all copies or substantial portions of the Software.
  35.  
  36. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  37. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  38. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  39. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  40. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  41. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  42. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  43. OTHER DEALINGS IN THE SOFTWARE.
  44. */
  45.  
  46. // Tags
  47. var REAPER = "R";
  48. var WASTELAND = "W";
  49. var BURGER = "B";
  50. var R00T = "./";
  51.  
  52. // Styles
  53. var STYLE = {};
  54. STYLE[REAPER] = "reaperstyle";
  55. STYLE[WASTELAND] = "wastelandstyle";
  56. STYLE[BURGER] = "burgerstyle";
  57. STYLE[R00T] = "r00tstyle";
  58.  
  59. GM_addStyle(".reaperstyle {color: rgb(0%, 0%, 50%);}");
  60. GM_addStyle(".wastelandstyle {color: rgb(50%, 0%, 0%);}");
  61. GM_addStyle(".burgerstyle {color: rgb(33%, 33%, 0%);}");
  62. GM_addStyle(".r00tstyle {color: rgb(0%, 50%, 0%);}");
  63.  
  64. // Ally lists
  65. // [<tag>] = [{name: <string>, levels: [<min level>, <max level>]}, ...]
  66. var TYPE = {};
  67. TYPE[REAPER] = [
  68. {name: "Anonymous", levels: [1, 3]},
  69. {name: "Blind Fury", levels: [1, 3]},
  70. {name: "Bucketface", levels: [1, 3]},
  71. {name: "Fletch", levels: [1, 3]},
  72. {name: "Hermano", levels: [1, 3]},
  73. {name: "Hotsumoto", levels: [1, 3]},
  74. {name: "Hyuk", levels: [1, 3]},
  75. {name: "LisaLisa", levels: [1, 3]},
  76. {name: "MC Stripeypants", levels: [1, 3]},
  77. {name: "Miss Kitty", levels: [1, 3]},
  78. {name: "Mister Six", levels: [1, 3]},
  79. {name: "Mister Tea", levels: [1, 3]},
  80. {name: "Nadeshiko", levels: [1, 3]},
  81. {name: "Proof Reader", levels: [1, 3]},
  82. {name: "Right", levels: [1, 3]},
  83. {name: "Robogirl", levels: [1, 3]},
  84. {name: "Scary", levels: [1, 3]},
  85. {name: "Smiley", levels: [1, 3]},
  86. {name: "Smokey the Bear", levels: [2, 3]},
  87. {name: "Shorty", levels: [1, 3]},
  88. {name: "Sporty", levels: [1, 3]},
  89. {name: "Strawberry", levels: [1, 3]},
  90. {name: "Tats", levels: [1, 3]},
  91. {name: "TicTac", levels: [1, 3]},
  92. {name: "Timmy", levels: [1, 3]},
  93. {name: "Vanilla", levels: [1, 3]}
  94. ];
  95.  
  96. TYPE[WASTELAND] = [
  97. {name: "Bones", levels: [1, 3]},
  98. {name: "Flutie", levels: [1, 3]},
  99. {name: "Chunks", levels: [1, 3]},
  100. {name: "Good Boy", levels: [1, 3]},
  101. {name: "Grandmaster P", levels: [1, 3]},
  102. {name: "Haro", levels: [1, 3]},
  103. {name: "Haus", levels: [1, 3]},
  104. {name: "Jaws", levels: [1, 3]},
  105. {name: "Larry", levels: [1, 3]},
  106. {name: "Mr. Sandman", levels: [1, 3]},
  107. {name: "Palmface", levels: [1, 3]},
  108. {name: "Proof Reader", levels: [1, 3]},
  109. {name: "Rayne", levels: [1, 3]},
  110. {name: "SNAKEMAN", levels: [1, 3]},
  111. {name: "Stalkergirl", levels: [3, 3]},
  112. {name: "Sticky", levels: [1, 3]},
  113. {name: "Sue", levels: [2, 3]},
  114. {name: "Terri", levels: [1, 3]},
  115. {name: "The Paper", levels: [1, 3]},
  116. {name: "The Twins", levels: [1, 3]},
  117. {name: "Threads", levels: [1, 3]},
  118. {name: "Touchy", levels: [1, 3]},
  119. {name: "Tubby", levels: [1, 3]},
  120. {name: "Venus", levels: [1, 3]}
  121. ];
  122.  
  123. TYPE[BURGER] = [
  124. {name: "Blondie", levels: [1, 3]},
  125. {name: "Cici", levels: [1, 3]},
  126. {name: "Cipher", levels: [1, 3]},
  127. {name: "Euthanasia", levels: [1, 3]},
  128. {name: "Karen", levels: [1, 3]},
  129. {name: "Lulu", levels: [1, 3]},
  130. {name: "Nana", levels: [1, 3]},
  131. {name: "Proof Reader", levels: [1, 3]},
  132. {name: "Robogirl", levels: [3, 3]},
  133. {name: "Smokey the Bear", levels: [2, 3]},
  134. {name: "Stalkergirl", levels: [3, 3]},
  135. {name: "Su-chan", levels: [1, 3]},
  136. {name: "TACOS", levels: [1, 3]}
  137. ];
  138.  
  139. TYPE[R00T] = [
  140. {name: "Doughman", levels: [2, 3]},
  141. {name: "K.Y.", levels: [2, 3]},
  142. {name: "Smokey the Bear", levels: [2, 3]},
  143. {name: "Sporty", levels: [2, 3]},
  144. {name: "Stalkergirl", levels: [3, 3]},
  145. {name: "Tempest Kitsune", levels: [1, 3]},
  146. {name: "Trapchan", levels: [2, 3]},
  147. {name: "Tsukasa", levels: [2, 3]}
  148. ];
  149.  
  150. function allyType(ally)
  151. {
  152. var name, level;
  153. var match = ally.match(/\s*(.*)( Lvl. (\d+))/);
  154. if (match) {
  155. name = match[1];
  156. level = parseInt(match[3]);
  157. } else {
  158. match = ally.match(/\s*(.*)\s*/);
  159. if (match) {
  160. name = match[1];
  161. level = 1;
  162. } else
  163. return;
  164. }
  165.  
  166. var cls = "";
  167. for (var c in TYPE)
  168. for (var i = 0; i < TYPE[c].length; i++)
  169. if (name.indexOf(TYPE[c][i].name) >= 0 && level >= TYPE[c][i].levels[0] && level <= TYPE[c][i].levels[1])
  170. cls += "<span class='" + STYLE[c] + "'>" + c + "</span>";
  171. return cls;
  172. }
  173.  
  174. if (/billy.bvs.team/.test(location.href)) {
  175. // //*[@id="wrapper"]/div/center/table/tbody/tr/td/table[2]/tbody/tr[2]/td[1]/center/table/tbody/tr[3]/td[3]/center/table/tbody/tr/td/font/center[1]/center[1]/table/tbody/tr[1]/td[2]/b
  176. // Team page
  177. var allies = document.evaluate("//div[@id='teamrep']/table/tbody/tr/td/label/b", document, null,
  178. XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  179. for (var i = 0; i < allies.snapshotLength; i++) {
  180. var node = allies.snapshotItem(i);
  181. var ally = node.textContent;
  182. var cls = allyType(ally);
  183. if (cls != "") {
  184. var sup = document.createElement("sup");
  185. sup.innerHTML = "[" + cls + "]";
  186. node.appendChild(sup);
  187. sup.setAttribute("style", "font-size: 75%;");
  188. }
  189. }
  190. // Team
  191. var allies = document.evaluate("//*[@id='wrapper']/div/center/table/tbody/tr/td/table[2]/tbody/tr[2]/td[1]/center/table/tbody/tr[3]/td[3]/center/table/tbody/tr/td/font/center[1]/center[1]/table/tbody/tr/td[2]/b", document, null,
  192. XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  193. for (var i = 0; i < allies.snapshotLength; i++) {
  194. var node = allies.snapshotItem(i);
  195. var ally = node.textContent;
  196. var cls = allyType(ally);
  197. if (cls != "") {
  198. var sup = document.createElement("sup");
  199. sup.innerHTML = "[" + cls + "]";
  200. node.appendChild(sup);
  201. sup.setAttribute("style", "font-size: 75%;");
  202. }
  203. }
  204. } else if (/billy.bvs.ninjaorder/.test(location.href)) {
  205. // Ally Reorganization page
  206. var allies = document.evaluate("//ul[@id='DragContainer7']/li", document, null,
  207. XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  208. for (var i = 0; i < allies.snapshotLength; i++) {
  209. var node = allies.snapshotItem(i);
  210. var img = node.getElementsByTagName("img")[0];
  211. var desc = node.getElementsByTagName("font")[0].textContent;
  212. var ally = img.nextSibling.nodeValue;
  213. ally = ally.replace(/^\s*/, "");
  214. ally = ally.replace(/\s*$/, "");
  215. node.innerHTML = "";
  216. node.appendChild(img);
  217. img.setAttribute("style", "margin: 3px; vertical-align: middle;");
  218. node.appendChild(document.createTextNode(ally));
  219. var cls = allyType(ally);
  220. if (cls != "") {
  221. var sup = document.createElement("sup");
  222. sup.innerHTML = "[" + cls + "]";
  223. node.appendChild(sup);
  224. sup.setAttribute("style", "font-size: 75%;");
  225. }
  226. node.appendChild(document.createTextNode(" "));
  227. var span = document.createElement("span");
  228. span.setAttribute("style", "font-weight: normal;");
  229. span.appendChild(document.createTextNode(desc));
  230. node.appendChild(span);
  231. }
  232. }