Greasy Fork 支持简体中文。

Peaks Increment Calculator V2.0

This Tool Calculate peaks Increment in each peak

  1. // ==UserScript==
  2. // @name Peaks Increment Calculator V2.0
  3. // @version 2.0
  4. // @description This Tool Calculate peaks Increment in each peak
  5. // @author Omer Ben Yosef
  6. // @include http://trophymanager.com/players/*
  7. // @include https://trophymanager.com/players/*
  8. // @include https://fb.trophymanager.com/players/*
  9. // @namespace https://greasyfork.org/users/18768
  10. // ==/UserScript==
  11. var div_area = document.createElement('div');
  12. var a = document.getElementById("player_graphs_new");
  13. var b = a.getElementsByClassName("graph_peaks background_gradient graph_block");
  14. var phySum = 0 ;
  15. var tacSum = 0 ;
  16. var tecSum = 0 ;
  17. document.getElementsByClassName("box")[0].appendChild(div_area);
  18. div_area.innerHTML = "<div style=\"position: absolute; z-index: 1; width: 186px; height: 249px; margin-top: 476px; background: url(http://s9.postimg.org/w3xw1ge6n/omer_omer.png); color: white; outset; display:inline;\">&nbsp;<p style=\"text-decoration: underline;\"><b><\p><table style=\"margin-top: -1em; margin-bottom: 1em; position:relative; top:0px;left:5px\">&nbsp;<tr><td>PhySum: </td><td>" + phySum + " (" + 0 + "%)</td></tr><tr><td>TacSum: </td><td>" + phySum + " (" + 0 + "%)</td></tr><tr><td>TecSum: </td><td>" + phySum + " (" + 0 + "%)</td></tr><tr><td>AllSum: </td><td>" + phySum + "</td></tr></table></b></div>";
  19.  
  20. var div = document.createElement("BUTTON");
  21. document.getElementsByClassName("box")[0].appendChild(div);
  22.  
  23. div.setAttribute("style", "position: absolute; z-index: 1; width: 185px; margin-top: 240px; background: #5F8D2D; padding-left: 5px; position: absolute; z-index: 1; width: 185px; margin-top: 240px; background: #5F8D2D;padding-left: 5px; position: absolute;display: inline-block; line-height: 21px;color: #fff; text-align: center;font-weight: normal; background: #4A6C1F url(/pics/normal_button_gradient.png) center center; box-shadow: 1px 1px 0 #44631b; font-size: 13px; margin-left: 5px; border-left-width: 2px; width: 175px ;margin-top: 663px;");
  24.  
  25. div.innerHTML = "<p><b>Calculate Peak Increment</b></p>";
  26.  
  27.  
  28. var array =
  29. ["15.00","15.01","15.02","15.03","15.04","15.05","15.06","15.07","15.08","15.09","15.10","15.11"
  30. ,"16.00","16.01","16.02","16.03","16.04","16.05","16.06","16.07","16.08","16.09","16.10","16.11"
  31. ,"17.00","17.01","17.02","17.03","17.04","17.05","17.06","17.07","17.08","17.09","17.10","17.11"
  32. ,"18.00","18.01","18.02","18.03","18.04","18.05","18.06","18.07","18.08","18.09","18.10","18.11"
  33. ,"19.00","19.01","19.02","19.03","19.04","19.05","19.06","19.07","19.08","19.09","19.10","19.11"
  34. ,"20.00","20.01","20.02","20.03","20.04","20.05","20.06","20.07","20.08","20.09","20.10","20.11"
  35. ,"21.00","21.01","21.02","21.03","21.04","21.05","21.06","21.07","21.08","21.09","21.10","21.11"
  36. ,"22.00","22.01","22.02","22.03","22.04","22.05","22.06","22.07","22.08","22.09","22.10","22.11"
  37. ,"23.00","23.01","23.02","23.03","23.04","23.05","23.06","23.07","23.08","23.09","23.10","23.11"
  38. ,"24.00","24.01","24.02","24.03","24.04","24.05","24.06","24.07","24.08","24.09","24.10","24.11"
  39. ,"25.00","25.01","25.02","25.03","25.04","25.05","25.06","25.07","25.08","25.09","25.10","25.11"
  40. ,"26.00","26.01","26.02","26.03","26.04","26.05","26.06","26.07","26.08","26.09","26.10","26.11"
  41. ,"27.00","27.01","27.02","27.03","27.04","27.05","27.06","27.07","27.08","27.09","27.10","27.11"
  42. ,"28.00","28.01","28.02","28.03","28.04","28.05","28.06","28.07","28.08","28.09","28.10","28.11"
  43. ,"29.00","29.01","29.02","29.03","29.04","29.05","29.06","29.07","29.08","29.09","29.10","29.11"
  44. ,"30.00","30.01","30.02","30.03","30.04","30.05","30.06","30.07","30.08","30.09","30.10","30.11"
  45. ,"31.00","31.01","31.02","31.03","31.04","31.05","31.06","31.07","31.08","31.09","31.10","31.11"
  46. ,"32.00","32.01","32.02","32.03","32.04","32.05","32.06","32.07","32.08","32.09","32.10","32.11"
  47. ,"33.00","33.01","33.02","33.03","33.04","33.05","33.06","33.07","33.08","33.09","33.10","33.11"
  48. ,"34.00","34.01","34.02","34.03","34.04","34.05","34.06","34.07","34.08","34.09","34.10","34.11"
  49. ,"35.00","35.01","35.02","35.03","35.04","35.05","35.06","35.07","35.08","35.09","35.10","35.11"
  50. ,"36.00","36.01","36.02","36.03","36.04","36.05","36.06","36.07","36.08","36.09","36.10","36.11"
  51. ,"37.00","37.01","37.02","37.03","37.04","37.05","37.06","37.07","37.08","37.09","37.10","37.11"
  52. ];
  53.  
  54. var float_left_info = document.getElementsByClassName("float_left info_table zebra");
  55. var tbody = float_left_info[0].getElementsByTagName("tbody")
  56. var tr = tbody[0].getElementsByTagName("tr")
  57. var age_y = tr[2].cells[1].innerText ;
  58. var age_string_years = parseInt(age_y);
  59. var months_string_num = parseInt(age_y.split(" ")[2])
  60. var zeo = false ;
  61. if (months_string_num < 10) { zeo = true;}
  62. var age_string_years = age_string_years.toString();
  63. var months_string_num = months_string_num.toString();
  64. var point = ".";
  65. var temp_months_string_num = "";
  66. var zero = "0" ;
  67. if (zeo == true) {
  68. months_string_num = temp_months_string_num.concat(zero,months_string_num);
  69. }
  70. var age_concat = age_string_years.concat(point,months_string_num);
  71.  
  72.  
  73. var mi = document.createElement("select");
  74. mi.id = "mi";
  75. document.getElementsByClassName("box")[0].appendChild(mi);
  76. mi.setAttribute("style", "position: absolute; z-index: 1; display: inline-block ; line-height: 25px; color: #fff; text-align: center; font-weight: normal; background: #4A6C1F url(/pics/normal_button_gradient.png) center center ; border-bottom: 1px solid #44631b; border-right: 1px solid #44631b; border: 1px solid #6c9922; box-shadow: 1px 1px 0 #44631b; padding-right: 20px ; margin: 0px 0px 30px 0px ; padding-right: 12px;padding-top: 6px;padding-bottom: 6px; padding-left: 12px ; margin: 0px 0px 0px 0px;font-size: 13px;margin-left: 4px; margin-top: 607px;");
  77.  
  78. mi_index = 0;
  79. for (var i = 0; i < array.length; i++) {
  80. var option = document.createElement("option");
  81. option.value = array[i];
  82. option.text = array[i];
  83. mi.appendChild(option);
  84. }
  85.  
  86. for (var i = 0; i < array.length; i++) {
  87. if (mi.options[i].value == age_concat){
  88. mi_index = i;
  89. mi.options[i].selected = true;
  90. }
  91. }
  92.  
  93. var mx = document.createElement("select");
  94. mx.id = "mx";
  95. document.getElementsByClassName("box")[0].appendChild(mx);
  96. mx.setAttribute("style", "position: absolute; z-index: 1; display: inline-block ; line-height: 25px; color: #fff; text-align: center; font-weight: normal; background: #4A6C1F url(/pics/normal_button_gradient.png) center center ; border-bottom: 1px solid #44631b; border-right: 1px solid #44631b; border: 1px solid #6c9922; box-shadow: 1px 1px 0 #44631b; padding-right: 20px ; margin: 0px 0px 30px 0px ; padding-right: 12px;padding-top: 6px;padding-bottom: 6px; padding-left: 12px ; margin: 0px 0px 0px 97px;font-size: 13px; margin-top: 607px;");
  97.  
  98. mx_index = 0;
  99. for (var i = 0; i < array.length; i++) {
  100. var option = document.createElement("option");
  101. option.value = array[i];
  102. option.text = array[i];
  103. mx.appendChild(option);
  104. }
  105.  
  106. for (var i = 0; i < array.length; i++) {
  107. if (mx.options[i].value == age_concat){
  108. mx_index = i;
  109. mx.options[i].selected = true;
  110. }
  111. }
  112.  
  113.  
  114.  
  115.  
  116. div.onclick=function()
  117. { var first_age = document.getElementById("mi").value ;
  118. var second_age = document.getElementById("mx").value ;
  119. var T_Must_To_Be = 1;
  120.  
  121. var a = document.getElementById("player_graphs_new");
  122. var b = a.getElementsByClassName("graph_peaks background_gradient graph_block");
  123. try {
  124. {if ($(b[0].getElementsByClassName("graph jqplot-target")).length>0)
  125. {var c = b[0].getElementsByClassName("graph jqplot-target");
  126. var bool = true ;
  127. var count = 0 ;
  128. var num = 0 ;
  129. while (bool == true) {
  130. var sta = "jqplot-point-label jqplot-series-0 jqplot-point-";
  131. num = count ;
  132. num = num.toString();
  133. str = sta.concat(num);
  134. if ($(b[0].getElementsByClassName(str)).length>0)
  135. { count = count + 1 ;
  136. }
  137. else { count = count -1 ;
  138. bool = false ; }
  139. }
  140.  
  141. console.log(count);
  142. var bool_two = true ;
  143. var count_two = 0 ;
  144. var num_two = 0 ;
  145. while (bool_two == true) {
  146. var sta_2 = "jqplot-point-label jqplot-series-1 jqplot-point-";
  147. num_two = count_two ;
  148. num_two = num_two.toString();
  149. var str_2 = sta_2.concat(num_two);
  150. if ($(b[0].getElementsByClassName(str_2)).length>0)
  151. { count_two = count_two + 1 ;
  152. }
  153. else { count_two = count_two -1 ;
  154. bool_two = false ; }
  155. }
  156.  
  157. console.log(count_two);
  158.  
  159. var bool_three = true ;
  160. var count_three = 0 ;
  161. var num_three = 0 ;
  162. while (bool_three == true) {
  163. var sta_3 = "jqplot-point-label jqplot-series-2 jqplot-point-";
  164. num_three = count_three ;
  165. num_three = num_three.toString();
  166. var str_3 = sta_3.concat(num_three);
  167. if ($(b[0].getElementsByClassName(str_3)).length>0)
  168. { count_three = count_three + 1 ;
  169. }
  170. else { count_three = count_three -1 ;
  171. bool_three = false ; }
  172. }
  173.  
  174. console.log(count_three);
  175.  
  176. var str1 = "jqplot-point-label jqplot-series-0 jqplot-point-";
  177. var str2 = "jqplot-point-label jqplot-series-1 jqplot-point-";
  178. var str3 = "jqplot-point-label jqplot-series-2 jqplot-point-";
  179. var first_age_index = 0;
  180. var second_age_index = 0;
  181. for (var i = 0; i < array.length; i++) {
  182. if (mi.options[i].value == first_age){
  183. first_age_index = i;
  184.  
  185. }
  186. }
  187. for (var i = 0; i < array.length; i++) {
  188. if (mx.options[i].value == second_age){
  189. second_age_index = i;
  190.  
  191. }
  192. }
  193. var tgA = 0;
  194. if (second_age_index > mx_index)
  195. { tgA = 0;
  196. }
  197. else {
  198. tgA = mx_index - second_age_index ;
  199. }
  200.  
  201. var Last_Training = (mi_index+1) - first_age_index;
  202. var tg = Last_Training - tgA
  203. var graph_ti_background_gradient = document.getElementsByClassName("graph_ti background_gradient graph_block");
  204. var graph_jqplot_target = document.getElementsByClassName("graph jqplot-target");
  205. var graph_ti = document.getElementById("graph_ti");
  206. var kid = graph_ti.children[7];
  207. var string = kid.classList[2];
  208. var num_ti_list = string.slice(string.indexOf("point")+6);
  209. num_ti_list = parseInt(num_ti_list);
  210. console.log(num_ti_list);
  211. var heighst_counts = Math.max (count_three,count_two,count);
  212. if (heighst_counts >= num_ti_list) {var num_of_training = heighst_counts + 1 ;}
  213. else {
  214. var num_of_training = num_ti_list ;
  215.  
  216. }
  217. console.log(num_of_training);
  218.  
  219. var e_count = 0 ;
  220. var T = 0 ;
  221. var count_r = count - tgA ;
  222. while (e_count < tg){
  223. var count_1 = count_r + 1 ;
  224. var TI = a.getElementsByClassName("graph_ti background_gradient graph_block");
  225. var TI = TI[0].getElementsByClassName("graph jqplot-target");
  226. var str_for_ti = "jqplot-point-label jqplot-series-0 jqplot-point-";
  227. var str_for_ti = str_for_ti.concat(count_1.toString());
  228. var TA = TI[0].getElementsByClassName(str_for_ti);
  229. var TGA = document.getElementsByClassName(str_for_ti)[0].textContent;
  230. if (TA.length == 0) {T_Must_To_Be = 0 ; }
  231. var TINT = parseInt(TGA);
  232. T = T + parseFloat(TINT/10);
  233. e_count = e_count + 1 ;
  234. count_r = count_r - 1 ;
  235. }
  236. var count_AA = num_of_training - 1 ;
  237. console.log(count);
  238. var num_last = count_AA - tgA ;
  239. var num_last_1 = count_AA - Last_Training ;
  240. num_last = num_last.toString()
  241. num_last_1 = num_last_1.toString()
  242. var str1_r = str1.concat(num_last);
  243. var str2_r = str2.concat(num_last);
  244. var str3_r = str3.concat(num_last);
  245. var str1b = str1.concat(num_last_1);
  246. var str2b = str2.concat(num_last_1);
  247. var str3b = str3.concat(num_last_1);
  248. var phy_peak_last = c[0].getElementsByClassName(str1_r);
  249. if (phy_peak_last.length == 0) {T_Must_To_Be = 0;}
  250. var tac_peak_last = c[0].getElementsByClassName(str2_r);
  251. if (tac_peak_last.length == 0) {T_Must_To_Be = 0;}
  252. var tec_peak_last = c[0].getElementsByClassName(str3_r);
  253. if (tec_peak_last.length == 0) {T_Must_To_Be = 0;}
  254. var phy_peak_last = phy_peak_last[0].style;
  255. var tac_peak_last = tac_peak_last[0].style;
  256. var tec_peak_last = tec_peak_last[0].style;
  257.  
  258. var phy_peak_last = phy_peak_last["top"];
  259. var tac_peak_last = tac_peak_last["top"];
  260. var tec_peak_last = tec_peak_last["top"];
  261.  
  262. phy_peak_last = parseFloat(phy_peak_last);
  263. tac_peak_last = parseFloat(tac_peak_last);
  264. tec_peak_last = parseFloat(tec_peak_last);
  265. var phy_peak_last_1 = c[0].getElementsByClassName(str1b);
  266. if (phy_peak_last_1.length == 0) {T_Must_To_Be = 0;}
  267. var tac_peak_last_1 = c[0].getElementsByClassName(str2b);
  268. if (tac_peak_last_1.length == 0) {T_Must_To_Be = 0;}
  269. var tec_peak_last_1 = c[0].getElementsByClassName(str3b);
  270. if (tec_peak_last_1.length == 0) {T_Must_To_Be = 0;}
  271.  
  272. var phy_peak_last_1 = phy_peak_last_1[0].style;
  273. var tac_peak_last_1 = tac_peak_last_1[0].style;
  274. var tec_peak_last_1 = tec_peak_last_1[0].style;
  275. var phy_peak_last_1 = phy_peak_last_1["top"]
  276. var tac_peak_last_1 = tac_peak_last_1["top"]
  277. var tec_peak_last_1 = tec_peak_last_1["top"]
  278. phy_peak_last_1 = parseFloat(phy_peak_last_1)
  279. tac_peak_last_1 = parseFloat(tac_peak_last_1)
  280. tec_peak_last_1 = parseFloat(tec_peak_last_1)
  281. var phy_diff = parseFloat(phy_peak_last_1 - phy_peak_last) ;
  282. var tac_diff = parseFloat(tac_peak_last_1 - tac_peak_last) ;
  283. var tec_diff = parseFloat(tec_peak_last_1 - tec_peak_last) ;
  284. var T = T.toFixed(1);
  285. var TOTALSUM = parseFloat(phy_diff + tac_diff + tec_diff) ;
  286. phy_diff = T/TOTALSUM*phy_diff;
  287. tac_diff = T/TOTALSUM*tac_diff;
  288. tec_diff = T/TOTALSUM*tec_diff;
  289. phy_diff = phy_diff.toFixed(1);
  290. tac_diff = tac_diff.toFixed(1);
  291. tec_diff = tec_diff.toFixed(1);
  292.  
  293. if ((first_age_index < mi_index+1)&&(second_age_index >= first_age_index) && (T_Must_To_Be == 1)){
  294. div_area.innerHTML = "<div style=\"position: absolute; z-index: 1; width: 186px; height: 249px; margin-top: 476px; background: url(http://s9.postimg.org/w3xw1ge6n/omer_omer.png); color: white; outset; display:inline;\">&nbsp;<p style=\"text-decoration: underline;\"><b><\p><table style=\"margin-top: -1em; margin-bottom: 1em; position:relative; top:0px;left:5px\">&nbsp;<tr><td>PhySum: </td><td>" + phy_diff + " (" + Math.round((phy_diff/T)*100) + "%)</td></tr><tr><td>TacSum: </td><td>" + tac_diff + " (" + Math.round((tac_diff/T)*100) + "%)</td></tr><tr><td>TecSum: </td><td>"+ tec_diff + " (" + Math.round((tec_diff/T)*100) + "%)</td></tr><tr><td>AllSum: </td><td>" + T + "</td></tr></table></b></div>";
  295. }
  296. }
  297. else (alert("Please Wait / Enable Peaks graph for your player"));
  298. }
  299. }
  300. catch(err) {
  301. document.getElementById("tabplayer_graphs_new").click();
  302. }
  303.  
  304. };