Information about teams for the match

You can see team informations(Rating, XP, ASI) about any match

  1. // ==UserScript==
  2. // @name Information about teams for the match
  3. // @version 1.0.5
  4. // @description You can see team informations(Rating, XP, ASI) about any match
  5. // @author Shomi
  6. // @include https://trophymanager.com/matches/*
  7. // @namespace https://gf.qytechs.cn/users/721529
  8. // @grant function
  9. // ==/UserScript==
  10.  
  11. let weightR4 = [
  12. [0.51872935, 0.29081119, 0.57222393, 0.89735816, 0.84487852, 0.50887940, 0.50887940, 0.13637928, 0.05248024, 0.09388931, 0.57549122, 0.00000000, 0.00000000, 0.0], // DC
  13. [0.45240063, 0.31762087, 0.68150374, 0.77724031, 0.74690951, 0.50072196, 0.45947168, 0.17663123, 0.23886264, 0.18410349, 0.46453393, 0.00000000, 0.00000000, 0.0], // DL/R
  14. [0.43789335, 0.31844356, 0.53515723, 0.63671706, 0.59109742, 0.51311701, 0.53184426, 0.32421168, 0.06318165, 0.27931537, 0.50093723, 0.19317517, 0.07490902, 0.0], // DMC
  15. [0.42311032, 0.32315966, 0.62271745, 0.53932111, 0.51442838, 0.49835997, 0.47896659, 0.26434782, 0.22586124, 0.32182902, 0.45537227, 0.23961054, 0.09291562, 0.0], // DML/R
  16. [0.31849880, 0.36581214, 0.50091016, 0.31726444, 0.28029020, 0.52022170, 0.55763723, 0.60199246, 0.10044356, 0.51811057, 0.38320838, 0.38594825, 0.14966211, 0.0], // MC
  17. [0.35409971, 0.34443972, 0.64417234, 0.30427501, 0.27956082, 0.49925481, 0.46093655, 0.32887111, 0.38695101, 0.47884837, 0.37465446, 0.39194758, 0.15198852, 0.0], // ML/R
  18. [0.32272636, 0.35024067, 0.48762872, 0.22888914, 0.19049636, 0.52620414, 0.57842512, 0.53330409, 0.07523792, 0.55942740, 0.39986691, 0.53866926, 0.20888391, 0.0], // OMC
  19. [0.36311066, 0.33106245, 0.61831416, 0.19830147, 0.17415753, 0.50049575, 0.47737842, 0.28937553, 0.34729042, 0.52834210, 0.39939218, 0.55684664, 0.21593269, 0.0], // OML/R
  20. [0.40622753, 0.29744114, 0.39446722, 0.09952139, 0.07503885, 0.50402399, 0.58505850, 0.36932466, 0.05210389, 0.53677990, 0.51998862, 0.83588627, 0.32413803, 0.0], // F
  21. [0.37313433, 0.37313433, 0.37313433, 0.74626866, 0.52238806, 0.74626866, 0.52238806, 0.52238806, 0.37313433, 0.22388060, 0.22388060]]; // GK
  22.  
  23. // RECb weights Str Sta Pac Mar Tac Wor Pos Pas Cro Tec Hea Fin Lon Set
  24. let weightRb = [
  25. [0.10493615, 0.05208547, 0.07934211, 0.14448971, 0.13159554, 0.06553072, 0.07778375, 0.06669303, 0.05158306, 0.02753168, 0.12055170, 0.01350989, 0.02549169, 0.03887550], // DC
  26. [0.07715535, 0.04943315, 0.11627229, 0.11638685, 0.12893778, 0.07747251, 0.06370799, 0.03830611, 0.10361093, 0.06253997, 0.09128094, 0.01314110, 0.02449199, 0.03726305], // DL/R
  27. [0.08219824, 0.08668831, 0.07434242, 0.09661001, 0.08894242, 0.08998026, 0.09281287, 0.08868309, 0.04753574, 0.06042619, 0.05396986, 0.05059984, 0.05660203, 0.03060871], // DMC
  28. [0.06744248, 0.06641401, 0.09977251, 0.08253749, 0.09709316, 0.09241026, 0.08513703, 0.06127851, 0.10275520, 0.07985941, 0.04618960, 0.03927270, 0.05285911, 0.02697852], // DML/R
  29. [0.07304213, 0.08174111, 0.07248656, 0.08482334, 0.07078726, 0.09568392, 0.09464529, 0.09580381, 0.04746231, 0.07093008, 0.04595281, 0.05955544, 0.07161249, 0.03547345], // MC
  30. [0.06527363, 0.06410270, 0.09701305, 0.07406706, 0.08563595, 0.09648566, 0.08651209, 0.06357183, 0.10819222, 0.07386495, 0.03245554, 0.05430668, 0.06572005, 0.03279859], // ML/R
  31. [0.07842736, 0.07744888, 0.07201150, 0.06734457, 0.05002348, 0.08350204, 0.08207655, 0.11181914, 0.03756112, 0.07486004, 0.06533972, 0.07457344, 0.09781475, 0.02719742], // OMC
  32. [0.06545375, 0.06145378, 0.10503536, 0.06421508, 0.07627526, 0.09232981, 0.07763931, 0.07001035, 0.11307331, 0.07298351, 0.04248486, 0.06462713, 0.07038293, 0.02403557], // OML/R
  33. [0.07738289, 0.05022488, 0.07790481, 0.01356516, 0.01038191, 0.06495444, 0.07721954, 0.07701905, 0.02680715, 0.07759692, 0.12701687, 0.15378395, 0.12808992, 0.03805251], // F
  34. [0.07466384, 0.07466384, 0.07466384, 0.14932769, 0.10452938, 0.14932769, 0.10452938, 0.10344411, 0.07512610, 0.04492581, 0.04479831]]; // GK
  35. // REC weights Str Sta Pac Mar Tac Wor Pos Pas Cro Tec Hea Fin Lon Set
  36. let weightR = [
  37. [0.653962303361921, 0.330014238020285, 0.562994547223387, 0.891800163983125, 0.871069095865164, 0.454514672470839, 0.555697278549252, 0.42777598627972, 0.338218821750765, 0.134348455965202, 0.796916786677566, 0.048831870932616, 0.116363443378865, 0.282347752982916], //DC
  38. [0.565605120229193, 0.430973382039533, 0.917125432457378, 0.815702528287723, 0.99022325015212, 0.547995876625372, 0.522203232914265, 0.309928898819518, 0.837365352274204, 0.483822472259513, 0.656901420858592, 0.137582588344562, 0.163658117596413, 0.303915447383549], //DL/R
  39. [0.55838825558912, 0.603683502357502, 0.563792314670998, 0.770425088563048, 0.641965853834719, 0.675495235675077, 0.683863478201805, 0.757342915150728, 0.473070797767482, 0.494107823556837, 0.397547163237438, 0.429660916538242, 0.56364174077388, 0.224791093448809], //DMC
  40. [0.582074038075056, 0.420032202680124, 0.7887541874616, 0.726221389774063, 0.722972329840151, 0.737617252827595, 0.62234458453736, 0.466946909655194, 0.814382915598981, 0.561877829393632, 0.367446981999576, 0.360623408340649, 0.390057769678583, 0.249517737311268], //DML/R
  41. [0.578431939417021, 0.778134685048085, 0.574726322388294, 0.71400292078636, 0.635403391007978, 0.822308254446722, 0.877857040588335, 0.864265671245476, 0.433450219618618, 0.697164252367046, 0.412568516841575, 0.586627586272733, 0.617905053049757, 0.308426814834866], //MC
  42. [0.497429376361348, 0.545347364699553, 0.788280917110089, 0.578724574327427, 0.663235306043286, 0.772537143243647, 0.638706135095199, 0.538453108494387, 0.887935381275257, 0.572515970409641, 0.290549550901104, 0.476180499897665, 0.526149424898544, 0.287001645266184], //ML/R
  43. [0.656437768926678, 0.617260722143117, 0.656569986958435, 0.63741054520629, 0.55148452726771, 0.922379789905246, 0.790553566121791, 0.999688557334153, 0.426203575603164, 0.778770912265944, 0.652374065121788, 0.662264393455567, 0.73120100926333, 0.274563618133769], //OMC
  44. [0.483341947292063, 0.494773052635464, 0.799434804259974, 0.628789194186491, 0.633847969631333, 0.681354437033551, 0.671233869875345, 0.536121458625519, 0.849389745477645, 0.684067723274814, 0.389732973354501, 0.499972692291964, 0.577231818355874, 0.272773352088982], //OML/R
  45. [0.493917051093473, 0.370423904816088, 0.532148929996192, 0.0629206658586336, 0.0904950078155216, 0.415494774080483, 0.54106107545574, 0.468181146095801, 0.158106484131194, 0.461125738338018, 0.83399612271067, 0.999828328674183, 0.827171977606305, 0.253225855459207], //F
  46. // For Rez Vit Ind One Ref Aer Sar Com Deg Aru
  47. [0.5, 0.333, 0.5, 1, 0.5, 1, 0.5, 0.5, 0.333, 0.333, 0.333]]; //GK
  48.  
  49.  
  50. function funFix2(i) {
  51. i = (Math.round(i * 100) / 100).toFixed(2);
  52. return i;
  53. }
  54.  
  55. function funFix3(i) {
  56. i = (Math.round(i * 1000) / 1000).toFixed(3);
  57. return i;
  58. }
  59.  
  60. //New data
  61.  
  62. const calculateREREC = (positionIndex, skills, SI, rou) => {
  63. console.log(skills)
  64. let rou2 = (3 / 100) * (100 - (100) * Math.pow(Math.E, -rou * 0.035));
  65. if (positionIndex == 9) var weight = 48717927500;
  66. else var weight = 263533760000;
  67. let rec = 0; // RERECb
  68. let ratingR = 0; // RatingR4
  69. let ratingR4 = 0; // RatingR4 + routine
  70. let skillSum = 0;
  71.  
  72. for (let i = 0; i < skills.length; i++) {
  73. skillSum += parseInt(skills[i]);
  74. }
  75.  
  76. let remainder = Math.round((Math.pow(2, Math.log(weight * SI) / Math.log(Math.pow(2, 7))) - skillSum) * 10) / 10; // RatingR4 remainder
  77.  
  78. // All position
  79. let remainderWeight = 0; // REREC remainder weight sum
  80. let remainderWeight2 = 0; // RatingR4 remainder weight sum
  81. let not20 = 0; // 20以外のスキル数
  82.  
  83.  
  84. weightR[positionIndex].forEach((value, index) => {
  85. rec += skills[index] * weightRb[positionIndex][index];
  86. ratingR += skills[index] * weightR4[positionIndex][index];
  87. if (skills[index] != 20) {
  88. remainderWeight += weightRb[positionIndex][index];
  89. remainderWeight2 += weightR4[positionIndex][index];
  90. not20++;
  91. }
  92. })
  93. if (remainder / not20 > 0.9 || not20 == 0) {
  94. if (positionIndex == 9) not20 = 11;
  95. else not20 = 14;
  96. remainderWeight = 1;
  97. remainderWeight2 = 5;
  98. }
  99.  
  100.  
  101. rec = funFix3((rec + remainder * remainderWeight / not20 - 2) / 3);
  102.  
  103. ratingR += remainder * remainderWeight2 / not20;
  104. ratingR4 = funFix2(ratingR + rou2 * 5);
  105. ratingR = funFix2(ratingR);
  106. return [rec, ratingR, ratingR4];
  107. };
  108.  
  109. //Old data
  110. const GetPlayerData = (playerID, position) => {
  111. $.ajaxSetup({async: false});
  112. let player;
  113. $.post("/ajax/tooltip.ajax.php", {
  114. "player_id": playerID
  115. }, function (responseText) {
  116. let data = JSON.parse(responseText);
  117. let skills = [];
  118. const checkSkills = data.player.skills.filter(skill => skill.value)
  119. if (position === 9) {
  120. skills = [checkSkills[0].value, checkSkills[2].value, checkSkills[4].value, checkSkills[1].value, checkSkills[3].value, checkSkills[5].value, checkSkills[6].value, checkSkills[7].value, checkSkills[8].value, checkSkills[9].value, checkSkills[10].value]
  121. } else {
  122. for (let i = 0; i <= data.player.skills.length; i = i + 2) {
  123. if (data.player.skills[i]) {
  124. skills.push(data.player.skills[i].value)
  125. }
  126. }
  127. for (let i = 1; i <= data.player.skills.length; i = i + 2) {
  128. if (data.player.skills[i]) {
  129. skills.push(data.player.skills[i].value)
  130. }
  131. }
  132. }
  133.  
  134. skills.forEach((skill, index) => {
  135. //if(skills[index] = 0) skills[index] = 1;
  136. if (typeof (skill) === 'string') {
  137. if (skill.includes('silver')) {
  138. skills[index] = 19
  139. } else {
  140. skills[index] = 20
  141. }
  142. }
  143. })
  144. player = {
  145. skills,
  146. number: data.player.no,
  147. id: data.player.player_id,
  148. position,
  149. ASI: Number(data.player.skill_index.split(',').join('')),
  150. xp: Number(data.player.routine.split(',').join('')),
  151. age: Number(data.player.age) * 12 + Number(data.player.months)
  152. };
  153.  
  154. });
  155. return player;
  156. }
  157.  
  158. const average = (players, column) => {
  159. const total = players.reduce((carry, player) => {
  160. carry = carry + player[column]
  161. return carry;
  162. }, 0)
  163. return (total / 11)
  164. }
  165.  
  166. const toFixed = (num, decimals) => {
  167. return num.toFixed(decimals)
  168. }
  169.  
  170. const ShowInfo = () => {
  171. if(document.querySelector('#tabs_content')){
  172. document.querySelector('#tabs_content').style.paddingLeft = 0;
  173. document.querySelector('#tabs_content').style.paddingRight = 0;
  174. const playersEl = [...document.getElementsByClassName("player_field")[0].getElementsByClassName("pog")];
  175.  
  176. const quarter = document.querySelectorAll('.quarter');
  177. [...quarter].forEach(q => {
  178. q.style.margin = 0;
  179. q.style.width = '245px'
  180. const list = q.querySelector('.player_list');
  181. list.style.padding = 0;
  182. list.style.width = '100%'
  183. });
  184.  
  185. let homePlayers = [];
  186. let awayPlayers = [];
  187. playersEl.forEach((el, index) => {
  188. let position = 0;
  189. if (el.classList.contains('gk')) position = 9;
  190. else if (el.classList.contains('d')) {
  191. position = ['237px', '47px'].includes(el.style.marginTop) ? 1 : 0
  192. } else if (el.classList.contains('dm')) {
  193. position = ['237px', '47px'].includes(el.style.marginTop) ? 3 : 2
  194. } else if (el.classList.contains('m')) {
  195. position = ['237px', '47px'].includes(el.style.marginTop) ? 5 : 4
  196. } else if (el.classList.contains('om')) {
  197. position = ['237px', '47px'].includes(el.style.marginTop) ? 7 : 6
  198. } else position = 8
  199. let playerID = el.getAttribute("player_id");
  200. let player = GetPlayerData(playerID, position);
  201. player.rating = calculateREREC(position, player.skills, player.ASI, player.xp);
  202. player.ratingRec = Number(player.rating[2]);
  203. if (index <= 10) {
  204. homePlayers.push(player);
  205. [...quarter[0].querySelectorAll('li')].forEach(list => {
  206. list.dataset.convert = '1234'
  207. const id = list.querySelector('a').getAttribute("href").replace('/players/', '');
  208. if(id === player.id) {
  209. list.querySelector('.favposition').querySelector('span').innerHTML = player.number;
  210. list.querySelector('.icons').style.width = '140px';
  211. const ratingEl = document.createElement('div');
  212. list.style.height = '22px';
  213. list.style.position = 'relative'
  214. ratingEl.style.position = 'absolute';
  215. ratingEl.style.right = 0;
  216. ratingEl.innerHTML = player.rating[2];
  217. list.appendChild(ratingEl);
  218. }
  219. })
  220. }
  221. else {
  222. awayPlayers.push(player);
  223. [...quarter[1].querySelectorAll('li')].forEach(list => {
  224. const id = list.querySelector('a').getAttribute("href").replace('/players/', '');
  225. if(id === player.id) {
  226. list.querySelector('.favposition').querySelector('span').innerHTML = player.number;
  227. list.querySelector('.icons').style.width = '140px';
  228. const ratingEl = document.createElement('div');
  229. list.style.height = '22px';
  230. list.style.position = 'relative'
  231. ratingEl.style.position = 'absolute';
  232. ratingEl.style.right = 0;
  233. ratingEl.innerHTML = player.rating[2];
  234. list.appendChild(ratingEl);
  235. }
  236. })
  237. }
  238. }
  239. );
  240. let newdiv = document.createElement("div");
  241. newdiv.style.paddingTop = '33px';
  242. newdiv.id = 'teamRatings';
  243. let html = ``;
  244. [homePlayers, awayPlayers].forEach((team, index) => {
  245. const colors = index ? [127, 30, 45] : [35, 45, 125];
  246. html += `<div
  247. class="${index ? 'away' : 'home'} color"
  248. style="background-color:rgb(${colors.join()});height: auto">
  249. <b style="color: gold;">
  250. Rating:${toFixed(average(team, 'ratingRec'), 2)}
  251. XP:${toFixed(average(team, 'xp'), 1)}
  252. Age:${toFixed(average(team, 'age') / 12, 1)}
  253. ASI:${toFixed(average(team, 'ASI'), 0)}
  254. </b>
  255. </div>`
  256. });
  257. newdiv.innerHTML = html;
  258. const teamRatings = document.querySelector('#teamRatings');
  259. if(!teamRatings) {
  260. document.getElementsByClassName("nameplate")[0].appendChild(newdiv);
  261. } else {
  262. teamRatings.parentNode.replaceChild(newdiv, teamRatings);
  263. }
  264. }
  265. }
  266.  
  267. let field = false;
  268. let interval = setInterval(() => {
  269. if(document.querySelector(".player_field") && !field){
  270. field = true;
  271. ShowInfo();
  272. //clearInterval(interval);
  273. }
  274. if(document.querySelector(".player_field")){
  275. const dataset = document.querySelector('.quarter').querySelector('li').dataset.convert;
  276. if(!dataset) ShowInfo();
  277. }
  278. }, 100)

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址