GLB Player Page Enhancements Warrior General

adds a few options when displaying the atribute values, with or with out items, also displayes ALG values

当前为 2015-09-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GLB Player Page Enhancements Warrior General
  3. // @namespace nikkoum
  4. // @version 4.0.4
  5. // @include http://goallineblitz.com/game/player.pl?player_id=*
  6. // @include http://glb.warriorgeneral.com/game/player.pl?player_id=*
  7. // @require https://greasyfork.org/scripts/12092-jquery-javascript-library-v1-4-2/code/jQuery%20JavaScript%20Library%20v142.js?version=71384
  8. // @description adds a few options when displaying the atribute values, with or with out items, also displayes ALG values
  9. // ==/UserScript==
  10.  
  11. /* copied over from userscripts.org so as to be used in the future by nikkoum only change the posting of the rlevant
  12. * required Jquery language in Greasy fork and changing of said line 2015.08.31
  13. *
  14. * modified by briansimoneau work with the new warriorgeneral.com
  15. * modified ever so slightly by mandyross 22 Sep 2011
  16. * rewritten by Bogleg from Highlight Attributes Archetype Fix:
  17. * written by forestmb @userscripts.org
  18. * modified by peteb @userscripts.org
  19. * modified by raiderdav @userscripts.org
  20. * modified by pabst 12/23/08+
  21. * modified by Tical2k
  22. * modified by txrulz
  23. * modified by numone
  24. * modified by Bogleg 10.06.04 and passed back to numone
  25. * modified by Bogleg 10.06.08
  26. */
  27.  
  28. var bonus = {
  29. 'Strength': 0,
  30. 'Speed': 0,
  31. 'Agility': 0,
  32. 'Jumping': 0,
  33. 'Stamina': 0,
  34. 'Vision': 0,
  35. 'Confidence': 0,
  36. 'Blocking': 0,
  37. 'Tackling': 0,
  38. 'Throwing': 0,
  39. 'Catching': 0,
  40. 'Carrying': 0,
  41. 'Kicking': 0,
  42. 'Punting': 0
  43. };
  44. var colorMajor = '#a03c19';
  45. var colorMinor = '#a000a0';
  46. var colorOther = '#606060';
  47. var attColor = [
  48. // attr name, attr val, attr val boosted (w/eq)
  49. [colorOther, colorOther, '#6060ff'],
  50. [colorMinor, colorMinor, '#2020ff'],
  51. [colorMajor, colorMajor, 0],
  52. ];
  53. var allBuilds = {};
  54. var position;
  55. var buildTypes;
  56. var archetype;
  57.  
  58. function createLegend() {
  59. // insert the color key
  60. $('.player_stats_table').eq(0).css('margin-bottom', '4px').after(
  61. '<div id="colorKeyDiv" style="font-weight: bold; text-align: center; margin-bottom: 4px;">Next Auto Level Gain'
  62. + ' = <span id="keyMajor" style="color: ' + attColor[2][0] + '">Major</span>'
  63. + ' / <span id="keyMinor" style="color: ' + attColor[1][0] + '">Minor</span>'
  64. + ' / <span id="keyOther" style="color: ' + attColor[0][0] + '">Zero</span>'
  65. + '<div id="colorKeyDiv_79" style="font-weight: bold; text-align: center; margin-bottom: 4px;">ALGs to Lv79'
  66. + ' = <span id="keyMajor_79" style="color: ' + attColor[2][0] + '">Major</span>'
  67. + ' / <span id="keyMinor_79" style="color: ' + attColor[1][0] + '">Minor</span>'
  68. );
  69. }
  70.  
  71. function createDropDown(buildTypes, archetype) {
  72. var selectBuild = '<select id="selectBuild" style="float: right; font-weight: normal; font-size: 9px;">';
  73. $.each(buildTypes, function() {
  74. selectBuild += '<option value="' + this[0] + '"';
  75. if (archetype == this[0]) {
  76. selectBuild += ' style="font-weight: bold; color: #a03c19;" selected="selected"';
  77. }
  78. selectBuild += '>' + this[0] + '</option>';
  79. });
  80. selectBuild += '</select>';
  81. $('#player_stats div.medium_head').eq(0).prepend(selectBuild).change(function(e) {
  82. e.preventDefault();
  83. highlightAttributes(buildTypes, $(this).find(':selected').val());
  84. });
  85. }
  86.  
  87. function highlightAttributes(buildTypes, selectedName) {
  88. if(!selectedName) selectedName = $('#selectBuild').find(':selected').val();
  89. if(!selectedName) return;
  90. var b = allBuilds[selectedName];
  91. if (!b) {
  92. $.each(buildTypes, function() {
  93. if (this[0] == selectedName) {
  94. allBuilds[selectedName] = b = new build(this);
  95. return false;
  96. }
  97. });
  98. }
  99. // SAs
  100. $('#player_skill_trees .skill_button').each(function() {
  101. var sa;
  102. try {
  103. sa = this.style.backgroundImage.match(/\/skills\/(.+?)\.(?:bonus\.|penalty\.)?gif\b/)[1];
  104. } catch(e) {
  105. console.error('this = ', this);
  106. console.error('this.style.backgroundImage = ', this.style.backgroundImage);
  107. return true;
  108. }
  109. if (sa in b.affectedSAs) {
  110. $(this).css('background-image', $(this).css('background-image').replace(/(?:\.bonus|\.penalty)?\.gif\b/, '.' + b.affectedSAs[sa] + '.gif'));
  111. } else {
  112. $(this).css('background-image', $(this).css('background-image').replace(/(?:\.bonus|\.penalty)?\.gif\b/, '.gif'));
  113. }
  114. });
  115. // atts
  116. $('div.stat_head_tall').each(function(i, attName) {
  117. var a = $(attName).text().slice(0, 3);
  118. var majmin = b.affectedAtts[a] || 0;
  119. $(attName).css('color', attColor[majmin][0]).next('div').each(function(j, attVal) {
  120. if ($(attVal).hasClass('stat_value_tall_boosted')) {
  121. if (attColor[majmin][2]) $(attVal).css('color', attColor[majmin][2]);
  122. } else {
  123. if (attColor[majmin][1]) $(attVal).css('color', attColor[majmin][1]);
  124. }
  125. });
  126. });
  127. // Update key
  128. var level = parseInt($('#player_current_stats_table .current_stats_value').eq(0).text().split('/')[0]);
  129. function ALG(l, mm, tgtLv) {
  130. if (!parseInt(tgtLv) || tgtLv <= l) tgtLv = l + 1;
  131. var out = 0;
  132. while (l < tgtLv) {
  133. var gain = mm * ((l <= 20) ? 1 : (l <= 28) ? 0.75 : (l <= 36) ? 0.5625 : 0.421875) / b.affectedAtts[mm];
  134. out += gain;
  135. out = Math.floor(out * 1000) / 1000;
  136. ++l;
  137. }
  138. return out;
  139. }
  140. $('#keyMajor').html(ALG(level, 2));
  141. $('#keyMajor_79').html(ALG(level, 2, 79));
  142. $('#keyMinor').html(ALG(level, 1));
  143. $('#keyMinor_79').html(ALG(level, 1, 79));
  144. }
  145.  
  146. function getBuilds(position) {
  147. switch(position) {
  148. case 'FB':
  149. return [
  150. ['No Archetype', 'Str,Agi,Blo,Car', 'Sta,Vis,Con,Tac,Cat'],
  151. ['Rusher', 'Agi,Car,Con,Str', 'Blo,Spe,Sta,Vis', 'power_through,cut', 'lead_block,pancake'],
  152. ['Blocker', 'Agi,Blo,Str,Vis', 'Car,Con,Spe,Sta', 'lead_block,pancake', 'power_through,cut'],
  153. ['Combo Back', 'Agi,Blo,Car,Str,Vis', 'Cat,Con,Jum,Spe'],
  154. ['Scat Back', 'Agi,Cat,Spe,Vis', 'Blo,Car,Con,Jum', 'sticky_hands,cut', 'lead_block,pancake'],
  155. ['Special Teamer', 'Agi,Blo,Spe,Sta,Tac', 'Con,Str,Vis'],
  156. ];
  157. break;
  158. case 'QB':
  159. return [
  160. ['No Archetype', 'Str,Sta,Vis,Con,Thr', 'Spe,Agi,Jum,Cat,Car'],
  161. ['Pocket Passer', 'Con,Thr,Vis', 'Agi,Sta,Str,Car', 'pump_fake,tight_spiral', 'on_the_run,dump_pass'],
  162. ['Deep Passer', 'Str,Thr,Vis', 'Agi,Con,Sta,Car', 'pump_fake,turn_the_shoulder', 'on_the_run,dump_pass'],
  163. ['Scrambler', 'Agi,Thr,Vis', 'Con,Spe,Str,Car', 'on_the_run,dump_pass', 'pump_fake,tight_spiral'],
  164. ];
  165. break;
  166. case 'HB':
  167. return [
  168. ['No Archetype', 'Str,Spe,Agi,Vis,Con,Car', 'Jum,Sta,Blo,Thr,Cat'],
  169. ['Power Back', 'Agi,Car,Con,Str', 'Jum,Spe,Sta,Vis', 'lower_the_shoulder,power_through', 'first_step,spin'],
  170. ['Elusive Back', 'Agi,Car,Spe,Vis', 'Cat,Con,Str', 'head_fake,juke', 'lower_the_shoulder,power_through'],
  171. ['Scat Back', 'Agi,Car,Cat,Spe', 'Con,Jum,Sta,Vis', 'cut,first_step', 'lower_the_shoulder,power_through'],
  172. ['Combo Back', 'Car,Con,Spe,Str,Vis', 'Agi,Cat,Jum,Sta'],
  173. ['Returner', 'Agi,Car,Spe,Sta,Vis', 'Con,Jum,Str', 'first_step,cut', 'stiff_arm,power_through'],
  174. ['Special Teamer', 'Agi,Blo,Spe,Sta,Tac', 'Con,Str,Vis'],
  175. ];
  176. break;
  177. case 'WR':
  178. return [
  179. ['No Archetype', 'Spe,Agi,Jum,Sta,Vis', 'Con,Car'],
  180. ['Speedster', 'Agi,Cat,Con,Spe,Vis', 'Car,Jum,Sta', 'first_step,cut', 'route_running,sticky_hands'],
  181. ['Possession Rec', 'Agi,Car,Cat,Jum,Vis', 'Con,Spe,Sta', 'route_running,sticky_hands', 'first_step,cut'],
  182. ['Power Rec', 'Agi,Car,Cat,Str,Vis', 'Con,Spe,Sta'],
  183. ['Returner', 'Agi,Car,Spe,Sta,Vis', 'Con,Jum,Str', 'first_step,cut', 'route_running,sticky_hands'],
  184. ['Special Teamer', 'Agi,Blo,Spe,Sta,Tac', 'Con,Str,Vis'],
  185. ];
  186. break;
  187. case 'TE':
  188. return [
  189. ['No Archetype', 'Str,Vis,Blo,Cat', 'Spe,Agi,Sta,Con,Tac,Car'],
  190. ['Blocker', 'Agi,Blo,Con,Str,Vis', 'Cat,Spe,Sta', 'get_low,pancake', 'route_running,cut'],
  191. ['Power Rec', 'Agi,Car,Con,Cat,Str', 'Blo,Spe,Sta', 'cover_up,lower_the_shoulder', 'get_low,pancake'],
  192. ['Receiver', 'Agi,Car,Cat,Spe,Vis', 'Blo,Sta,Str', 'route_running,cut', 'get_low,pancake'],
  193. ['Dual Threat', 'Agi,Blo,Cat,Str,Vis', 'Con,Jum,Spe'],
  194. ['Special Teamer', 'Agi,Blo,Spe,Sta,Tac', 'Con,Str,Vis'],
  195. ];
  196. break;
  197. case 'C':
  198. return [
  199. ['No Archetype', 'Str,Blo', 'Agi,Sta,Vis,Con,Tac'],
  200. ['Pass Blocker', 'Agi,Blo,Con,Vis', 'Spe,Sta,Str', 'pass_block,foundation', 'get_low,pancake'],
  201. ['Run Blocker', 'Blo,Con,Str,Vis', 'Agi,Spe,Sta', 'get_low,pancake', 'pass_block,foundation'],
  202. ['Special Teamer', 'Agi,Blo,Spe,Sta,Tac', 'Con,Str,Vis'],
  203. ];
  204. break;
  205. case 'G':
  206. return [
  207. ['No Archetype', 'Str,Con,Blo', 'Agi,Sta,Vis,Tac'],
  208. ['Pass Blocker', 'Agi,Blo,Con,Vis', 'Spe,Sta,Str', 'pass_block,foundation', 'get_low,pancake'],
  209. ['Run Blocker', 'Blo,Con,Str,Vis', 'Agi,Spe,Sta', 'get_low,pancake', 'pass_block,foundation'],
  210. ['Special Teamer', 'Agi,Blo,Spe,Sta,Tac', 'Con,Str,Vis'],
  211. ];
  212. break;
  213. case 'OT':
  214. return [
  215. ['No Archetype', 'Str,Agi,Vis,Con,Blo', 'Sta,Tac'],
  216. ['Pass Blocker', 'Agi,Blo,Con,Vis', 'Spe,Sta,Str', 'pass_block,protector', 'get_low,pancake'],
  217. ['Run Blocker', 'Blo,Con,Str,Vis', 'Agi,Spe,Sta', 'get_low,pancake', 'pass_block,protector'],
  218. ['Special Teamer', 'Agi,Blo,Spe,Sta,Tac', 'Con,Str,Vis'],
  219. ];
  220. break;
  221. case 'DT':
  222. return [
  223. ['No Archetype', 'Str,Agi,Tac', 'Spe,Sta,Vis,Con,Blo'],
  224. ['Run Stuffer', 'Agi,Str,Tac,Vis', 'Con,Spe,Sta', 'wall,break_through', 'shed_block,swat_ball'],
  225. ['Pass Rusher', 'Agi,Spe,Tac,Vis', 'Con,Sta,Str', 'shed_block,swat_ball', 'wall,break_through'],
  226. ['Combo Tackle', 'Spe,Str,Tac,Vis', 'Agi,Con,Sta'],
  227. ['Special Teamer', 'Agi,Blo,Spe,Sta,Tac', 'Con,Str,Vis'],
  228. ];
  229. break;
  230. case 'DE':
  231. return [
  232. ['No Archetype', 'Str,Spe,Agi,Tac', 'Jum,Sta,Vis,Con,Blo'],
  233. ['Run Stuffer', 'Agi,Str,Tac,Vis', 'Con,Spe,Sta', 'wall,strong_base', 'first_step,tunnel_vision'],
  234. ['Pass Rusher', 'Agi,Spe,Tac,Vis', 'Con,Sta,Str', 'first_step,tunnel_vision', 'wall,strong_base'],
  235. ['Combo End', 'Spe,Str,Tac,Vis', 'Agi,Con,Sta'],
  236. ['Special Teamer', 'Agi,Blo,Spe,Sta,Tac', 'Con,Str,Vis'],
  237. ];
  238. break;
  239. case 'LB':
  240. return [
  241. ['No Archetype', 'Str,Agi,Sta,Vis,Con,Tac', 'Spe,Jum,Blo,Cat'],
  242. ['Coverage LB', 'Agi,Jum,Spe,Vis', 'Con,Sta,Str,Tac', 'diving_tackle,swat_ball', 'monster_hit,shed_block'],
  243. ['Blitzer', 'Agi,Jum,Spe,Tac', 'Con,Sta,Str,Vis', 'shed_block,big_sack', 'aura_of_intimidation,diving_tackle'],
  244. ['Hard Hitter', 'Agi,Str,Tac,Vis', 'Con,Jum,Spe,Sta', 'snarl,monster_hit', 'swat_ball,big_sack'],
  245. ['Combo LB', 'Agi,Con,Spe,Tac,Vis', 'Jum,Sta,Str'],
  246. ['Special Teamer', 'Agi,Blo,Spe,Sta,Tac', 'Con,Str,Vis'],
  247. ];
  248. break;
  249. case 'CB':
  250. return [
  251. ['No Archetype', 'Spe,Agi,Jum,Sta,Vis,Cat', 'Str,Con,Tac,Car'],
  252. ['Man Specialist', 'Agi,Jum,Spe,Vis', 'Cat,Con,Sta,Tac', 'shutdown_coverage', 'closing_speed'],
  253. ['Zone Specialist', 'Agi,Spe,Tac,Vis', 'Cat,Con,Jum,Sta', 'superior_vision', 'shutdown_coverage'],
  254. ['Hard Hitter', 'Spe,Str,Tac,Vis', 'Agi,Con,Jum,Sta', 'closing_speed', 'change_direction'],
  255. ['Combo Corner', 'Agi,Spe,Str,Tac', 'Con,Jum,Sta,Vis'],
  256. ['Returner', 'Agi,Car,Spe,Sta,Vis', 'Con,Jum,Str', 'change_direction,return_specialist', 'superior_vision,shutdown_coverage'],
  257. ['Special Teamer', 'Agi,Blo,Spe,Sta,Tac', 'Con,Str,Vis'],
  258. ];
  259. break;
  260. case 'SS':
  261. return [
  262. ['No Archetype', 'Str,Spe,Sta,Vis,Tac', 'Agi,Jum,Con,Blo,Cat,Car'],
  263. ['Man Specialist', 'Agi,Jum,Spe,Vis', 'Cat,Con,Sta,Tac', 'change_direction', 'big_hit'],
  264. ['Zone Specialist', 'Agi,Spe,Tac,Vis', 'Cat,Con,Jum,Sta', 'superior_vision', 'wrap_up_tackle'],
  265. ['Hard Hitter', 'Spe,Str,Tac,Vis', 'Agi,Con,Jum,Sta', 'big_hit', 'change_direction'],
  266. ['Combo Safety', 'Agi,Spe,Str,Tac', 'Con,Jum,Sta,Vis'],
  267. ['Special Teamer', 'Agi,Blo,Spe,Sta,Tac', 'Con,Str,Vis'],
  268. ];
  269. break;
  270. case 'FS':
  271. return [
  272. ['No Archetype', 'Spe,Sta,Vis,Tac,Cat', 'Str,Agi,Jum,Con,Blo,Car'],
  273. ['Man Specialist', 'Agi,Jum,Spe,Vis', 'Cat,Con,Sta,Tac', 'shutdown_coverage', 'big_hit'],
  274. ['Zone Specialist', 'Agi,Spe,Tac,Vis', 'Cat,Con,Jum,Sta', 'superior_vision', 'shutdown_coverage'],
  275. ['Hard Hitter', 'Spe,Str,Tac,Vis', 'Agi,Con,Jum,Sta', 'big_hit', 'change_direction'],
  276. ['Combo Safety', 'Agi,Spe,Str,Tac', 'Con,Jum,Sta,Vis'],
  277. ['Special Teamer', 'Agi,Blo,Spe,Sta,Tac', 'Con,Str,Vis'],
  278. ];
  279. break;
  280. case 'K':
  281. return [
  282. ['No Archetype', 'Con,Kic', 'Str,Spe,Agi,Jum,Vis,Thr'],
  283. ['Boomer', 'Con,Kic,Str', 'Agi,Jum,Vis'],
  284. ['Technician', 'Con,Kic,Vis', 'Agi,Jum,Str'],
  285. ];
  286. break;
  287. case 'P':
  288. return [
  289. ['No Archetype', 'Con,Pun', 'Str,Spe,Agi,Jum,Vis,Thr'],
  290. ['Boomer', 'Con,Pun,Str', 'Agi,Jum,Vis'],
  291. ['Technician', 'Con,Pun,Vis', 'Agi,Jum,Str'],
  292. ];
  293. break;
  294. }
  295. }
  296.  
  297. function build(args) {
  298. this.name = args[0];
  299. this.affectedAtts = {0: 14, 1: 0, 2: 0};
  300. var me = this;
  301. var att;
  302. if (args[1]) $.each(args[1].split(','), function() {
  303. me.affectedAtts[this] = 2;
  304. ++me.affectedAtts[2];
  305. --me.affectedAtts[0];
  306. });
  307. if (args[2]) $.each(args[2].split(','), function() {
  308. me.affectedAtts[this] = 1;
  309. ++me.affectedAtts[1];
  310. --me.affectedAtts[0];
  311. });
  312. this.affectedSAs = {};
  313. var sa;
  314. if (args[3]) $.each(args[3].split(','), function() {
  315. me.affectedSAs[this] = 'bonus';
  316. });
  317. if (args[4]) $.each(args[4].split(','), function() {
  318. me.affectedSAs[this] = 'penalty';
  319. });
  320. }
  321.  
  322. function getArchetype() {
  323. var atImg = $('#player img[src^="/images/game/archetypes/"]');
  324. return (atImg.length == 1 ? atImg.parent().html().split("'")[1] : 'No Archetype')
  325. .replace('Linebacker', 'LB').replace(' Receiver', ' Rec');
  326. }
  327.  
  328. function setupOtherViews() {
  329. $('#player_stats > table.player_stats_table').before('<div id="statsDivs"><div id="statsTabBar" class="subhead_link_bar" style="width: 320px; position: static;"><div id="tab_normalStats" class="tab_off"><a href="javascript:;">Normal</a></div><div id="tab_nakedStats" class="tab_off"><a href="javascript:;">Naked</a></div><div id="tab_bonusStats" class="tab_on"><a href="javascript:;">+/-</a></div><div id="tab_nakedBonusStats" class="tab_off"><a href="javascript:;">Naked &amp; +/-</a></div></div><div id="statsTables"><div id="normalStats"></div><div id="nakedStats"></div><div id="bonusStats"></div><div id="nakedBonusStats"></div></div></div>');
  330. $('#normalStats').hide().append($('#player_stats > table.player_stats_table'));
  331. $('#nakedStats').hide().append($('#normalStats table.player_stats_table').clone());
  332. $('#bonusStats').append($('#normalStats table.player_stats_table').clone());
  333. $('#nakedStats div.stat_value_tall_boosted').each(function() {
  334. $(this).text(eval($(this).text().replace('(', '').replace('+', '-').replace(')', '')));
  335. });
  336. $('#nakedBonusStats').hide().append($('#nakedStats table.player_stats_table').clone());
  337. $('#player_stats table.column_320').find('tr.alternating_color1, tr.alternating_color2').each(function() {
  338. if (bonus[$(this).find('td').eq(0).text()] == undefined) return;
  339. bonus[$(this).find('td').eq(0).text()] = parseFloat($(this).find('td').eq(1).text());
  340. });
  341. $('#bonusStats, #nakedBonusStats').find('div.stat_head_tall').each(function() {
  342. var a = $(this).text().replace(':', '');
  343. if (!bonus[a]) return;
  344. $(this).next().text($(this).next().text().replace(/([0-9.]+)/, function(m, base) {
  345. var newVal = parseFloat(base) + bonus[a];
  346. return Math.round(newVal * 100) / 100;
  347. }));
  348. });
  349. $('#player_stats table.column_320').find('tr.alternating_color1, tr.alternating_color2').each(function() {
  350. if (bonus[$(this).find('td').eq(0).text()] != undefined) $(this).hide();
  351. });
  352. function clickStatsTab(tab) {
  353. $('#statsTables > div').hide();
  354. $('#' + tab).show();
  355. $('#statsTabBar > div').addClass('tab_off').removeClass('tab_on');
  356. $('#tab_' + tab).addClass('tab_on').removeClass('tab_off');
  357. var hideBnP = 0;
  358. if (tab.indexOf('onus') != -1) hideBnP = 1;
  359. $('#player_stats table.column_320').find('tr.alternating_color1, tr.alternating_color2').each(function() {
  360. if (hideBnP) {
  361. if (bonus[$(this).find('td').eq(0).text()] != undefined) $(this).hide();
  362. } else {
  363. if (bonus[$(this).find('td').eq(0).text()] != undefined) $(this).show();
  364. }
  365. });
  366. GM_setValue('statsView', tab);
  367. }
  368. $('#tab_normalStats').click(function() {
  369. clickStatsTab('normalStats');
  370. });
  371. $('#tab_nakedStats').click(function() {
  372. clickStatsTab('nakedStats');
  373. });
  374. $('#tab_bonusStats').click(function() {
  375. clickStatsTab('bonusStats');
  376. });
  377. $('#tab_nakedBonusStats').click(function() {
  378. clickStatsTab('nakedBonusStats');
  379. });
  380. clickStatsTab(GM_getValue('statsView', 'bonusStats'));
  381. }
  382.  
  383. position = $('.position').eq(0).text();
  384. buildTypes = getBuilds(position);
  385. archetype = getArchetype();
  386. createLegend();
  387. createDropDown(buildTypes, archetype);
  388. highlightAttributes(buildTypes, archetype);
  389. setupOtherViews();
  390.