Stats Xente Script

Stats Xente script for inject own data on Managerzone site

当前为 2024-12-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Stats Xente Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.120
  5. // @description Stats Xente script for inject own data on Managerzone site
  6. // @author xente
  7. // @match https://www.managerzone.com/*
  8. // @icon https://statsxente.com/MZ1/View/Images/main_icon.png
  9. // @license GNU
  10. // @grant GM_xmlhttpRequest
  11. // @grant GM_addStyle
  12. // @grant GM_getValue
  13. // @grant GM_setValue
  14. // @grant GM_deleteValue
  15. // @grant GM_listValues
  16. // @require https://code.jquery.com/jquery-3.7.1.js
  17. // ==/UserScript==
  18.  
  19. (function () {
  20. 'use strict';
  21.  
  22. /*let keys = GM_listValues();
  23. keys.forEach(function(key) {
  24. console.log(key+" "+GM_getValue(key))
  25. });*/
  26.  
  27. /*let actual_version="0.9666"
  28. console.log(GM_info.script.version)
  29.  
  30. if(GM_info.script.version!=actual_version){
  31. console.log("here")
  32. keys = GM_listValues();
  33. keys.forEach(function (key) {
  34. GM_deleteValue(key);
  35. });
  36. }*/
  37.  
  38. setCSSStyles()
  39. createModalMenu()
  40. waitToDOMById(createModalEventListeners,"saveButton",5000)
  41. setLangSportCats()
  42. getUsernameData()
  43. checkScriptVersion()
  44.  
  45. /// FUNCTIONS MENU
  46. setTimeout(function () {
  47.  
  48. const urlParams = new URLSearchParams(window.location.search);
  49. if ((urlParams.has('p')) && (urlParams.get('p') === 'league') && (GM_getValue("leagueFlag"))) {
  50. waitToDOM(leagues, ".nice_table", 0,7000)
  51. }
  52.  
  53. if ((urlParams.has('p')) && (urlParams.get('p') === 'federations')
  54. && (urlParams.get('sub') === 'league') && (GM_getValue("federationFlag"))) {
  55. waitToDOM(clashLeagues, ".nice_table", 0,7000)
  56. }
  57.  
  58. if ((urlParams.has('p')) && (urlParams.get('p') === 'federations')
  59. && (urlParams.get('sub') === 'clash') && (GM_getValue("federationFlag"))) {
  60. getDeviceFormat()
  61. waitToDOM(clash, ".fed_badge", 0,7000)
  62. }
  63.  
  64. if ((urlParams.has('p')) && (urlParams.get('p') === 'match')
  65. && (urlParams.get('sub') === 'result') && (GM_getValue("matchFlag"))) {
  66. setTimeout(function () {
  67. waitToDOM(match, ".hitlist.statsLite.marker", 0,7000)
  68. }, 2000);
  69. }
  70.  
  71. if ((urlParams.has('p')) && (urlParams.get('p') === 'players') && (!urlParams.has('pid'))
  72. && (GM_getValue("playersFlag"))) {
  73. getDeviceFormat()
  74. waitToDOM(playersPage, ".playerContainer", 0,7000)
  75.  
  76. }
  77.  
  78. if ((urlParams.has('p')) && (urlParams.get('p') === 'players') && (urlParams.has('pid'))) {
  79. waitToDOM(playersPageStats, ".player_name", 0,7000)
  80. }
  81.  
  82.  
  83. if ((urlParams.has('p')) && (urlParams.get('p') === 'rank') && (urlParams.get('sub') === 'countryrank')
  84. && (GM_getValue("countryRankFlag"))) {
  85. countryRank();
  86. }
  87.  
  88. if ((urlParams.has('p')) && (urlParams.get('p') === 'clubhouse')) {
  89. StatsXenteNextMatchesClubhouse()
  90. }
  91.  
  92.  
  93. if ((urlParams.has('p')) && (urlParams.get('p') === 'friendlyseries')
  94. && (urlParams.get('sub') === 'standings')) {
  95. waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0,7000)
  96. }
  97.  
  98.  
  99. if ((urlParams.has('p')) && (urlParams.get('p') === 'cup') && (urlParams.get('sub') === 'groupplay')) {
  100. waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0,7000)
  101. }
  102.  
  103.  
  104. if ((urlParams.has('p')) && (urlParams.get('p') === 'private_cup') && (urlParams.get('sub') === 'groupplay')) {
  105. waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0,7000)
  106. }
  107.  
  108.  
  109.  
  110. if ((urlParams.has('p')) && (urlParams.get('p') === 'match') && (urlParams.get('sub') === 'played')) {
  111. if(GM_getValue("eloNextMatchesFlag")){
  112. waitToDOM(nextMatches, ".group", 0,7000)
  113. }
  114. if(GM_getValue("eloPlayedMatchesFlag")){
  115. waitToDOM(lastMatchesELO, ".group", 0,7000)
  116. }
  117.  
  118. }
  119.  
  120.  
  121.  
  122.  
  123. if ((urlParams.has('p')) && (urlParams.get('p') === 'match') && (urlParams.get('sub') === 'scheduled')) {
  124. if(GM_getValue("eloNextMatchesFlag")){
  125. waitToDOM(nextMatches, ".group", 0,7000)
  126. }
  127. }
  128.  
  129.  
  130. if ((urlParams.has('p')) && (urlParams.get('p') === 'team') && (GM_getValue("teamPageFlag"))) {
  131. teamPage()
  132. }
  133.  
  134. if ((urlParams.has('p')) && (urlParams.get('p') === 'rank') && (urlParams.has('sub')) &&
  135. (urlParams.get('sub') === 'userrank')) {
  136. usersRank()
  137. }
  138.  
  139.  
  140. if ((urlParams.has('p')) && (urlParams.get('p') === 'training_report')&& (GM_getValue("trainingReportFlag"))) {
  141. getDeviceFormat()
  142. waitToDOMById(trainingReport,"training_report",5000)
  143. }
  144.  
  145.  
  146.  
  147.  
  148.  
  149. if ((urlParams.has('p')) && (urlParams.get('p') !== 'players')){
  150.  
  151. const elementos = document.querySelectorAll('.player_link'); //Adds stats icon in players page, when click on player info
  152. elementos.forEach(function (elemento) {
  153. elemento.addEventListener('click', function () {
  154. waitToDOM(playersPageStats, ".player_name", 0,7000)
  155. });
  156. });
  157.  
  158. }
  159.  
  160.  
  161. }, 1000);
  162.  
  163. let teams_data = "";
  164. let searchClassName = ""
  165. let players = []
  166. let lines = []
  167. let gk_line = ""
  168. let skills_names = []
  169. let su_line = "unsetted";
  170.  
  171. //BUTTONS EVENTS LISTENERS
  172. const urlParams = new URLSearchParams(window.location.search);
  173. if ((urlParams.get('p') === 'friendlyseries')||(urlParams.get('p') === 'federations')){
  174. waitToDOMById(tableFLAndClashEventListener,"ui-id-2",5000)
  175. }
  176.  
  177. if (urlParams.get('p') === 'cup'){
  178. waitToDOMById(tableCupsEventListener,"ui-id-4",5000)
  179. }
  180. waitToDOMById(tableLeaguesEventListener,"league_tab_table",5000)
  181.  
  182. function tableLeaguesEventListener(){
  183. document.getElementById("league_tab_table").addEventListener('click', function () {
  184. if (document.getElementById("showMenu") === null) {
  185. waitToDOM(leagues, ".nice_table", 0,7000)
  186. }
  187. });
  188.  
  189. }
  190.  
  191. function tableCupsEventListener(){
  192. document.getElementById("ui-id-4").parentNode.addEventListener('click', function () {
  193. if (document.getElementById("showMenu") === null) {
  194. waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0,7000)
  195. }
  196.  
  197.  
  198. viewButtonCupsEventListener()
  199.  
  200.  
  201. });
  202.  
  203.  
  204. }
  205.  
  206. function viewButtonCupsEventListener(){
  207. document.addEventListener('click', function(event) {
  208. if ((event.target) &&((event.target.parentNode.id === 'view_btn')||(event.target.parentNode.parentNode.id === 'view_btn'))) {
  209. setTimeout(function () {
  210. if (document.getElementById("showMenu") === null) {
  211. waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0,7000)
  212. }
  213. }, 1000);
  214. }
  215. });
  216.  
  217. }
  218.  
  219. function tableFLAndClashEventListener(){
  220. document.getElementById("ui-id-2").parentNode.addEventListener('click', function () {
  221. if (document.getElementById("showMenu") === null) {
  222. const urlParams = new URLSearchParams(window.location.search);
  223. if (urlParams.get('fsid')) {
  224. waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0,7000)
  225. } else {
  226. waitToDOM(clashLeagues, ".nice_table", 0,7000)
  227. }
  228.  
  229. }
  230. });
  231. }
  232.  
  233. //Workers
  234. const workerCode = `
  235. self.onmessage = function (e) {
  236. const { elementos, sport, skillsNames, tacticsList, flagStats } = e.data;
  237. let players = [];
  238. let lines = [];
  239. let gk_line = "";
  240. let su_line = "";
  241.  
  242. // Procesar cada elemento
  243. for (let i = 0; i < elementos.length; i++) {
  244. let playerValues = {
  245. id: elementos[i].id,
  246. skills: [],
  247. lines: [],
  248. tacticsPosition: {},
  249. tactics: [],
  250. age: parseInt(elementos[i].age),
  251. };
  252.  
  253. // Procesar tácticas y líneas
  254. for (let j = 0; j < elementos[i].tactics.length; j++) {
  255. const tactic = elementos[i].tactics[j].name;
  256. const line = elementos[i].tactics[j].line;
  257.  
  258. if(sport=="soccer"){
  259. if (line.includes(",")) {
  260. var fin = line.indexOf(',');
  261. su_line = line.substring(0, fin);
  262. }
  263.  
  264.  
  265. }
  266.  
  267.  
  268. playerValues.tactics.push(tactic);
  269. playerValues.tacticsPosition[tactic] = line;
  270.  
  271. // Usar un Set para evitar líneas duplicadas
  272. if (!lines.includes(line)) {
  273. lines.push(line);
  274. playerValues.lines.push(line);
  275. }
  276. }
  277. var key=0;
  278. if(sport=="soccer"){
  279. key=1;
  280. }
  281.  
  282. // Procesar habilidades
  283. for (let j = 0; j < elementos[i].skills.length-key; j++) {
  284. playerValues.skills.push(elementos[i].skills[j]);
  285. }
  286.  
  287. players.push(playerValues);
  288. }
  289.  
  290. // Enviar datos procesados al hilo principal
  291. self.postMessage({ players:players, lines: [...new Set(lines)], gk_line:gk_line, su_line:su_line, tacticsList: [...new Set(tacticsList)], skillsNames:skillsNames });
  292. };
  293. `;
  294.  
  295.  
  296.  
  297. //Training Report
  298. function trainingReport(){
  299.  
  300. if(!document.getElementById("trainingDaysId")){
  301. let elem=document.getElementsByClassName("headerPanel")
  302. elem[0].id="trainingDaysId"
  303.  
  304.  
  305. document.getElementById("trainingDaysId").addEventListener('click', function () {
  306. setTimeout(function () {
  307. waitToDOMById(trainingReport,"training_report",5000)
  308. }, 500);
  309.  
  310.  
  311. });
  312. }
  313. let key="ball"
  314. if(window.sport==="hockey"){
  315. key="puck"
  316. }
  317.  
  318. let promesas = [];
  319. let clase="loader-"+window.sport
  320. if(window.stx_device==="computer"){
  321.  
  322. let elements0 = document.querySelectorAll('.dailyReportRightColumn');
  323. elements0.forEach(element0 => {
  324. let previousTd = element0.previousElementSibling.previousElementSibling.previousElementSibling;
  325. if((!previousTd.innerHTML.includes("training_graph_icon"))&&(previousTd.innerHTML.includes("<img"))){
  326. let loaders=previousTd.getElementsByClassName("containerLoaderDiv")
  327. if(loaders.length>0){
  328. loaders[0].innerHTML='<div id="hp_loader" class="'+clase+'" style="gap: 10px;display:inline-block; width:25%"></div>'+loaders[0].innerHTML;
  329. }else{
  330. previousTd.innerHTML='<div id="hp_loader" class="'+clase+'" style="gap: 10px;display:inline-block; width:25%"></div>'+previousTd.innerHTML
  331. previousTd.innerHTML="<div class=containerLoaderDiv style='display: flex; align-items: center;gap: 8px;'>"+previousTd.innerHTML+"</div>"
  332. }
  333. }
  334. if(element0.innerHTML.includes(key)){
  335. let skills = element0.previousElementSibling.previousElementSibling;
  336. let number_skills=skills.getElementsByClassName("skillBallSeparator")
  337.  
  338. if(number_skills.length>3){
  339.  
  340. let player_td = element0.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling;
  341. let player_as=player_td.getElementsByTagName("a")
  342. let link=player_as[0].href
  343. promesas.push(fetchAndProcessPlayerData(link,previousTd.innerText,previousTd,window.stx_device))
  344. }
  345. }
  346.  
  347. });
  348.  
  349. }else{
  350.  
  351. let elements0 = document.querySelectorAll('.playerColumn.hitlist-compact-list-column');
  352. elements0.forEach(element0 => {
  353. let dl=element0.getElementsByClassName("hitlist-compact-list markers")
  354. let newDL = document.createElement("dl");
  355. newDL.className="hitlist-compact-list markers";
  356. newDL.innerHTML='<div id="hp_loader" class="'+clase+'" style="display:inline-block; width:15%"></div>'
  357. dl[0].appendChild(newDL)
  358.  
  359. if(element0.innerHTML.includes(key)){
  360. let number_skills=element0.getElementsByClassName("skillBallSeparator")
  361.  
  362. if(number_skills.length>3){
  363.  
  364. let player_as=element0.getElementsByTagName("a")
  365. let link=player_as[0].href
  366. let toChange=element0.getElementsByClassName("responsive-show floatRight")
  367. promesas.push(fetchAndProcessPlayerData(link,toChange[0].innerText,toChange[0],window.stx_device))
  368. }
  369. }
  370. });
  371.  
  372.  
  373.  
  374.  
  375.  
  376. }
  377.  
  378. Promise.all(promesas)
  379. .then(() => {
  380. const elementos = document.querySelectorAll('.'+clase);
  381. elementos.forEach(elemento => elemento.remove());
  382. })
  383. .catch(() => {
  384. const elementos = document.querySelectorAll('.'+clase);
  385. elementos.forEach(elemento => elemento.remove());
  386. });
  387.  
  388.  
  389.  
  390. }
  391. //Users ranking page
  392. function usersRank(){
  393. let initialValues = {};
  394. initialValues["senior"] = GM_getValue("league_default_senior");
  395.  
  396. let linkIds = ""
  397. let tabla = document.getElementById("userRankTable");
  398.  
  399.  
  400. let values = new Map();
  401. values.set('valor23', 'U23 Value');
  402. values.set('valor21', 'U21 Value');
  403. values.set('valor18', 'U18 Value');
  404. values.set('salario', 'Salary');
  405. values.set('valorUPSenior', 'LM Value');
  406. values.set('valorUPSUB23', 'U23 LM Value');
  407. values.set('valorUPSUB21', 'U21 LM Value');
  408. values.set('valorUPSUB18', 'U18 LM Value');
  409. values.set('edad', 'Age');
  410. if (window.sport === "soccer") {
  411. values.set('valor11', 'TOP 11');
  412. values.set('valor11_23', 'U23 TOP 11');
  413. values.set('valor11_21', 'U21 TOP 11');
  414. values.set('valor11_18', 'U18 TOP 11');
  415. } else {
  416. values.set('valor11', 'TOP 21');
  417. values.set('valor11_23', 'U23 TOP 21');
  418. values.set('valor11_21', 'U21 TOP 21');
  419. values.set('valor11_18', 'U18 TOP 21');
  420. }
  421. values.set('noNac', 'Foreigners');
  422. values.set('elo', 'ELO Score');
  423. values.set('elo23', 'U23 ELO Score');
  424. values.set('elo21', 'U21 ELO Score');
  425. values.set('elo18', 'U18 ELO Score');
  426. values.set('numJugadores', 'Number of players');
  427. values.set('leagues_all', 'Leagues');
  428. values.set('world_leagues_all', 'World Leagues');
  429. values.set('youth_leagues_all', 'Youth Leagues');
  430. values.set('world_youth_leagues_all', 'Youth World Leagues');
  431. values.set('federation_leagues', 'Federation Leagues');
  432. values.set('cup', 'Cups');
  433. values.set('cup_u23', 'U23 Cups');
  434. values.set('cup_u21', 'U21 Cups');
  435. values.set('cup_u18', 'U18 Cups');
  436. values.set('special_cup', 'Special Cups');
  437.  
  438. let contenidoNuevo = '<div id=testClick style="margin: 0 auto;">';
  439. getNativeTableStyles();
  440.  
  441. ///MENU TABLE
  442. contenidoNuevo += "<table id=showMenu style='margin: 0 auto;'><thead style='border-color:white; margin: 0 auto; background-color:" + GM_getValue("bg_native") + "; color:" + GM_getValue("color_native") + ";'>"
  443. contenidoNuevo +="<tr>";
  444. contenidoNuevo += '<th style="text-align:center; margin: 0 auto; padding:4px;" colspan="4">Values</th>'
  445. contenidoNuevo += "</tr>";
  446.  
  447. let styleTable = " style='margin: 0 auto; display:none;'";
  448. let styleIcon = ""
  449. let styleSep = "style='padding-top:5px;'";
  450.  
  451. if (GM_getValue("show_league_selects") === true) {
  452. styleTable = " style='margin: 0 auto;'";
  453. styleIcon = " active"
  454. styleSep = " style='display:none;'";
  455. }
  456.  
  457.  
  458. contenidoNuevo += "<tr><td></td><td colspan='2' style='padding-top:5px;'>";
  459. contenidoNuevo += '<div id="moreInfo" class="expandable-icon' + styleIcon + '" style="margin: 0 auto; cursor:pointer; background-color:' + GM_getValue("bg_native") + ';"><div id="line1" class="line"></div><div id="line2" class="line"></div></div></center>';
  460. contenidoNuevo += "</td><td></td></tr>";
  461. contenidoNuevo += "<tr><td colspan='5' id='separatorTd'" + styleSep + "></td></tr>";
  462. contenidoNuevo += "</table></center>";
  463. contenidoNuevo += '<table id=show3' + styleTable + '><tr><td><label>';
  464.  
  465. if ("valor" === initialValues["senior"]) {
  466. contenidoNuevo += '<input class="statsxente" type="checkbox" checked id="valor" value="Value">Value</label></td>';
  467. } else {
  468. contenidoNuevo += '<input class="statsxente" type="checkbox" id="valor" value="Value">Value</label></td>';
  469. }
  470.  
  471. values.forEach(function (valor, clave) {
  472.  
  473. if (clave === "valorUPSenior") {
  474. contenidoNuevo += "</tr><tr>";
  475. }
  476.  
  477. if (clave === "valor11") {
  478. contenidoNuevo += "</tr><tr>";
  479. }
  480. if (clave === "elo") {
  481. contenidoNuevo += "</tr><tr>";
  482. }
  483.  
  484. if (clave === "leagues") {
  485. contenidoNuevo += "</tr><tr>";
  486. }
  487.  
  488. if (clave === "leagues_all") {
  489. contenidoNuevo += "</tr><tr>";
  490. }
  491.  
  492. if (clave === "cup") {
  493. contenidoNuevo += "</tr><tr>";
  494. }
  495.  
  496. if (clave === initialValues["senior"]) {
  497. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" checked value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  498. } else {
  499. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  500. }
  501. });
  502. contenidoNuevo += "</tr></table></center>"
  503. contenidoNuevo += "</div></br>";
  504. values.set('valor', 'Value');
  505.  
  506. tabla.insertAdjacentHTML('beforebegin', contenidoNuevo);
  507.  
  508. if (GM_getValue("show_league_selects") === true) {
  509. document.getElementById("line2").style.transform = 'rotateZ(0deg)';
  510. document.getElementById("line1").style.transform = 'rotateZ(180deg)';
  511. document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
  512. }
  513. values.forEach(function (valor, clave) {
  514. let elemento = document.getElementById(clave);
  515. elemento.addEventListener('click', handleClickUserRank);
  516. });
  517. (function () {
  518. document.getElementById("moreInfo").addEventListener('click', function () {
  519. document.getElementById("moreInfo").classList.toggle('active');
  520.  
  521. if (document.getElementById("moreInfo").classList.contains("active")) {
  522. document.getElementById("line2").style.transform = 'rotateZ(0deg)';
  523. document.getElementById("line1").style.transform = 'rotateZ(180deg)';
  524. document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
  525. $('#separatorTd').fadeOut(1);
  526. document.getElementById("separatorTd").style.paddingTop = "5px";
  527. $('#show3').fadeIn('slow');
  528. } else {
  529. document.getElementById("line2").style.transform = 'rotateZ(45deg)';
  530. document.getElementById("line1").style.transform = 'rotateZ(-45deg)';
  531. document.getElementById("moreInfo").style.transform = 'rotateZ(45deg)';
  532. $('#separatorTd').fadeIn(1);
  533. $('#show3').fadeOut('slow');
  534. }
  535.  
  536. });
  537. })();
  538.  
  539.  
  540.  
  541. const filas = document.querySelectorAll("#userRankTable tr");
  542. let contIds=0;
  543. for (let i = 1; i < filas.length; i++) {
  544. const fila = filas[i];
  545. const tercerTd = fila.children[4];
  546. const cuartoTd = fila.children[5];
  547.  
  548. let data=extractTeamData(fila.children[3].getElementsByTagName("a"))
  549. linkIds += "&idEquipo" + contIds + "=" + data[0]
  550. contIds++;
  551. if (tercerTd && cuartoTd) {
  552. tercerTd.innerHTML = cuartoTd.innerHTML + " " + tercerTd.innerHTML;
  553. cuartoTd.innerHTML=""
  554. }
  555. }
  556.  
  557. let nuevaCeldaEncabezado = document.querySelector("#userRankTable th:last-of-type");
  558. nuevaCeldaEncabezado.innerHTML = "<a href='#'>"+values.get(initialValues["senior"])+"</a>"
  559. nuevaCeldaEncabezado.style.textAlign = 'center';
  560. nuevaCeldaEncabezado.style.maxWidth = '8.5em';
  561. nuevaCeldaEncabezado.style.width = '8.5em';
  562. nuevaCeldaEncabezado.style.whiteSpace = 'nowrap';
  563. nuevaCeldaEncabezado.style.overflow = 'hidden';
  564. nuevaCeldaEncabezado.style.textOverflow = 'ellipsis';
  565. nuevaCeldaEncabezado.id="stx_value"
  566.  
  567. document.getElementById("stx_value").addEventListener("click", function () {
  568. setTimeout(function () {
  569. ordenarTabla(5, false, "userRankTable",false);
  570. }, 20);
  571. });
  572.  
  573.  
  574.  
  575.  
  576.  
  577. GM_xmlhttpRequest({
  578. method: "GET",
  579. url: "https://statsxente.com/MZ1/Functions/tamper_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + linkIds,
  580. headers: {
  581. "Content-Type": "application/json"
  582. },
  583. onload: function (response) {
  584. teams_data = JSON.parse(response.responseText);
  585. const filas = document.querySelectorAll("#userRankTable tr");
  586. for (let i = 1; i < filas.length; i++) {
  587. const fila = filas[i];
  588. const tercerTd = fila.children[5];
  589. let data=extractTeamData(fila.children[3].getElementsByTagName("a"))
  590. tercerTd.innerText=new Intl.NumberFormat(window.userLocal).format(Math.round(teams_data[data[0]]['elo']))
  591. tercerTd.align = "center";
  592. }
  593. }});
  594. }
  595. //Next matches page
  596. function nextMatches(){
  597.  
  598.  
  599. let selectElements = document.getElementsByName('limit');
  600. if (selectElements.length > 0) {
  601. let selectElement = selectElements[0];
  602. selectElement.addEventListener('change', function() {
  603. if(GM_getValue("eloNextMatchesFlag")){
  604. waitToDOM(nextMatches, ".group", 0,7000)
  605. }
  606. });
  607. }
  608. selectElements = document.getElementsByName('selectType');
  609. if (selectElements.length > 0) {
  610. let selectElement = selectElements[0];
  611. selectElement.addEventListener('change', function() {
  612. if(GM_getValue("eloNextMatchesFlag")){
  613. waitToDOM(nextMatches, ".group", 0,7000)
  614. }
  615. });
  616. }
  617.  
  618.  
  619. let team_id=""
  620. let urlParams = new URLSearchParams(window.location.search);
  621. if (urlParams.has('tid')){
  622. team_id=urlParams.get("tid")
  623. }else{
  624. if(window.sport==="soccer"){
  625. team_id=GM_getValue("soccer_team_id")
  626. }else{
  627. team_id=GM_getValue("hockey_team_id")
  628. }
  629. }
  630.  
  631.  
  632. let team_ids=[]
  633. let linkIds=""
  634. let contIds=0
  635. let cIds=""
  636. let contCIds=0
  637. let comps=[]
  638. let comp_ids=[]
  639. let elements0 = document.querySelectorAll('.odd');
  640.  
  641. elements0.forEach(element0 => {
  642. let cat=element0.getElementsByClassName("responsive-hide match-reference-text-wrapper flex-grow-0");
  643. if(cat.length>0){
  644. let links = cat[0].querySelectorAll('a');
  645.  
  646. if(links.length>0){
  647. let urlObj = new URL("https://www.managerzone.com/" + links[0].getAttribute('href'));
  648. let params = new URLSearchParams(urlObj.search);
  649. let type = params.get('type');
  650.  
  651. if(type===null){
  652.  
  653. if((params.get('p')==="cup")||(params.get('p')==="private_cup")){
  654.  
  655.  
  656. if(links[0].textContent.includes("U23")){
  657. comps[params.get('cid')]="U23"
  658. }else{
  659. if(links[0].textContent.includes("U21")){
  660. comps[params.get('cid')]="U21"
  661. }else{
  662.  
  663.  
  664. if(links[0].textContent.includes("U18")){
  665. comps[params.get('cid')]="U18"
  666. }else{
  667.  
  668. comps[params.get('cid')]="SENIOR";
  669. }
  670. }
  671. }
  672. }else{
  673.  
  674. let id=0;
  675.  
  676. switch(params.get('p')){
  677. case "cup":
  678. id=params.get('cid');
  679. break;
  680. case "private_cup":
  681. id=params.get('cid');
  682. break;
  683. case "friendly_series":
  684. id=params.get('fsid');
  685. break;
  686. case "friendlyseries":
  687. id=params.get('fsid');
  688. break;
  689.  
  690. }
  691.  
  692. if (!comp_ids.includes(id)) {
  693. comp_ids.push(id);
  694. cIds += "&idComp" + contCIds + "=" + id
  695. contCIds++;
  696. }
  697. }
  698. }
  699. }
  700. }
  701.  
  702.  
  703.  
  704. let elements1 = element0.querySelectorAll('.teams-wrapper .flex-grow-1');
  705. elements1.forEach(element1 => {
  706. let elements2 = element1.querySelectorAll('.clippable');
  707. elements2.forEach(element2 => {
  708. let urlObj = new URL("https://www.managerzone.com/" + element2.getAttribute('href'));
  709.  
  710. let params = new URLSearchParams(urlObj.search);
  711. let tidValue = params.get('tid');
  712. if(tidValue!==null){
  713. if (!team_ids.includes(tidValue)) {
  714. team_ids.push(tidValue);
  715. linkIds += "&idEquipo" + contIds + "=" + tidValue
  716. contIds++;
  717. }
  718. }
  719. });
  720. });
  721. });
  722.  
  723. if (!team_ids.includes(team_id)) {
  724. linkIds += "&idEquipo" + contIds + "=" + team_id
  725. }
  726.  
  727.  
  728. GM_xmlhttpRequest({
  729. method: "GET",
  730. url: "https://statsxente.com/MZ1/Functions/tamper_elo_values.php?sport=" + window.sport + linkIds+cIds,
  731. headers: {
  732. "Content-Type": "application/json"
  733. },
  734. onload: function (response) {
  735. let rawJSON = JSON.parse(response.responseText);
  736. let jsonResponse=rawJSON["teams"]
  737.  
  738.  
  739. for (let key in rawJSON["comps"]) {
  740. comps[key]=rawJSON["comps"][key]['restriction']
  741. }
  742.  
  743. let elements0 = document.querySelectorAll('.odd:not(.uxx)');
  744. elements0.forEach(element0 => {
  745. let elements1 = element0.querySelectorAll('.teams-wrapper .flex-grow-1');
  746. elements1.forEach(element1 => {
  747. let elements2 = element1.querySelectorAll('.clippable');
  748. elements2.forEach(element2 => {
  749. let urlObj = new URL("https://www.managerzone.com/" + element2.getAttribute('href'));
  750. let params = new URLSearchParams(urlObj.search);
  751. let tidValue = params.get('tid');
  752. if(tidValue!==null){
  753. tidValue=parseInt(tidValue)
  754. let valor=0;
  755. if (jsonResponse[tidValue]?.SENIOR) {
  756. valor = new Intl.NumberFormat(window.userLocal).format(Number.parseFloat(jsonResponse[tidValue]["SENIOR"]).toFixed(0))
  757. }
  758. element1.innerHTML+="</br>"+valor;
  759. }else{
  760. tidValue=parseInt(team_id)
  761. let valor=0;
  762. if (jsonResponse[tidValue]?.SENIOR) {
  763. valor = new Intl.NumberFormat(window.userLocal).format(Number.parseFloat(jsonResponse[tidValue]["SENIOR"]).toFixed(0))
  764. }
  765. element1.innerHTML+="</br>"+valor;
  766. }
  767. });
  768. });
  769. });
  770.  
  771. let temp_cats=[]
  772.  
  773. temp_cats["u23"] = "U23";
  774. temp_cats["u21"] = "U21";
  775. temp_cats["u18"] = "U18";
  776. temp_cats["u23_world"] = "U23";
  777. temp_cats["u21_world"] = "U21";
  778. temp_cats["u18_world"] = "U18";
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785. elements0 = document.querySelectorAll('.odd.uxx');
  786.  
  787. elements0.forEach(element0 => {
  788. let cat=element0.getElementsByClassName("responsive-hide match-reference-text-wrapper flex-grow-0");
  789. let links = cat[0].querySelectorAll('a');
  790. let type
  791. let href=""
  792. if(links[0]!==undefined){
  793. href=links[0].getAttribute('href')
  794. }
  795.  
  796. let urlObj = new URL("https://www.managerzone.com/" +href);
  797. let params = new URLSearchParams(urlObj.search);
  798. type = params.get('type');
  799.  
  800. let elo_type="SENIOR"
  801. if(type==null){
  802. if(params.get('cid')!=null){
  803. elo_type=comps[params.get('cid')]
  804. }
  805. if(params.get('fsid')!=null){
  806. elo_type=comps[params.get('fsid')]
  807. }
  808. }else{
  809. elo_type=temp_cats[type]
  810. }
  811.  
  812. let elements1 = element0.querySelectorAll('.teams-wrapper .flex-grow-1');
  813. elements1.forEach(element1 => {
  814. let elements2 = element1.querySelectorAll('.clippable');
  815. elements2.forEach(element2 => {
  816. let urlObj = new URL("https://www.managerzone.com/" + element2.getAttribute('href'));
  817. let params = new URLSearchParams(urlObj.search);
  818. let tidValue = params.get('tid');
  819. if(tidValue!==null){
  820. tidValue=parseInt(tidValue)
  821. let valor=0;
  822. if(jsonResponse[tidValue] && jsonResponse[tidValue][elo_type] !== undefined){
  823. valor = new Intl.NumberFormat(window.userLocal).format(Number.parseFloat(jsonResponse[tidValue][elo_type]).toFixed(0))
  824. }
  825. element1.innerHTML+="</br>"+valor;
  826. }else{
  827. tidValue=parseInt(team_id)
  828. let valor=0;
  829. if(jsonResponse[tidValue] && jsonResponse[tidValue][elo_type] !== undefined){
  830. valor = new Intl.NumberFormat(window.userLocal).format(Number.parseFloat(jsonResponse[tidValue][elo_type]).toFixed(0))
  831. }
  832. element1.innerHTML+="</br>"+valor;
  833. }
  834. });
  835. });
  836. });
  837. }
  838. });
  839.  
  840.  
  841. }
  842. //Team page
  843. function teamPage(){
  844. let u23_type="",u21_type="",u18_type=""
  845. let team_name_div=document.getElementsByClassName("teamDataText clippable");
  846. const team_name=encodeURI(team_name_div[0].textContent)
  847. let team_id=""
  848. let urlParams = new URLSearchParams(window.location.search);
  849. if (urlParams.has('tid')){
  850. team_id=urlParams.get("tid")
  851. }else{
  852. if(window.sport==="soccer"){
  853. team_id=GM_getValue("soccer_team_id")
  854. }else{
  855. team_id=GM_getValue("hockey_team_id")
  856. }
  857. }
  858.  
  859. let main_div=document.getElementById("infoAboutTeam")
  860. let dds = main_div.querySelectorAll('dd');
  861.  
  862. dds.forEach(dd => {
  863. let as = dd.querySelectorAll('a');
  864. if(as.length>0){
  865. let href = as[0].getAttribute('href');
  866. let urlParams = new URLSearchParams(href.split('?')[1]);
  867. let type = urlParams.get('type');
  868. if(type.includes("u23")){
  869. u23_type=window.cats[type]
  870. }
  871. if(type.includes("u21")){
  872. u21_type=window.cats[type]
  873. }
  874. if(type.includes("u18")){
  875. u18_type=window.cats[type]
  876. }
  877. }
  878. });
  879.  
  880.  
  881. GM_xmlhttpRequest({
  882. method: "GET",
  883. url: "https://statsxente.com/MZ1/Functions/tamper_detailed_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + "&idEquipo="+team_id,
  884. headers: {
  885. "Content-Type": "application/json"
  886. },
  887. onload: function (response) {
  888.  
  889. let jsonResponse = JSON.parse(response.responseText);
  890.  
  891. let aux=team_id
  892.  
  893. let top="TOP 11"
  894.  
  895. if(window.sport==="hockey"){
  896. top="TOP 21"
  897. }
  898.  
  899. let teamTable='<div style="display: flex;flex-direction: column;justify-content: center;align-items: center;flex-wrap: wrap;max-height: 100%;">'
  900. teamTable+='<table class="matchValuesTable"><thead><tr>'
  901. teamTable+='<th id=thTransparent0 style="background-color:transparent; border:0;"></th>'
  902. teamTable+='<th style="border-top-left-radius: 5px;">Value</th><th>LM Value</th>'
  903. teamTable+='<th >'+top+'</th><th>ELO</th>'
  904. teamTable+='<th>Age</th>'
  905. teamTable+='<th>Salary</th>'
  906. teamTable+='<th>Players</th>'
  907. teamTable+='<th style="border-top-right-radius: 5px;"></th>'
  908. teamTable+='</tr></thead><tbody>'
  909. let valor=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor']))
  910. let valorLM=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valorUPSenior']))
  911. let valor11=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor11']))
  912. let elo=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['elo']))
  913. let edad= Number.parseFloat(jsonResponse[aux]['edad']).toFixed(2)
  914. let salario=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['salario']))
  915. let numJugs=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['numJugadores']))
  916. teamTable+='<tr><th style="border-top-left-radius: 5px;">Senior</th><td>'+valor+'</td><td>'+valorLM+'</td><td>'+valor11+'</td><td>'+elo+'</td><td>'+edad+'</td><td>'+salario+'</td>'
  917. teamTable+='<td>'+numJugs+'</td>'
  918. teamTable+='<td style="border-right:1px solid '+GM_getValue("bg_native")+';">'
  919. teamTable+='<img alt="" style="cursor:pointer;" id="seniorButton" src="https://statsxente.com/MZ1/View/Images/detail.png" width="20px" height="20px"/>'
  920.  
  921. teamTable+='</td></tr>'
  922.  
  923. valor=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor23']))
  924. valorLM=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valorUPSUB23']))
  925. valor11=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor11_23']))
  926. elo=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['elo23']))
  927. edad=Number.parseFloat(jsonResponse[aux]['age23']).toFixed(2)
  928. salario=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['salary23']))
  929. numJugs=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['players23']))
  930. teamTable+='<tr><th>U23</th><td>'+valor+'</td><td>'+valorLM+'</td><td>'+valor11+'</td><td>'+elo+'</td><td>'+edad+'</td><td>'+salario+'</td>'
  931. teamTable+='<td>'+numJugs+'</td>'
  932. teamTable+='<td style="border-right:1px solid '+GM_getValue("bg_native")+';">'
  933. teamTable+='<img alt="" style="cursor:pointer;" id="sub23Button" src="https://statsxente.com/MZ1/View/Images/detail.png" width="20px" height="20px"/>'
  934. teamTable+='</td></tr>'
  935.  
  936.  
  937.  
  938. valor=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor21']))
  939. valorLM=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valorUPSUB21']))
  940. valor11=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor11_21']))
  941. elo=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['elo21']))
  942. edad=Number.parseFloat(jsonResponse[aux]['age21']).toFixed(2)
  943. salario=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['salary21']))
  944. numJugs=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['players21']))
  945. teamTable+='<tr><th>U21</th><td>'+valor+'</td><td>'+valorLM+'</td><td>'+valor11+'</td><td>'+elo+'</td><td>'+edad+'</td><td>'+salario+'</td>'
  946. teamTable+='<td>'+numJugs+'</td>'
  947. teamTable+='<td style="border-right:1px solid '+GM_getValue("bg_native")+';">'
  948. teamTable+='<img alt="" style="cursor:pointer;" id="sub21Button" src="https://statsxente.com/MZ1/View/Images/detail.png" width="20px" height="20px"/>'
  949. teamTable+='</td></tr>'
  950.  
  951.  
  952.  
  953.  
  954. valor=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor18']))
  955. valorLM=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valorUPSUB18']))
  956. valor11=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor11_18']))
  957. elo=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['elo18']))
  958. edad=Number.parseFloat(jsonResponse[aux]['age18']).toFixed(2)
  959. salario=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['salary18']))
  960. numJugs=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['players18']))
  961. teamTable+='<tr><th style="border-bottom-left-radius: 5px;">U18</th><td style="border-bottom:1px solid '+GM_getValue("bg_native")+';">'+valor+'</td>'
  962. teamTable+='<td style="border-bottom:1px solid '+GM_getValue("bg_native")+';">'+valorLM+'</td>'
  963. teamTable+='<td style="border-bottom:1px solid '+GM_getValue("bg_native")+';">'+valor11+'</td>'
  964. teamTable+='<td style="border-bottom:1px solid '+GM_getValue("bg_native")+';">'+elo+'</td><td style="border-bottom:1px solid '+GM_getValue("bg_native")+';">'+edad+'</td><td style="border-bottom:1px solid '+GM_getValue("bg_native")+';">'+salario+'</td>'
  965. teamTable+='<td style="border-bottom:1px solid '+GM_getValue("bg_native")+';">'+numJugs+'</td>'
  966. teamTable+='<td style="border-radius: 0 0 10px 0; border-bottom:1px solid '+GM_getValue("bg_native")+'; border-right:1px solid '+GM_getValue("bg_native")+';">'
  967. teamTable+='<img alt="" style="cursor:pointer;" id="sub18Button" src="https://statsxente.com/MZ1/View/Images/detail.png" width="20px" height="20px"/>'
  968. teamTable+='</td></tr>'
  969. teamTable+='</tbody></table>'
  970. teamTable+='<button class="btn-save" style="color:'+GM_getValue("color_native")+'; background-color:'+GM_getValue("bg_native")+'; font-family: \'Roboto\'; font-weight:bold; font-size:revert;" id="eloHistoryButton"><i class="bi bi-clock-history" style="font-style:normal;"> ELO History</i></button></div>'
  971.  
  972. let divToInserT=document.getElementById("streakAndCupInfo")
  973. divToInserT.innerHTML=teamTable+divToInserT.innerHTML
  974.  
  975. let color=GM_getValue("bg_native")
  976. let darkerColor = darkenColor(color, 25);
  977.  
  978. document.styleSheets[0].insertRule(
  979. '.btn-save:hover { background-color: '+darkerColor+' !important; }',
  980. document.styleSheets[0].cssRules.length
  981. );
  982.  
  983.  
  984. document.getElementById("eloHistoryButton").addEventListener('click', function () {
  985. let link = "https://statsxente.com/MZ1/Functions/graphLoader.php?graph=elo_history&team_id=" + team_id+"&sport=" + window.sport
  986. openWindow(link, 0.95, 1.25);
  987. });
  988.  
  989.  
  990.  
  991. document.getElementById("seniorButton").addEventListener('click', function () {
  992. let link = "https://www.statsxente.com/MZ1/Functions/tamper_teams_stats.php?team_id=" + team_id +
  993. "&category=senior&elo_category=SENIOR&sport=" + window.sport+ "&idioma=" + window.lang+"&team_name="
  994. +team_name+"&divisa=" + GM_getValue("currency")
  995. openWindow(link, 0.95, 1.25);
  996. });
  997. document.getElementById("sub23Button").addEventListener('click', function () {
  998. let link = "https://www.statsxente.com/MZ1/Functions/tamper_teams_stats.php?team_id=" + team_id +
  999. "&category="+u23_type+"&elo_category=U23&sport=" + window.sport+ "&idioma=" + window.lang+"&team_name="
  1000. +team_name+"&divisa=" + GM_getValue("currency")
  1001. openWindow(link, 0.95, 1.25);
  1002. });
  1003.  
  1004. document.getElementById("sub21Button").addEventListener('click', function () {
  1005. let link = "https://www.statsxente.com/MZ1/Functions/tamper_teams_stats.php?team_id=" + team_id +
  1006. "&category="+u21_type+"&elo_category=U21&sport=" + window.sport+ "&idioma=" + window.lang+"&team_name="
  1007. +team_name+"&divisa=" + GM_getValue("currency")
  1008. openWindow(link, 0.95, 1.25);
  1009. });
  1010.  
  1011.  
  1012. document.getElementById("sub18Button").addEventListener('click', function () {
  1013. let link = "https://www.statsxente.com/MZ1/Functions/tamper_teams_stats.php?team_id=" + team_id +
  1014. "&category="+u18_type+"&elo_category=U18&sport=" + window.sport+ "&idioma=" + window.lang+"&team_name="
  1015. +team_name+"&divisa=" + GM_getValue("currency")
  1016. openWindow(link, 0.95, 1.25);
  1017. });
  1018.  
  1019.  
  1020.  
  1021. const thElements = document.querySelectorAll('table.matchValuesTable th');
  1022. thElements.forEach(th => {
  1023. th.style.backgroundColor = GM_getValue("bg_native");
  1024. th.style.color = GM_getValue("color_native");
  1025. });
  1026. document.getElementById("thTransparent0").style.backgroundColor="transparent";
  1027. }
  1028. });
  1029. }
  1030. //Last matches page
  1031. function lastMatchesELO(){
  1032. let selectElements = document.getElementsByName('limit');
  1033. if (selectElements.length > 0) {
  1034. let selectElement = selectElements[0];
  1035. selectElement.addEventListener('change', function() {
  1036. if(GM_getValue("eloNextMatchesFlag")){
  1037. //waitToDOM(nextMatches, ".group", 0,7000)
  1038. }
  1039. if(GM_getValue("eloPlayedMatchesFlag")){
  1040. waitToDOM(lastMatchesELO, ".group", 0,7000)
  1041. }
  1042. });
  1043. }
  1044. selectElements = document.getElementsByName('selectType');
  1045. if (selectElements.length > 0) {
  1046. let selectElement = selectElements[0];
  1047. selectElement.addEventListener('change', function() {
  1048. if(GM_getValue("eloNextMatchesFlag")){
  1049. //waitToDOM(nextMatches, ".group", 0,7000)
  1050. }
  1051. if(GM_getValue("eloPlayedMatchesFlag")){
  1052. waitToDOM(lastMatchesELO, ".group", 0,7000)
  1053. }
  1054. });
  1055. }
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062. const today = new Date();
  1063.  
  1064. today.setDate(today.getDate() + 2);
  1065. const year = today.getFullYear();
  1066. const month = String(today.getMonth() + 1).padStart(2, '0');
  1067. const day = String(today.getDate()).padStart(2, '0');
  1068. let finalDate = `${year}-${month}-${day}`;
  1069.  
  1070. let initialDate="undefined"
  1071.  
  1072.  
  1073.  
  1074. let elems = document.getElementsByClassName("group");
  1075. Array.from(elems).forEach(function(elem) {
  1076. initialDate=getParsedValidDateText(elem.innerText)
  1077. });
  1078.  
  1079. getUsernameData()
  1080.  
  1081.  
  1082. let team_id
  1083. let urlParams = new URLSearchParams(window.location.search);
  1084. if (urlParams.has('tid')){
  1085. team_id=urlParams.get("tid")
  1086. }else{
  1087.  
  1088. if(window.sport==="soccer"){
  1089. team_id=GM_getValue("soccer_team_id")
  1090. }else{
  1091. team_id=GM_getValue("hockey_team_id")
  1092. }
  1093.  
  1094. }
  1095.  
  1096. let clase="loader-"+window.sport
  1097. elems = document.getElementsByClassName("bold score-cell-wrapper textCenter flex-grow-0");
  1098. Array.from(elems).forEach(function(elem) {
  1099. elem.innerHTML+="</br><div id='hp_loader' class='"+clase+"'></div>"
  1100.  
  1101. });
  1102.  
  1103. GM_xmlhttpRequest({
  1104. method: "GET",
  1105. url: "https://statsxente.com/MZ1/Functions/tamper_elo_matches.php?sport=" + window.sport + "&team_id="+team_id+"&initial_date="+initialDate+"&final_date="+finalDate,
  1106. headers: {
  1107. "Content-Type": "application/json"
  1108. },
  1109. onload: function (response) {
  1110. let jsonResponse = JSON.parse(response.responseText);
  1111.  
  1112.  
  1113.  
  1114.  
  1115. let elems = document.getElementsByClassName("bold score-cell-wrapper textCenter flex-grow-0");
  1116.  
  1117. Array.from(elems).forEach(function(elem) {
  1118.  
  1119. let links = elem.getElementsByClassName('score-hidden gray');
  1120. let href = links[0].getAttribute('href');
  1121. let urlParams = new URLSearchParams(href.split('?')[1]);
  1122. let mid = parseInt(urlParams.get('mid'));
  1123.  
  1124. if(mid in jsonResponse){
  1125.  
  1126. let diff=jsonResponse[mid]['score']-jsonResponse[mid]['old_score']
  1127. diff = diff.toFixed(2)
  1128.  
  1129. let symbol="";
  1130. let status="down";
  1131. if(diff>0){
  1132. symbol="+";
  1133. status="up";
  1134. }
  1135.  
  1136. elem.innerHTML+="<div id='showELOChange' style='display: flex;align-items: center;'>"+symbol+diff+"<img alt='' src='https://statsxente.com/MZ1/View/Images/"+status+".png' width='10px' height='10px'/></div>";
  1137. }
  1138.  
  1139.  
  1140. });
  1141.  
  1142. const elementos = document.querySelectorAll('.'+clase);
  1143. elementos.forEach(elemento => elemento.remove());
  1144.  
  1145. }
  1146.  
  1147.  
  1148.  
  1149. });
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156. }
  1157. //Federation clash page
  1158. function clash() {
  1159.  
  1160. let badges = document.getElementsByClassName("fed_badge");
  1161. let regex = /fid=(\d+)/;
  1162. let srcLocal = badges[0].getAttribute('src');
  1163. let local_id = srcLocal.match(regex);
  1164. let src_away = badges[1].getAttribute('src');
  1165. let away_id = src_away.match(regex);
  1166. let names = document.getElementsByClassName("name-score text-ellipsis")
  1167. let homeName=encodeURIComponent(names[0].innerText)
  1168. let awayName=encodeURIComponent(names[1].innerText)
  1169. let elems = document.getElementsByClassName("top-pane__deadline");
  1170. let tabla = elems[0]
  1171.  
  1172. GM_xmlhttpRequest({
  1173. method: "GET",
  1174. url: "https://statsxente.com/MZ1/Functions/tamper_federations_clash_data.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport +"&home="+local_id[1]+"&away="+away_id[1],
  1175. headers: {
  1176. "Content-Type": "application/json"
  1177. },
  1178. onload: function (response) {
  1179. let jsonResponse = JSON.parse(response.responseText);
  1180.  
  1181.  
  1182.  
  1183. let contenidoNuevo = "</br></br><table style='margin: 0 auto;'><tr><td class='subheader clearfix'>Clash Compare</td></tr><tr><td><img alt='' id=clashCompare src='https://www.statsxente.com/MZ1/View/Images/clash_icon.png' style='width:45px; height:45px; cursor:pointer;'/></center></td></tr></table></center>";
  1184. contenidoNuevo+="<table style='width:65%;margin: 0 auto; table-layout:unset;' class='hitlist challenges-list'><thead><tr>"
  1185. contenidoNuevo+="<th colspan='2'>Rank</th><th>Value</th><th>LM Value</th><th>ELO Score</th></tr></thead>"
  1186. contenidoNuevo+="<tbody>"
  1187.  
  1188. contenidoNuevo+="<tr class='odd'>"
  1189.  
  1190. contenidoNuevo+="<td style='text-align:right;'><img alt='' src='https://www.managerzone.com/dynimg/pic.php?type=federation&fid="+local_id[1]+"&size=medium&sport="+window.sport+"' width=35px height=35px/></td>"
  1191. contenidoNuevo+="<td style='text-align:left;'>#"+jsonResponse[local_id[1]]["table_index"]+"</td>"
  1192.  
  1193. let valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[local_id[1]]["value"]))
  1194. contenidoNuevo+="<td style='margin: 0 auto;'>"+valor+"</td>"
  1195. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[local_id[1]]["valueLM"]))
  1196. contenidoNuevo+="<td style='margin: 0 auto;'>"+valor+"</td>"
  1197. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[local_id[1]]["elo"]))
  1198. contenidoNuevo+="<td style='margin: 0 auto;'>"+valor+"</td>"
  1199.  
  1200. contenidoNuevo+="</tr>"
  1201.  
  1202. contenidoNuevo+="<tr class='even'>"
  1203. contenidoNuevo+="<td style='text-align:right;'><img alt='' src='https://www.managerzone.com/dynimg/pic.php?type=federation&fid="+away_id[1]+"&size=medium&sport="+window.sport+"' width=35px height=35px/></td>"
  1204. contenidoNuevo+="<td style='text-align:left;'>#"+jsonResponse[away_id[1]]["table_index"]+"</td>"
  1205.  
  1206.  
  1207. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[away_id[1]]["value"]))
  1208. contenidoNuevo+="<td style='margin: 0 auto;'>"+valor+"</td>"
  1209. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[away_id[1]]["valueLM"]))
  1210. contenidoNuevo+="<td style='margin: 0 auto;'>"+valor+"</td>"
  1211. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[away_id[1]]["elo"]))
  1212. contenidoNuevo+="<td style='margin: 0 auto;'>"+valor+"</td>"
  1213.  
  1214. contenidoNuevo+="</tr>"
  1215.  
  1216. contenidoNuevo+="</tbody>"
  1217. contenidoNuevo+="</table></center>"
  1218. tabla.insertAdjacentHTML('beforeend', contenidoNuevo)
  1219.  
  1220. document.getElementById("clashCompare").addEventListener('click', function () {
  1221. let link = "https://statsxente.com/MZ1/Functions/loadClashFederationData.php?tamper=yes&fid=" + local_id[1] + "&fid1=" + away_id[1] + "&fede=" + homeName + "&fede1=" + awayName + "&idioma=" + window.lang + "&divisa=" + GM_getValue("currency") + "&sport=" + window.sport;
  1222. openWindow(link, 0.95, 1.25);
  1223. });
  1224.  
  1225. names[0].innerText="(#"+jsonResponse[local_id[1]]["table_index"]+")"+names[0].innerText;
  1226. names[1].innerText="(#"+jsonResponse[away_id[1]]["table_index"]+")"+names[1].innerText;
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247. let tables = document.querySelectorAll('.hitlist');
  1248. let table=tables[1]
  1249. if(window.stx_device==="computer"){
  1250. const thead = table.querySelector("thead");
  1251. if (thead.children.length === 0) {
  1252. const th1 = document.createElement("th");
  1253. th1.innerText = "Equipo";
  1254. const th2 = document.createElement("th");
  1255. th2.innerText = "Resultado";
  1256. const nuevaFila = document.createElement("tr");
  1257. nuevaFila.appendChild(th1);
  1258. nuevaFila.appendChild(th2);
  1259. thead.appendChild(nuevaFila);
  1260. }
  1261.  
  1262. }
  1263.  
  1264.  
  1265.  
  1266.  
  1267. const colCount = table.rows[0].cells.length;
  1268.  
  1269. let eloCol=0
  1270. let lmCol=1
  1271. if(colCount>2){
  1272.  
  1273. eloCol=5
  1274. lmCol=6
  1275.  
  1276. }
  1277.  
  1278.  
  1279. table.id="clash_table";
  1280.  
  1281.  
  1282. let contIds = 0
  1283. let linkIds = ""
  1284. let teamNameElement=""
  1285.  
  1286. let index_init=0
  1287. if(window.stx_device==="computer"){
  1288. index_init=1
  1289. }
  1290.  
  1291.  
  1292. for (let i = index_init; i < table.rows.length; i++) {
  1293. let row = table.rows[i];
  1294. if(window.stx_device==="computer"){
  1295. let thirdColumnCell = row.cells[eloCol];
  1296. teamNameElement = thirdColumnCell.querySelector('.team-name');
  1297. let href = teamNameElement.getAttribute('href');
  1298. let urlParams = new URLSearchParams(href.split('?')[1]);
  1299. let tid = urlParams.get('tid');
  1300. linkIds += "&idEquipo" + contIds + "=" + tid
  1301. contIds++
  1302.  
  1303. }else{
  1304. let flexs_elements = row.querySelector('.flex-grow-1');
  1305. if(flexs_elements){
  1306. let as=flexs_elements.getElementsByTagName("a")
  1307. let team_data=extractTeamData(as)
  1308.  
  1309.  
  1310. linkIds += "&idEquipo" + contIds + "=" + team_data[0]
  1311. contIds++
  1312.  
  1313.  
  1314. }
  1315.  
  1316. }
  1317.  
  1318. }
  1319.  
  1320. GM_xmlhttpRequest({
  1321. method: "GET",
  1322. url: "https://statsxente.com/MZ1/Functions/tamper_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + linkIds,
  1323. headers: {
  1324. "Content-Type": "application/json"
  1325. },
  1326. onload: function (response) {
  1327. let jsonResponse = JSON.parse(response.responseText);
  1328.  
  1329.  
  1330. let valor=0
  1331. let tid=0
  1332. if(window.stx_device==="computer"){
  1333. for (let i = 0; i < table.rows.length; i++) {
  1334. let row = table.rows[i];
  1335.  
  1336.  
  1337. if(i>0){
  1338.  
  1339. let thirdColumnCell = row.cells[eloCol];
  1340. let teamNameElement = thirdColumnCell.querySelector('.team-name');
  1341. let href = teamNameElement.getAttribute('href');
  1342. let urlParams = new URLSearchParams(href.split('?')[1]);
  1343. tid = urlParams.get('tid');
  1344.  
  1345.  
  1346. }
  1347.  
  1348.  
  1349. let newCell1 = row.insertCell(eloCol);
  1350. if (i === 0) {
  1351.  
  1352. let th = document.createElement('th');
  1353. th.innerHTML = "ELO";
  1354. th.style.width="50px";
  1355. th.id="elo_th"
  1356. newCell1.replaceWith(th);
  1357.  
  1358. } else {
  1359. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[tid]["elo"]))
  1360. newCell1.innerHTML = valor;
  1361. }
  1362.  
  1363. let newCell = row.insertCell(lmCol);
  1364. if (i === 0) {
  1365.  
  1366. let th1 = document.createElement('th');
  1367. th1.innerHTML = "LM Value";
  1368. th1.style.width="80px";
  1369. th1.id="lm_th"
  1370. newCell.replaceWith(th1);
  1371. } else {
  1372. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[tid]["valorUPSenior"]))
  1373. newCell.innerHTML = valor;
  1374. }
  1375.  
  1376.  
  1377. if(eloCol===0){
  1378. let rankCell = row.insertCell(eloCol);
  1379.  
  1380. if (i === 0) {
  1381.  
  1382.  
  1383. let th2 = document.createElement('th'); // Creamos un elemento 'th'
  1384. th2.innerHTML = "Rank";
  1385. th2.style.width="50px";
  1386. rankCell.replaceWith(th2);
  1387.  
  1388.  
  1389. }else{
  1390. rankCell.innerHTML = i
  1391.  
  1392. }
  1393. }
  1394.  
  1395.  
  1396.  
  1397. }
  1398.  
  1399.  
  1400. if(eloCol===0){
  1401. eloCol++;
  1402. lmCol++;
  1403. }
  1404.  
  1405. document.getElementById("elo_th").addEventListener("click", function () {
  1406.  
  1407. ordenarTabla(eloCol, false, "clash_table",true);
  1408. });
  1409.  
  1410.  
  1411. document.getElementById("lm_th").addEventListener("click", function () {
  1412.  
  1413. ordenarTabla(lmCol, false, "clash_table",true);
  1414. });
  1415.  
  1416.  
  1417. }else{
  1418.  
  1419. //MOBILE VIEW
  1420.  
  1421. for (let i = 0; i < table.rows.length; i++) {
  1422. let row = table.rows[i];
  1423.  
  1424.  
  1425. let flexs_elements = row.querySelector('.flex-grow-1');
  1426. if(flexs_elements){
  1427. let as=flexs_elements.getElementsByTagName("a")
  1428. let team_data=extractTeamData(as)
  1429. let valor = new Intl.NumberFormat(window.userLocal).format(Number.parseFloat(jsonResponse[team_data[0]]["valorUPSenior"]).toFixed(0))
  1430. let elo = new Intl.NumberFormat(window.userLocal).format(Number.parseFloat(jsonResponse[team_data[0]]["elo"]).toFixed(0))
  1431. let txt="<table><tr><td>LM Value</td><td>"+valor+"</td></tr><tr><td>ELO</td><td>"+elo+"</td></tr></table>"
  1432.  
  1433.  
  1434. flexs_elements.innerHTML+=txt
  1435. }
  1436.  
  1437.  
  1438. }
  1439.  
  1440. }
  1441.  
  1442. }
  1443.  
  1444.  
  1445.  
  1446. });
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452. }
  1453.  
  1454. });
  1455.  
  1456.  
  1457. }
  1458. //Leagues page
  1459. function leagues() {
  1460. let urlParams = new URLSearchParams(window.location.search);
  1461. let initialValues = {};
  1462. initialValues["senior"] = GM_getValue("league_default_senior");
  1463. initialValues["world"] = GM_getValue("league_default_senior");
  1464. initialValues["u23"] = GM_getValue("league_default_u23");
  1465. initialValues["u21"] = GM_getValue("league_default_u21");
  1466. initialValues["u18"] = GM_getValue("league_default_u18");
  1467. initialValues["u23_world"] = GM_getValue("league_default_u23");
  1468. initialValues["u21_world"] = GM_getValue("league_default_u21");
  1469. initialValues["u18_world"] = GM_getValue("league_default_u18");
  1470.  
  1471. let linkIds = ""
  1472. let elems = document.getElementsByClassName("nice_table");
  1473. let tabla = elems[0]
  1474. let thSegundo = tabla.querySelector("thead th:nth-child(2)");
  1475. thSegundo.style.width = "250px";
  1476.  
  1477.  
  1478. let values = new Map();
  1479. values.set('valor23', 'U23 Value');
  1480. values.set('valor21', 'U21 Value');
  1481. values.set('valor18', 'U18 Value');
  1482. values.set('salario', 'Salary');
  1483. values.set('valorUPSenior', 'LM Value');
  1484. values.set('valorUPSUB23', 'U23 LM Value');
  1485. values.set('valorUPSUB21', 'U21 LM Value');
  1486. values.set('valorUPSUB18', 'U18 LM Value');
  1487. values.set('edad', 'Age');
  1488. if (window.sport === "soccer") {
  1489. values.set('valor11', 'TOP 11');
  1490. values.set('valor11_23', 'U23 TOP 11');
  1491. values.set('valor11_21', 'U21 TOP 11');
  1492. values.set('valor11_18', 'U18 TOP 11');
  1493. } else {
  1494. values.set('valor11', 'TOP 21');
  1495. values.set('valor11_23', 'U23 TOP 21');
  1496. values.set('valor11_21', 'U21 TOP 21');
  1497. values.set('valor11_18', 'U18 TOP 21');
  1498. }
  1499.  
  1500. values.set('noNac', 'Foreigners');
  1501. values.set('elo', 'ELO Score');
  1502. values.set('elo23', 'U23 ELO Score');
  1503. values.set('elo21', 'U21 ELO Score');
  1504. values.set('elo18', 'U18 ELO Score');
  1505. values.set('numJugadores', 'Number of players');
  1506.  
  1507. if (urlParams.get('type') === "senior") {
  1508. values.set('leagues', 'Leagues');
  1509. values.set('world_leagues_all', 'World Leagues');
  1510. values.set('youth_leagues_all', 'Youth Leagues');
  1511. values.set('world_youth_leagues_all', 'Youth World Leagues');
  1512. values.set('federation_leagues', 'Federation Leagues');
  1513. }
  1514.  
  1515.  
  1516. if (urlParams.get('type') === "world") {
  1517. values.set('leagues_all', 'Leagues');
  1518. values.set('world_leagues', 'World Leagues');
  1519. values.set('youth_leagues_all', 'Youth Leagues');
  1520. values.set('world_youth_leagues_all', 'Youth World Leagues');
  1521. values.set('federation_leagues', 'Federation Leagues');
  1522. }
  1523.  
  1524.  
  1525. if ((urlParams.get('type').includes("u")) && (!urlParams.get('type').includes("_"))) {
  1526. let actual_cat = urlParams.get('type').toUpperCase();
  1527. GM_setValue("actual_league_cat", actual_cat)
  1528. values.set('leagues_all', 'Leagues');
  1529. values.set('world_leagues_all', 'World Leagues');
  1530. values.set('youth_leagues', actual_cat + ' Youth Leagues');
  1531. values.set('world_youth_leagues_all', 'Youth World Leagues');
  1532. values.set('federation_leagues', 'Federation Leagues');
  1533. }
  1534.  
  1535.  
  1536. if ((urlParams.get('type').includes("u")) && (urlParams.get('type').includes("_"))) {
  1537. let actual_cat = urlParams.get('type').substring(0, 3).toUpperCase();
  1538. GM_setValue("actual_league_cat", actual_cat)
  1539. values.set('leagues_all', 'Leagues');
  1540. values.set('world_leagues_all', 'World Leagues');
  1541. values.set('youth_leagues_all', 'Youth Leagues');
  1542. values.set('world_youth_leagues', actual_cat + ' Youth World Leagues');
  1543. values.set('federation_leagues', 'Federation Leagues');
  1544. }
  1545. values.set('cup', 'Cups');
  1546. values.set('cup_u23', 'U23 Cups');
  1547. values.set('cup_u21', 'U21 Cups');
  1548. values.set('cup_u18', 'U18 Cups');
  1549. values.set('special_cup', 'Special Cups');
  1550.  
  1551. let contenidoNuevo = '<div id=testClick style="margin: 0 auto;">';
  1552.  
  1553.  
  1554. getNativeTableStyles();
  1555.  
  1556. let idProgress = "noProgress";
  1557. if (urlParams.get('type') === "senior") {
  1558. idProgress = "divProgress"
  1559. }
  1560.  
  1561.  
  1562. let widthTable = "1.5em"
  1563. ///MENU TABLE
  1564. contenidoNuevo += "<table id=showMenu style='margin: 0 auto;'><thead style='margin: 0 auto; background-color:" + GM_getValue("bg_native") + "; color:" + GM_getValue("color_native") + ";'><tr>";
  1565. contenidoNuevo += '<th style="text-align:center; margin: 0 auto; padding:4px;">Stats</th>'
  1566. contenidoNuevo +='<th style="text-align:center; margin: 0 auto; padding:4px;">Graph</th>';
  1567. contenidoNuevo += "<th style='text-align:center; margin: 0 auto; padding:4px;'>History</th>";
  1568. contenidoNuevo += "<th style='text-align:center; margin: 0 auto; padding:4px;'>Top Players</th></tr></thead>";
  1569. contenidoNuevo += "<tr>";
  1570. contenidoNuevo += "<td style='margin: 0 auto; text-align:center; padding:4px; max-width: " + widthTable + "; width:" + widthTable + ";'><img alt='' id='detailDivision' style='cursor:pointer;' src=https://statsxente.com/MZ1/View/Images/detail.png width=25 height=25/></td>";
  1571. contenidoNuevo += "<td style='margin: 0 auto; text-align:center; padding:4px; max-width:" + widthTable + "; width:" + widthTable + ";'><img alt='' id='graphDivision' style='cursor:pointer;' src=https://statsxente.com/MZ1/View/Images/report.png width=31 height=25/></td>";
  1572. if (idProgress === "noProgress") {
  1573. contenidoNuevo += "<td style='margin: 0 auto; text-align:center; padding:4px; max-width: " + widthTable + "; width: " + widthTable + ";'><img alt='' id='" + idProgress + "' style='cursor:pointer;' src=https://statsxente.com/MZ1/View/Images/graph_disabled.png width=25 height=25/></td>";
  1574. } else {
  1575. contenidoNuevo += "<td style='margin: 0 auto; text-align:center; padding:4px; max-width: " + widthTable + "; width: " + widthTable + ";'><img alt='' id='" + idProgress + "' style='cursor:pointer;' src=https://statsxente.com/MZ1/View/Images/graph.png width=25 height=25/></td>";
  1576. }
  1577. contenidoNuevo += "<td style='margin: 0 auto; text-align:center; padding:4px; max-width: " + widthTable + "; width: " + widthTable + ";'><img alt='' id='topPlayersDivision' style='cursor:pointer;' src=https://statsxente.com/MZ1/View/Images/top-10.png width=25 height=25/></td>";
  1578. contenidoNuevo += "</tr>";
  1579.  
  1580. let styleTable = " style='margin: 0 auto; display:none;'";
  1581. let styleIcon = ""
  1582. let styleSep = "style='padding-top:5px;'";
  1583.  
  1584. if (GM_getValue("show_league_selects") === true) {
  1585. styleTable = " style='margin: 0 auto;'";
  1586. styleIcon = " active"
  1587. styleSep = " style='display:none;'";
  1588. }
  1589.  
  1590.  
  1591. contenidoNuevo += "<tr><td></td><td colspan='2'>";
  1592. contenidoNuevo += '<div id="moreInfo" class="expandable-icon' + styleIcon + '" style="margin: 0 auto; cursor:pointer; background-color:' + GM_getValue("bg_native") + ';"><div id="line1" class="line"></div><div id="line2" class="line"></div></div></center>';
  1593. contenidoNuevo += "</td><td></td></tr>";
  1594. contenidoNuevo += "<tr><td colspan='5' id='separatorTd'" + styleSep + "></td></tr>";
  1595. contenidoNuevo += "</table></center>";
  1596. contenidoNuevo += '<table id=show3' + styleTable + '><tr><td><label>';
  1597.  
  1598. if ((urlParams.get('type') === 'senior') || (urlParams.get('type') === 'world')) {
  1599. if ("valor" === initialValues[urlParams.get('type')]) {
  1600. contenidoNuevo += '<input class="statsxente" type="checkbox" checked id="valor" value="Value">Value</label></td>';
  1601. } else {
  1602. contenidoNuevo += '<input class="statsxente" type="checkbox" id="valor" value="Value">Value</label></td>';
  1603. }
  1604. } else {
  1605. contenidoNuevo += '<input class="statsxente" type="checkbox" id="valor" value="Value">Value</label></td>';
  1606. }
  1607.  
  1608. values.forEach(function (valor, clave) {
  1609.  
  1610. if (clave === "valorUPSenior") {
  1611. contenidoNuevo += "</tr><tr>";
  1612. }
  1613.  
  1614. if (clave === "valor11") {
  1615. contenidoNuevo += "</tr><tr>";
  1616. }
  1617. if (clave === "elo") {
  1618. contenidoNuevo += "</tr><tr>";
  1619. }
  1620.  
  1621. if (clave === "leagues") {
  1622. contenidoNuevo += "</tr><tr>";
  1623. }
  1624.  
  1625. if (clave === "leagues_all") {
  1626. contenidoNuevo += "</tr><tr>";
  1627. }
  1628.  
  1629. if (clave === "cup") {
  1630. contenidoNuevo += "</tr><tr>";
  1631. }
  1632.  
  1633. if (clave === initialValues[urlParams.get('type')]) {
  1634. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" checked value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  1635. } else {
  1636. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  1637. }
  1638. });
  1639.  
  1640. let cats_elo = {}
  1641. cats_elo["senior"] = "SENIOR";
  1642. cats_elo["world"] = "SENIOR";
  1643. cats_elo["u23"] = "U23";
  1644. cats_elo["u21"] = "U21";
  1645. cats_elo["u18"] = "U18";
  1646. cats_elo["u23_world"] = "U23";
  1647. cats_elo["u21_world"] = "U21";
  1648. cats_elo["u18_world"] = "U18";
  1649.  
  1650.  
  1651. let cats_temp=["SENIOR","U23","U21","U18"];
  1652. contenidoNuevo += "</tr>"
  1653. contenidoNuevo +="<tr style='margin: 0 auto; text-align: center;'>"
  1654. contenidoNuevo += '<td colspan="5"><label><input class="statsxente" type="checkbox" value="ELOCompare" id="ELOCompare">ELO Compare</label></td>';
  1655. contenidoNuevo +="</tr>"
  1656. contenidoNuevo +='<tr style="margin: 0 auto; text-align: center; display:none;" id="trELOCompare"><td colspan="5">Category: '
  1657. contenidoNuevo+='<select id="catSelect" style="background-color: '+GM_getValue("bg_native")+'; padding: 6px 3px; border-radius: 3px; width: 9em; border-color: white; color: '+GM_getValue("color_native")
  1658. contenidoNuevo+='; font-family: Roboto; font-weight: bold; font-size: revert;">'
  1659. for (let i = 0; i < cats_temp.length; i++) {
  1660. let tmp=""
  1661. if(cats_elo[urlParams.get('type')]===cats_temp[i]){
  1662. tmp="selected"
  1663. }
  1664. contenidoNuevo+="<option value='"+cats_temp[i]+"' "+tmp+">"+cats_temp[i]+"</option>"
  1665. }
  1666. contenidoNuevo +='</select> <button class="btn-save" style="color:'+GM_getValue("color_native")+'; background-color:'+GM_getValue("bg_native")+'; font-family: \'Roboto\'; font-weight:bold; font-size:revert;" id="eloCompareButton"><i class="bi bi-graph-up" style="font-style:normal;"> ELO Compare</i></button></td></tr>'
  1667. contenidoNuevo +="</table></center>"
  1668. contenidoNuevo += "</div></br>";
  1669. values.set('valor', 'Value');
  1670. let color=GM_getValue("bg_native")
  1671. let darkerColor = darkenColor(color, 25);
  1672. document.styleSheets[0].insertRule(
  1673. '.btn-save:hover { background-color: '+darkerColor+' !important; }',
  1674. document.styleSheets[0].cssRules.length
  1675. );
  1676.  
  1677. elems = document.getElementsByClassName("nice_table");
  1678. tabla = elems[0]
  1679. tabla.insertAdjacentHTML('beforebegin', contenidoNuevo);
  1680.  
  1681. document.getElementById("eloCompareButton").style.padding = "5px 3px";
  1682. document.getElementById("eloCompareButton").style.width = "9em";
  1683.  
  1684. document.getElementById("eloCompareButton").addEventListener('click', function () {
  1685. let elems = document.getElementsByClassName("nice_table");
  1686. let tabla = elems[0]
  1687. let link="https://statsxente.com/MZ1/Functions/graphLoader.php?graph=elo_compare&lang="+window.lang+"&category="+document.getElementById("catSelect").value+"&sport="+window.sport
  1688. let cont=0
  1689. for (let i = 0; i < tabla.rows.length; i++) {
  1690. let fila = tabla.rows[i];
  1691. if (fila.cells.length > 1) {
  1692. let checkboxes = fila.cells[1].querySelectorAll("input[type='checkbox']");
  1693. checkboxes.forEach(function(checkbox) {
  1694. if(checkbox.checked){
  1695. if(cont<5){
  1696. link+="&team_name"+cont+"="+encodeURIComponent(checkbox.value)+"&team_id"+cont+"="+checkbox.id
  1697. cont++;
  1698. }
  1699. }
  1700. });
  1701. }
  1702. }
  1703. openWindow(link, 0.95, 1.25);
  1704. });
  1705. document.getElementById("ELOCompare").addEventListener('click', function () {
  1706. let checkboxes = document.querySelectorAll('.statsxente');
  1707. checkboxes.forEach(function (checkbox) {
  1708. if (checkbox.id !== "ELOCompare") {
  1709. checkbox.checked = false;
  1710. }
  1711. });
  1712. if(!document.getElementById("eloCompareCol")){
  1713. let elems = document.getElementsByClassName("nice_table");
  1714. let tabla = elems[0]
  1715. for (let fila of tabla.rows) {
  1716. const nuevaCelda = fila.rowIndex === 0 ? document.createElement('th') : document.createElement('td');
  1717. if(fila.rowIndex>0){
  1718. let team_data=extractTeamData(fila.cells[1].getElementsByTagName('a'))
  1719. nuevaCelda.innerHTML = '<input class="statsxente1" type="checkbox" value="'+team_data[1]+'" id="'+team_data[0]+'">';
  1720. }
  1721.  
  1722. fila.insertBefore(nuevaCelda, fila.cells[1]);
  1723. if(fila.rowIndex===0){
  1724. fila.cells[1].id="eloCompareCol"
  1725. fila.cells[2].style.width="175px"
  1726. }
  1727. }
  1728. }else{
  1729. let elems = document.getElementsByClassName("nice_table");
  1730. let table = elems[0]
  1731. let th = document.getElementById("eloCompareCol");
  1732. let columnIndex = th.cellIndex;
  1733. for (let i = 0; i < table.rows.length; i++) {
  1734. let row = table.rows[i];
  1735. let cell = row.cells[columnIndex];
  1736. if (cell.style.display === 'none') {
  1737. cell.style.display = '';
  1738. th.style.fontWeight = 'normal';
  1739. } else {
  1740. cell.style.display = 'none';
  1741. th.style.fontWeight = 'bold';
  1742. }
  1743. }
  1744. }
  1745.  
  1746. if(document.getElementById("trELOCompare").style.display==="none"){
  1747. document.getElementById("trELOCompare").style.display="table-row";
  1748.  
  1749. }else{
  1750. document.getElementById("trELOCompare").style.display="none";
  1751. }
  1752.  
  1753. });
  1754.  
  1755. if (GM_getValue("show_league_selects") === true) {
  1756. document.getElementById("line2").style.transform = 'rotateZ(0deg)';
  1757. document.getElementById("line1").style.transform = 'rotateZ(180deg)';
  1758. document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
  1759. }
  1760.  
  1761. values.forEach(function (valor, clave) {
  1762. let elemento = document.getElementById(clave);
  1763. elemento.addEventListener('click', handleClick);
  1764. });
  1765.  
  1766. let nuevaCeldaEncabezado = document.createElement("th");
  1767. nuevaCeldaEncabezado.textContent = values.get(initialValues[urlParams.get('type')]);
  1768. nuevaCeldaEncabezado.style.textAlign = 'center';
  1769. nuevaCeldaEncabezado.style.maxWidth = '6.5em';
  1770. nuevaCeldaEncabezado.style.width = '6.5em';
  1771. nuevaCeldaEncabezado.style.whiteSpace = 'nowrap';
  1772. nuevaCeldaEncabezado.style.overflow = 'hidden';
  1773. nuevaCeldaEncabezado.style.textOverflow = 'ellipsis';
  1774. document.getElementsByClassName("seriesHeader")[0].appendChild(nuevaCeldaEncabezado);
  1775.  
  1776. nuevaCeldaEncabezado = document.createElement("th");
  1777. nuevaCeldaEncabezado.textContent = "Stats Xente";
  1778. nuevaCeldaEncabezado.style.textAlign = 'center';
  1779. document.getElementsByClassName("seriesHeader")[0].appendChild(nuevaCeldaEncabezado);
  1780.  
  1781.  
  1782. if (tabla.getElementsByTagName("tbody")[0].innerHTML.includes("mazyar")) {
  1783. searchClassName = "responsive-hide"
  1784. }
  1785.  
  1786. let contIds = 0
  1787. let filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  1788. for (let i = 0; i < filasDatos.length; i++) {
  1789. if (checkClassNameExists(tabla.rows[i + 1], searchClassName)) {
  1790. let celda = tabla.rows[i + 1].cells[1];
  1791. let team_data=extractTeamData(celda.getElementsByTagName("a"));
  1792. let id=team_data[0]
  1793. let equipo=team_data[1]
  1794. linkIds += "&idEquipo" + contIds + "=" + id
  1795. contIds++
  1796. celda.innerHTML += "<input type='hidden' id='team_" + id + "' value='" + equipo + "'/>"
  1797. }
  1798.  
  1799. }
  1800. let cat = cats[urlParams.get('type')]
  1801. let enlace = document.getElementById('league_tab_schedule');
  1802. let href = enlace.href;
  1803. let url = new URL(href);
  1804. let league_id = url.searchParams.get('sid');
  1805.  
  1806.  
  1807.  
  1808. ///DIV PROGRESS
  1809. setTimeout(function () {
  1810.  
  1811.  
  1812. if (idProgress !== "noProgress") {
  1813. (function (currentId, currentLSport, lang) {
  1814. document.getElementById("divProgress").addEventListener('click', function () {
  1815.  
  1816. let link = "https://statsxente.com/MZ1/Graficos/graficoProgresoDivision.php?idLiga=" + currentId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") + "&deporte=" + currentLSport;
  1817. openWindow(link, 0.95, 1.25);
  1818. });
  1819. })(league_id, window.lsport, window.lang);
  1820.  
  1821. }
  1822.  
  1823.  
  1824. (function () {
  1825. document.getElementById("moreInfo").addEventListener('click', function () {
  1826. document.getElementById("moreInfo").classList.toggle('active');
  1827.  
  1828. if (document.getElementById("moreInfo").classList.contains("active")) {
  1829. document.getElementById("line2").style.transform = 'rotateZ(0deg)';
  1830. document.getElementById("line1").style.transform = 'rotateZ(180deg)';
  1831. document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
  1832. $('#separatorTd').fadeOut(1);
  1833. document.getElementById("separatorTd").style.paddingTop = "5px";
  1834. $('#show3').fadeIn('slow');
  1835. } else {
  1836. document.getElementById("line2").style.transform = 'rotateZ(45deg)';
  1837. document.getElementById("line1").style.transform = 'rotateZ(-45deg)';
  1838. document.getElementById("moreInfo").style.transform = 'rotateZ(45deg)';
  1839. $('#separatorTd').fadeIn(1);
  1840. $('#show3').fadeOut('slow');
  1841. }
  1842.  
  1843.  
  1844.  
  1845. });
  1846. })();
  1847.  
  1848. (function (currentId, currentLSport, lang, currentCat) {
  1849. document.getElementById("detailDivision").addEventListener('click', function () {
  1850. let url_ = "https://statsxente.com/MZ1/Functions/lecturaStatsDivisionesHistorico2.0.php"
  1851. if (window.sport === "hockey") {
  1852. url_ = "https://statsxente.com/MZ1/Functions/lecturaStatsDivisionesHockeyHistorico.php"
  1853. }
  1854.  
  1855. let link = url_ + "?tamper=yes&modal=yes&idLiga=" + currentId + "&idioma=" + lang + "&categoria=" + currentCat + "&season=75&season_actual=75";
  1856. openWindow(link, 0.95, 1.25);
  1857. });
  1858. })(league_id, window.lsport, window.lang, cat);
  1859.  
  1860. (function (currentId, sport, lang) {
  1861. document.getElementById("topPlayersDivision").addEventListener('click', function () {
  1862. let url_ = "https://statsxente.com/MZ1/Functions/tamper_top_players_division.php"
  1863. if (window.sport === "hockey") {
  1864. url_ = "https://statsxente.com/MZ1/Functions/tamper_top_players_division_hockey.php"
  1865. }
  1866. let link = url_ + "?league_id=" + currentId + "&sport=" + sport + "&category=" + cat + "&idioma=" + lang;
  1867. openWindow(link, 0.95, 1.25);
  1868. });
  1869. })(league_id, window.sport, window.lang, cat);
  1870.  
  1871. (function (currentId, currentLSport, lang, currentCat) {
  1872. document.getElementById("graphDivision").addEventListener('click', function () {
  1873. let url_sport = ""
  1874. if (window.sport === "hockey") {
  1875. url_sport = "Hockey"
  1876. }
  1877. let link = "https://statsxente.com/MZ1/View/filtroGraficoLinealDivisiones" + url_sport + ".php?tamper=yes&idLiga=" + currentId + "&idioma=" + lang + "&categoria=" + currentCat + "&season=75&season_actual=75&modal=yes&valor=nota";
  1878. openWindow(link, 0.95, 1.25);
  1879. });
  1880. })(league_id, window.lsport, window.lang, cat);
  1881.  
  1882.  
  1883. }, 200);
  1884.  
  1885. GM_xmlhttpRequest({
  1886. method: "GET",
  1887. url: "https://statsxente.com/MZ1/Functions/tamper_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + linkIds,
  1888. headers: {
  1889. "Content-Type": "application/json"
  1890. },
  1891. onload: function (response) {
  1892. let cat = window.cats[urlParams.get('type')]
  1893. let jsonResponse = JSON.parse(response.responseText);
  1894. teams_data = jsonResponse;
  1895. let filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  1896. for (let i = 0; i < filasDatos.length; i++) {
  1897. if (checkClassNameExists(filasDatos[i], searchClassName)) {
  1898. let celda = filasDatos[i].cells[1];
  1899. let team_data=extractTeamData(celda.getElementsByTagName("a"));
  1900. let id=team_data[0]
  1901. let equipo=team_data[1]
  1902.  
  1903. let nuevaColumna = document.createElement("td");
  1904. let valor = 0;
  1905. if (jsonResponse[id] && jsonResponse[id][initialValues[urlParams.get('type')]] !== undefined) {
  1906. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[id][initialValues[urlParams.get('type')]]))
  1907. }
  1908. nuevaColumna.innerHTML = valor
  1909. nuevaColumna.style.textAlign = 'center';
  1910. filasDatos[i].appendChild(nuevaColumna);
  1911.  
  1912. let eloType = 1
  1913.  
  1914. if (window.sport === "soccer") { eloType = 2 }
  1915. if (cat.includes("SUB")) { eloType = 3 }
  1916.  
  1917.  
  1918. let flagSenior = 0, flagSub23 = 0, flagSub21 = 0, flagSub18 = 0;
  1919. if (jsonResponse[id]["elo"] > 0) { flagSenior = 1 }
  1920. if (jsonResponse[id]["elo23"] > 0) { flagSub23 = 1 }
  1921. if (jsonResponse[id]["elo21"] > 0) { flagSub21 = 1 }
  1922. if (jsonResponse[id]["elo18"] > 0) { flagSub18 = 1 }
  1923.  
  1924. let buttonDisplay = "display:block;";
  1925. nuevaColumna = document.createElement("td");
  1926. nuevaColumna.style.margin = '0 auto';
  1927. nuevaColumna.style.textAlign = 'center';
  1928. let iner = "<img alt='' src='https://statsxente.com/MZ1/View/Images/detail.png' width='" + GM_getValue("league_image_size") + "px' height='" + GM_getValue("league_image_size") + "px' id='but" + id + "' style='cursor:pointer;'/>";
  1929. if (GM_getValue("league_graph_button") === "checked") {
  1930. buttonDisplay = ""
  1931. } else {
  1932. buttonDisplay = "display:none;";
  1933. }
  1934. iner += "<img alt='' src='https://statsxente.com/MZ1/View/Images/graph.png' width='" + GM_getValue("league_image_size") + "px' height='" + GM_getValue("league_image_size") + "px' id='but1" + id + "' style='cursor:pointer; " + buttonDisplay + "'/>";
  1935.  
  1936. if (GM_getValue("league_report_button") === "checked") {
  1937. buttonDisplay = ""
  1938. } else {
  1939. buttonDisplay = "display:none;";
  1940. }
  1941. iner += "<img alt='' src='https://statsxente.com/MZ1/View/Images/report.png' width='" + GM_getValue("league_image_size") + "px' height='" + GM_getValue("league_image_size") + "px' id='but2" + id + "' style='cursor:pointer; " + buttonDisplay + "'/>";
  1942.  
  1943. if (GM_getValue("league_calendar_button") === "checked") {
  1944. buttonDisplay = ""
  1945. } else {
  1946. buttonDisplay = "display:none;";
  1947. }
  1948. iner += " <img alt='' src='https://statsxente.com/MZ1/View/Images/calendar.png' width='" + GM_getValue("league_image_size") + "px' height='" + GM_getValue("league_image_size") + "px' id='but3" + id + "' style='cursor:pointer; " + buttonDisplay + "'/>";
  1949. cat = cats[urlParams.get('type')]
  1950. nuevaColumna.innerHTML = iner
  1951. filasDatos[i].appendChild(nuevaColumna);
  1952. nuevaColumna = document.createElement("td");
  1953.  
  1954.  
  1955. (function (currentId, currentLSport, lang) {
  1956. document.getElementById("but1" + currentId).addEventListener('click', function () {
  1957. let link = "https://statsxente.com/MZ1/Functions/graphLoader.php?graph=team_progress&idEquipo=" + currentId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") + "&deporte=" + currentLSport;
  1958. openWindow(link, 0.95, 1.25);
  1959. });
  1960. })(id, window.lsport, window.lang);
  1961.  
  1962. (function (currentId, currentLSport, lang) {
  1963. document.getElementById("but2" + currentId).addEventListener('click', function () {
  1964. let src = "filtroGraficoEquiposHistoricoHockey";
  1965. if (currentLSport === "F") {
  1966. src = "filtroGraficoLinealEquiposHistorico";
  1967. }
  1968. let link = "https://statsxente.com/MZ1/View/" + src + ".php?tamper=yes&categoria=" + cat + "&idEquipo=" + currentId + "&idioma=" + lang + "&modal=yes&valor=nota&season=75&season_actual=75&equipo=-"
  1969. openWindow(link, 0.95, 1.25);
  1970. });
  1971. })(id, window.lsport, window.lang, cat);
  1972.  
  1973. (function (currentId, currentEquipo, currentCat, currentSport, lang) {
  1974. document.getElementById("but" + currentId).addEventListener('click', function () {
  1975.  
  1976. let link = "https://statsxente.com/MZ1/View/filtroStatsEquiposHistorico.php?tamper=no&idEquipo=" + currentId + "&idioma=" + lang + "&modal=yes&deporte=" + currentSport + "&season=77&season_actual=77&categoria=" + currentCat + "&equipo=" + currentEquipo + "&cerrar=no";
  1977. openWindow(link, 0.95, 1.25);
  1978. });
  1979. })(id, equipo, cat, window.sport, window.lang);
  1980.  
  1981. (function (currentId, type, currentCat, currentSport, lang, flagS, flagS23, flagS21, flagS18) {
  1982. document.getElementById("but3" + currentId).addEventListener('click', function () {
  1983. let link = "https://statsxente.com/MZ1/Graficos/graficoRachaEquipoELO.php?tamper=yes&team_id=" + currentId + "&idioma=" + lang + "&deporte=" + currentSport + "&type=" + type + "&cat=" + currentCat + "&flagSenior=" +
  1984. flagS + "&flagSub23=" + flagS23 + "&flagSub21=" + flagS21 + "&flagSub18=" + flagS18;
  1985. openWindow(link, 0.95, 1.25);
  1986. });
  1987. })(id, eloType, cats_elo[cat], window.sport, window.lang, flagSenior, flagSub23, flagSub21, flagSub18);
  1988.  
  1989. }
  1990.  
  1991. }
  1992.  
  1993. let thead = document.getElementsByClassName("seriesHeader")[0]
  1994. let ths = thead.querySelectorAll("th");
  1995. ths.forEach(function (th, index) {
  1996. th.addEventListener("click", function () {
  1997. if (index === 1) {
  1998. ordenarTablaText(index, true, "nice_table",true);
  1999. } else {
  2000. ordenarTabla(index, true, "nice_table",true);
  2001. }
  2002.  
  2003. });
  2004. });
  2005. }
  2006. });
  2007. }
  2008. //Clash leagues page
  2009. function clashLeagues() {
  2010.  
  2011. document.getElementById("division-select").addEventListener('change', function () {
  2012. setTimeout(function () {
  2013. clashLeagues();
  2014. }, 2000);
  2015. });
  2016.  
  2017.  
  2018. document.getElementById("season-select").addEventListener('change', function () {
  2019. setTimeout(function () {
  2020. clashLeagues();
  2021. }, 2000);
  2022. });
  2023.  
  2024.  
  2025.  
  2026.  
  2027. let elems = document.getElementsByClassName("nice_table");
  2028. let tabla = elems[0]
  2029. let thSegundo = tabla.querySelector("thead th:nth-child(2)");
  2030. thSegundo.style.width = "250px";
  2031. let values = new Map();
  2032. values.set('valueLM', 'LM Value');
  2033. values.set('elo', 'ELO Score');
  2034. values.set('teams_count', 'Number of teams');
  2035. values.set('table_index', 'Rank Position');
  2036.  
  2037. let contenidoNuevo = '<div id=testClick style="margin: 0 auto; text-align:center;">'
  2038. getNativeTableStyles();
  2039.  
  2040. ///MENU TABLE
  2041. contenidoNuevo += "<table id=showMenu style='margin: 0 auto; text-align:center;'><thead style='background-color:" + GM_getValue("bg_native") + "; color:" + GM_getValue("color_native") + ";'><tr>";
  2042. contenidoNuevo += '<th style="padding:4px; margin: 0 auto; text-align:center;" colspan="3">Values</th></tr></thead>';
  2043. contenidoNuevo += "<tr>";
  2044. contenidoNuevo += "</tr></table>";
  2045. contenidoNuevo += '<table id=show3 style="margin: 0 auto; text-align:center;"><tr><td><label>';
  2046. contenidoNuevo += '<input class="statsxente" type="checkbox" checked id="value" value="Value">Value</label></td>';
  2047.  
  2048.  
  2049. values.forEach(function (valor, clave) {
  2050. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  2051. });
  2052. contenidoNuevo += "</tr></table>"
  2053. contenidoNuevo += "</div></br>";
  2054.  
  2055. values.set('value', 'Value');
  2056. elems = document.getElementsByClassName("nice_table");
  2057. tabla = elems[0]
  2058. tabla.insertAdjacentHTML('beforebegin', contenidoNuevo);
  2059.  
  2060.  
  2061.  
  2062. values.forEach(function (valor, clave) {
  2063.  
  2064. let elemento = document.getElementById(clave);
  2065. elemento.addEventListener('click', handleClickClash);
  2066.  
  2067. });
  2068. let nuevaCeldaEncabezado = document.createElement("th");
  2069. nuevaCeldaEncabezado.textContent = "Value";
  2070. nuevaCeldaEncabezado.style.textAlign = 'center';
  2071.  
  2072. document.getElementsByClassName("nice_table")[0].querySelector('thead').querySelector('tr').appendChild(nuevaCeldaEncabezado);
  2073.  
  2074. nuevaCeldaEncabezado = document.createElement("th");
  2075. nuevaCeldaEncabezado.textContent = "Stats Xente";
  2076. nuevaCeldaEncabezado.style.textAlign = 'center';
  2077. document.getElementsByClassName("nice_table")[0].querySelector('thead').querySelector('tr').appendChild(nuevaCeldaEncabezado);
  2078.  
  2079.  
  2080. let contIds = 0
  2081. let linkIds = ""
  2082. let filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  2083. for (let i = 0; i < filasDatos.length; i++) {
  2084. let celda = tabla.rows[i + 1].cells[1];
  2085. let imagen = celda.querySelector('img');
  2086. let url = new URL(imagen.src);
  2087. let id = url.searchParams.get('fid');
  2088. linkIds += "&id" + contIds + "=" + id
  2089. contIds++
  2090. }
  2091.  
  2092.  
  2093. GM_xmlhttpRequest({
  2094. method: "GET",
  2095. url: "https://statsxente.com/MZ1/Functions/tamper_federations.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + linkIds,
  2096. headers: {
  2097. "Content-Type": "application/json"
  2098. },
  2099. onload: function (response) {
  2100. let jsonResponse = JSON.parse(response.responseText);
  2101. teams_data = jsonResponse;
  2102. let filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  2103. for (let i = 0; i < filasDatos.length; i++) {
  2104. let celda = tabla.rows[i + 1].cells[1];
  2105. let imagen = celda.querySelector('img');
  2106. let url = new URL(imagen.src);
  2107. let id = url.searchParams.get('fid');
  2108. let nuevaColumna = document.createElement("td");
  2109. let valor = 0
  2110.  
  2111. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[id]["value"]))
  2112. nuevaColumna.innerHTML = valor
  2113. nuevaColumna.style.textAlign = 'center';
  2114. filasDatos[i].appendChild(nuevaColumna);
  2115.  
  2116.  
  2117. nuevaColumna = document.createElement("td");
  2118. nuevaColumna.style.margin = '0 auto';
  2119. nuevaColumna.style.textAlign = 'center';
  2120. nuevaColumna.innerHTML = "<img alt='' src='https://statsxente.com/MZ1/View/Images/detail.png' width='20px' height='20px' id='but" + id + "' style='cursor:pointer;'/>"
  2121. filasDatos[i].appendChild(nuevaColumna);
  2122.  
  2123.  
  2124. (function (currentId, currentSport, lang) {
  2125. document.getElementById("but" + currentId).addEventListener('click', function () {
  2126.  
  2127. let link = "https://statsxente.com/MZ1/Functions/loadClashFederationDetail.php?tamper=yes&idioma=" +
  2128. lang + "&modal_to_close=myModal&divisa=" + GM_getValue("currency") + "&fid=" + currentId + "&sport=" + currentSport + "&modal=yes";
  2129. openWindow(link, 0.95, 1.25);
  2130. });
  2131. })(id, window.sport, window.lang);
  2132.  
  2133. }
  2134. }
  2135. });
  2136.  
  2137. let thead = document.getElementsByClassName("nice_table")[0].querySelector('thead')
  2138. let ths = thead.querySelectorAll("th");
  2139. ths.forEach(function (th, index) {
  2140. th.addEventListener("click", function () {
  2141. ordenarTabla(index, true, "nice_table",true);
  2142. });
  2143. });
  2144. }
  2145.  
  2146.  
  2147. //Cups and FL's page
  2148. async function friendlyCupsAndLeagues() {
  2149.  
  2150. let urlParams = new URLSearchParams(window.location.search);
  2151. let age_restriction
  2152. let idComp="null"
  2153. let link = "https://www.managerzone.com" + document.getElementById("ui-id-1").getAttribute('href')
  2154. if (urlParams.get('fsid')) {
  2155. let fl_data= await fetchExistsFL(urlParams.get('fsid'))
  2156. idComp=fl_data['id']
  2157. age_restriction = await fetchAgeRestriction(link);
  2158. } else {
  2159. age_restriction = await fetchCupAgeRestriction(link);
  2160. }
  2161.  
  2162. let detected_cat = "senior"
  2163.  
  2164. if (age_restriction !== "none") {
  2165.  
  2166.  
  2167. switch (age_restriction) {
  2168. case "U23":
  2169. detected_cat = "u23"
  2170. break;
  2171. case "U21":
  2172. detected_cat = "u21"
  2173. break;
  2174. case "U18":
  2175. detected_cat = "u18"
  2176. break;
  2177. }
  2178.  
  2179. }
  2180.  
  2181.  
  2182.  
  2183. let initialValues = {};
  2184. initialValues["senior"] = GM_getValue("league_default_senior");
  2185. initialValues["world"] = GM_getValue("league_default_senior");
  2186. initialValues["u23"] = GM_getValue("league_default_u23");
  2187. initialValues["u21"] = GM_getValue("league_default_u21");
  2188. initialValues["u18"] = GM_getValue("league_default_u18");
  2189. initialValues["u23_world"] = GM_getValue("league_default_u23");
  2190. initialValues["u21_world"] = GM_getValue("league_default_u21");
  2191. initialValues["u18_world"] = GM_getValue("league_default_u18");
  2192.  
  2193. let linkIds = ""
  2194. let elems = document.getElementsByClassName("nice_table");
  2195. let tabla = elems[0]
  2196. let thSegundo = tabla.querySelector("thead th:nth-child(2)");
  2197. thSegundo.style.width = "250px";
  2198.  
  2199.  
  2200. let values = new Map();
  2201. values.set('valor23', 'U23 Value');
  2202. values.set('valor21', 'U21 Value');
  2203. values.set('valor18', 'U18 Value');
  2204. values.set('salario', 'Salary');
  2205. values.set('valorUPSenior', 'LM Value');
  2206. values.set('valorUPSUB23', 'U23 LM Value');
  2207. values.set('valorUPSUB21', 'U21 LM Value');
  2208. values.set('valorUPSUB18', 'U18 LM Value');
  2209. values.set('edad', 'Age');
  2210. if (window.sport === "soccer") {
  2211. values.set('valor11', 'TOP 11');
  2212. values.set('valor11_23', 'U23 TOP 11');
  2213. values.set('valor11_21', 'U21 TOP 11');
  2214. values.set('valor11_18', 'U18 TOP 11');
  2215. } else {
  2216. values.set('valor11', 'TOP 21');
  2217. values.set('valor11_23', 'U23 TOP 21');
  2218. values.set('valor11_21', 'U21 TOP 21');
  2219. values.set('valor11_18', 'U18 TOP 21');
  2220. }
  2221.  
  2222. values.set('noNac', 'Foreigners');
  2223. values.set('elo', 'ELO Score');
  2224. values.set('elo23', 'U23 ELO Score');
  2225. values.set('elo21', 'U21 ELO Score');
  2226. values.set('elo18', 'U18 ELO Score');
  2227. values.set('numJugadores', 'Number of players');
  2228. values.set('leagues', 'Leagues');
  2229. values.set('world_leagues_all', 'World Leagues');
  2230. values.set('youth_leagues_all', 'Youth Leagues');
  2231. values.set('world_youth_leagues_all', 'Youth World Leagues');
  2232. values.set('federation_leagues', 'Federation Leagues');
  2233. values.set('cup', 'Cups');
  2234. values.set('cup_u23', 'U23 Cups');
  2235. values.set('cup_u21', 'U21 Cups');
  2236. values.set('cup_u18', 'U18 Cups');
  2237. values.set('special_cup', 'Special Cups');
  2238.  
  2239. let contenidoNuevo = '<div id="testClick" style="margin: 0 auto; text-align:center;">'
  2240. getNativeTableStyles();
  2241.  
  2242. ///MENU TABLE
  2243. contenidoNuevo += "<table id=showMenu style='margin: 0 auto; text-align:center;'><thead style='background-color:" + GM_getValue("bg_native") + "; color:" + GM_getValue("color_native") + ";'><tr>";
  2244. contenidoNuevo += '<th style="padding:4px; margin: 0 auto; text-align:center;" colspan="4">Stats Xente</th>';
  2245. contenidoNuevo += "</tr></thead>";
  2246. let styleTable = " style='display:none;'";
  2247. let styleIcon = ""
  2248. let styleSep = "style='padding-top:5px;'";
  2249.  
  2250. if (GM_getValue("show_league_selects") === true) {
  2251. styleTable = " style='margin: 0 auto; text-align:left;'";
  2252. styleIcon = " active"
  2253. styleSep = " style='display:none;'";
  2254.  
  2255. }
  2256.  
  2257. contenidoNuevo += "<tr><td></td><td style='padding-top:5px' colspan='2'>";
  2258. contenidoNuevo += '<div id="moreInfo" class="expandable-icon' + styleIcon + '" style="margin: 0 auto; text-align:center; cursor:pointer; background-color:' + GM_getValue("bg_native") + ';"><div id="line1" class="line"></div><div id="line2" class="line"></div></div></center>';
  2259. contenidoNuevo += "</td><td></td></tr>";
  2260. contenidoNuevo += "<tr><td colspan='5' id='separatorTd'" + styleSep + "></td></tr>";
  2261. contenidoNuevo += "</table>";
  2262.  
  2263.  
  2264. contenidoNuevo += '<table id=show3' + styleTable + '><tr><td><label>';
  2265.  
  2266. if ("valor" === initialValues[detected_cat]) {
  2267. contenidoNuevo += '<input class="statsxente" type="checkbox" checked id="valor" value="Value">Value</label></td>';
  2268. } else {
  2269. contenidoNuevo += '<input class="statsxente" type="checkbox" id="valor" value="Value">Value</label></td>';
  2270. }
  2271.  
  2272.  
  2273. values.forEach(function (valor, clave) {
  2274.  
  2275. if (clave === "valorUPSenior") {
  2276. contenidoNuevo += "</tr><tr>";
  2277. }
  2278.  
  2279. if (clave === "valor11") {
  2280. contenidoNuevo += "</tr><tr>";
  2281. }
  2282. if (clave === "elo") {
  2283. contenidoNuevo += "</tr><tr>";
  2284. }
  2285.  
  2286. if (clave === "leagues") {
  2287. contenidoNuevo += "</tr><tr>";
  2288. }
  2289.  
  2290. if (clave === "leagues_all") {
  2291. contenidoNuevo += "</tr><tr>";
  2292. }
  2293.  
  2294. if (clave === "cup") {
  2295. contenidoNuevo += "</tr><tr>";
  2296. }
  2297.  
  2298. if (clave === initialValues[detected_cat]) {
  2299. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" checked value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  2300. } else {
  2301. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  2302. }
  2303. });
  2304. contenidoNuevo += "</tr></table></center>"
  2305. contenidoNuevo += "</div></br>";
  2306.  
  2307.  
  2308. if(idComp!=="null"){
  2309.  
  2310. contenidoNuevo +="<table style='width:80%; margin: 0 auto; text-align:center;'><tr>"
  2311. let color=GM_getValue("bg_native")
  2312. contenidoNuevo +='<td><button class="btn-comp-fed" style="color:'+GM_getValue("color_native")+'; background-color:'+GM_getValue("bg_native")+'; font-family: \'Roboto\'; font-weight:bold; font-size:revert;" id="todos">All against all</button></td>'
  2313. contenidoNuevo += '<td><button class="btn-comp-fed" style="color:'+GM_getValue("color_native")+'; background-color:'+GM_getValue("bg_native")+'; font-family: \'Roboto\'; font-weight:bold; font-size:revert;" id="directosSIN">Direct confrontations [Without ties]</button></td>'
  2314. contenidoNuevo += '<td><button class="btn-comp-fed" style="color:'+GM_getValue("color_native")+'; background-color:'+GM_getValue("bg_native")+'; font-family: \'Roboto\'; font-weight:bold; font-size:revert;" id="directosCON">Direct confrontations [With ties]</button></td>'
  2315. contenidoNuevo +="</tr>"
  2316.  
  2317. contenidoNuevo += '<tr><td colspan="3"><button class="btn-comp-fed" style="color:'+GM_getValue("color_native")+'; background-color:'+GM_getValue("bg_native")+'; font-family: \'Roboto\'; font-weight:bold; font-size:revert;" id="desgloseSIN">Users Points [Without ties]</button>'
  2318. contenidoNuevo += '&nbsp;<button class="btn-comp-fed" style="color:'+GM_getValue("color_native")+'; background-color:'+GM_getValue("bg_native")+'; font-family: \'Roboto\'; font-weight:bold; font-size:revert;" id="desgloseCON">Users Points [With ties]</button></td>'
  2319.  
  2320. contenidoNuevo +="</tr>"
  2321.  
  2322. contenidoNuevo +="</table></br>"
  2323.  
  2324.  
  2325.  
  2326. let darkerColor = darkenColor(color, 25);
  2327.  
  2328. document.styleSheets[0].insertRule(
  2329. '.btn-comp-fed:hover { background-color: '+darkerColor+' !important; }',
  2330. document.styleSheets[0].cssRules.length
  2331. );
  2332.  
  2333. values.set('valor', 'Value');
  2334. elems = document.getElementsByClassName("nice_table");
  2335. tabla = elems[0]
  2336. tabla.insertAdjacentHTML('beforebegin', contenidoNuevo);
  2337.  
  2338.  
  2339. ///COM FED BUTTONS
  2340. document.getElementById("todos").addEventListener('click', function () {
  2341. let link = "https://statsxente.com/MZ1/View/FEDCOMP_ContraTodos_VIEW.php?tamper=yes&id="+idComp+"&idioma="+ window.lang
  2342. openWindow(link, 0.75, 1.1);
  2343. });
  2344. document.getElementById("directosSIN").addEventListener('click', function () {
  2345. let link = "https://statsxente.com/MZ1/View/FEDCOMP_Directos_VIEW.php?tamper=yes&id="+idComp+"&idioma="+ window.lang
  2346. openWindow(link, 0.75, 1.1);
  2347. });
  2348. document.getElementById("directosCON").addEventListener('click', function () {
  2349. let link = "https://statsxente.com/MZ1/View/FEDCOMP_DirectosEmpates_VIEW.php?tamper=yes&id="+idComp+"&idioma="+ window.lang
  2350. openWindow(link, 0.75, 1.1);
  2351. });
  2352.  
  2353. document.getElementById("desgloseSIN").addEventListener('click', function () {
  2354. let link = "https://statsxente.com/MZ1/Lecturas/getDesglosePuntosFede.php?tamper=yes&idComp="+idComp+"&idioma="+ window.lang+"&idLiga="+urlParams.get('fsid')
  2355. openWindow(link, 0.75, 1.1);
  2356. });
  2357.  
  2358. document.getElementById("desgloseCON").addEventListener('click', function () {
  2359. let link = "https://statsxente.com/MZ1/Lecturas/getDesglosePuntosFedeEmpates.php?tamper=yes&idComp="+idComp+"&idioma="+ window.lang+"&idLiga="+urlParams.get('fsid')
  2360. openWindow(link, 0.75, 1.1);
  2361. });
  2362.  
  2363. }else{
  2364.  
  2365. values.set('valor', 'Value');
  2366. elems = document.getElementsByClassName("nice_table");
  2367. tabla = elems[0]
  2368. tabla.insertAdjacentHTML('beforebegin', contenidoNuevo);
  2369.  
  2370. }
  2371.  
  2372.  
  2373.  
  2374.  
  2375.  
  2376. if (GM_getValue("show_league_selects") === true) {
  2377.  
  2378. document.getElementById("line2").style.transform = 'rotateZ(0deg)';
  2379. document.getElementById("line1").style.transform = 'rotateZ(180deg)';
  2380. document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
  2381. }
  2382.  
  2383.  
  2384. values.forEach(function (valor, clave) {
  2385.  
  2386. let elemento = document.getElementById(clave);
  2387. elemento.addEventListener('click', handleClick);
  2388.  
  2389. });
  2390.  
  2391. let thWidth="7.5em"
  2392.  
  2393. if(idComp!=="null"){
  2394. thWidth="5.5em"
  2395. }
  2396.  
  2397. let nuevaCeldaEncabezado = document.createElement("th");
  2398. nuevaCeldaEncabezado.textContent = values.get(initialValues[detected_cat]);
  2399. nuevaCeldaEncabezado.style.textAlign = 'center';
  2400. nuevaCeldaEncabezado.style.maxWidth = thWidth;
  2401. nuevaCeldaEncabezado.style.width = thWidth;
  2402. nuevaCeldaEncabezado.style.whiteSpace = 'nowrap';
  2403. nuevaCeldaEncabezado.style.overflow = 'hidden';
  2404. nuevaCeldaEncabezado.style.textOverflow = 'ellipsis';
  2405.  
  2406. let ser = document.getElementsByClassName("seriesHeader")
  2407.  
  2408.  
  2409. let table_index = 0;
  2410. for (let kl = 0; kl < ser.length; kl++) {
  2411. if (document.getElementsByClassName("seriesHeader")[kl].parentNode.parentNode.className === "nice_table") {
  2412. table_index = kl
  2413. }
  2414.  
  2415.  
  2416. }
  2417.  
  2418. let widthTeam="180px"
  2419.  
  2420. if(idComp!=="null"){
  2421. widthTeam="150px";
  2422. }
  2423.  
  2424.  
  2425. document.getElementsByClassName("seriesHeader")[table_index].cells[1].style.width = widthTeam
  2426. document.getElementsByClassName("seriesHeader")[table_index].appendChild(nuevaCeldaEncabezado);
  2427.  
  2428. if(idComp!=="null"){
  2429.  
  2430. let nuevaColumna1 = document.getElementsByClassName("seriesHeader")[table_index].insertCell(2);
  2431. nuevaColumna1.outerHTML = "<th>Federation</th>"
  2432. nuevaColumna1.style.textAlign = 'center';
  2433.  
  2434.  
  2435. let tds = document.querySelectorAll('.nice_table td');
  2436. let ths = document.querySelectorAll('.nice_table th');
  2437.  
  2438. tds.forEach(td => {
  2439. td.style.paddingLeft = "3px";
  2440. td.style.paddingRight = "3px";
  2441. });
  2442.  
  2443. ths.forEach(th => {
  2444. th.style.paddingLeft = "3px";
  2445. th.style.paddingRight = "3px";
  2446. });
  2447.  
  2448. }
  2449.  
  2450.  
  2451. nuevaCeldaEncabezado = document.createElement("th");
  2452. nuevaCeldaEncabezado.textContent = "Stats Xente";
  2453. nuevaCeldaEncabezado.style.textAlign = 'center';
  2454. document.getElementsByClassName("seriesHeader")[table_index].appendChild(nuevaCeldaEncabezado);
  2455.  
  2456.  
  2457. if (tabla.getElementsByTagName("tbody")[0].innerHTML.includes("mazyar")) {
  2458. searchClassName = "responsive-hide"
  2459. }
  2460.  
  2461. let contIds = 0
  2462. let filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  2463. for (let i = 0; i < filasDatos.length; i++) {
  2464. if (checkClassNameExists(tabla.rows[i + 1], searchClassName)) {
  2465. let celda = tabla.rows[i + 1].cells[1];
  2466. let team_data=extractTeamData(celda.getElementsByTagName("a"));
  2467. let id=team_data[0]
  2468. let equipo=team_data[1]
  2469.  
  2470. linkIds += "&idEquipo" + contIds + "=" + id
  2471. contIds++
  2472. celda.innerHTML += "<input type='hidden' id='team_" + id + "' value='" + equipo + "'/>"
  2473. }
  2474.  
  2475. }
  2476.  
  2477.  
  2478.  
  2479. ///DIV PROGRESS
  2480. setTimeout(function () {
  2481.  
  2482.  
  2483. (function () {
  2484. document.getElementById("moreInfo").addEventListener('click', function () {
  2485. document.getElementById("moreInfo").classList.toggle('active');
  2486.  
  2487. if (document.getElementById("moreInfo").classList.contains("active")) {
  2488. document.getElementById("line2").style.transform = 'rotateZ(0deg)';
  2489. document.getElementById("line1").style.transform = 'rotateZ(180deg)';
  2490. document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
  2491. $('#separatorTd').fadeOut(1);
  2492. document.getElementById("separatorTd").style.paddingTop = "5px";
  2493. $('#show3').fadeIn('slow');
  2494. } else {
  2495. document.getElementById("line2").style.transform = 'rotateZ(45deg)';
  2496. document.getElementById("line1").style.transform = 'rotateZ(-45deg)';
  2497. document.getElementById("moreInfo").style.transform = 'rotateZ(45deg)';
  2498. $('#separatorTd').fadeIn(1);
  2499. $('#show3').fadeOut('slow');
  2500. }
  2501.  
  2502.  
  2503.  
  2504. });
  2505. })();
  2506.  
  2507. }, 200);
  2508.  
  2509. GM_xmlhttpRequest({
  2510. method: "GET",
  2511. url: "https://statsxente.com/MZ1/Functions/tamper_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + linkIds,
  2512. headers: {
  2513. "Content-Type": "application/json"
  2514. },
  2515. onload: function (response) {
  2516. let jsonResponse = JSON.parse(response.responseText);
  2517. teams_data = jsonResponse;
  2518. let filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  2519. for (let i = 0; i < filasDatos.length; i++) {
  2520. if (checkClassNameExists(filasDatos[i], searchClassName)) {
  2521. let celda = filasDatos[i].cells[1]
  2522. let team_data=extractTeamData(celda.getElementsByTagName("a"));
  2523. let id=team_data[0]
  2524. let equipo=team_data[1]
  2525.  
  2526. let nuevaColumna = document.createElement("td");
  2527. let valor = 0;
  2528.  
  2529. if (jsonResponse[id] && jsonResponse[id][initialValues[detected_cat]] !== undefined) {
  2530. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[id][initialValues[detected_cat]]))
  2531. }
  2532. nuevaColumna.innerHTML = valor
  2533. nuevaColumna.style.textAlign = 'center';
  2534. filasDatos[i].appendChild(nuevaColumna);
  2535.  
  2536.  
  2537. if(idComp!=="null"){
  2538. let nuevaColumna1 = filasDatos[i].insertCell(2);
  2539. nuevaColumna1.innerHTML = "<img alt='' src='https://www.managerzone.com/dynimg/pic.php?type=federation&fid="+fl_data["federations"][fl_data['teams'][id]['nombreFede']]['idFede']+"&size=small&sport=soccer' width='10px' height='10px'/> <span style='color:red;'>"+fl_data['teams'][id]['nombreFede']+"</span>";
  2540. nuevaColumna1.style.textAlign = 'left';
  2541. }
  2542.  
  2543. let eloType = 1
  2544. if (window.sport === "soccer") { eloType = 2 }
  2545. let cats_elo = {}
  2546. cats_elo["senior"] = "SENIOR";
  2547. cats_elo["seniorw"] = "SENIOR";
  2548. cats_elo["SUB23"] = "U23";
  2549. cats_elo["SUB21"] = "U21";
  2550. cats_elo["SUB18"] = "U18";
  2551. cats_elo["SUB23w"] = "U23";
  2552. cats_elo["SUB21w"] = "U21";
  2553. cats_elo["SUB18w"] = "U18";
  2554.  
  2555. let cat = cats[detected_cat]
  2556.  
  2557.  
  2558. let flagSenior = 0, flagSub23 = 0, flagSub21 = 0, flagSub18 = 0;
  2559. if (jsonResponse[id]["elo"] > 0) { flagSenior = 1 }
  2560. if (jsonResponse[id]["elo23"] > 0) { flagSub23 = 1 }
  2561. if (jsonResponse[id]["elo21"] > 0) { flagSub21 = 1 }
  2562. if (jsonResponse[id]["elo18"] > 0) { flagSub18 = 1 }
  2563.  
  2564. let buttonDisplay = "display:block;";
  2565. nuevaColumna = document.createElement("td");
  2566. nuevaColumna.style.margin = '0 auto';
  2567. nuevaColumna.style.textAlign = 'center';
  2568. let iner = "<img alt='' src='https://statsxente.com/MZ1/View/Images/detail.png' width='" + GM_getValue("league_image_size") + "px' height='" + GM_getValue("league_image_size") + "px' id='but" + id + "' style='cursor:pointer;'/>";
  2569. if (GM_getValue("league_graph_button") === "checked") {
  2570. buttonDisplay = ""
  2571. } else {
  2572. buttonDisplay = "display:none;";
  2573. }
  2574. iner += "<img alt='' src='https://statsxente.com/MZ1/View/Images/graph.png' width='" + GM_getValue("league_image_size") + "px' height='" + GM_getValue("league_image_size") + "px' id='but1" + id + "' style='cursor:pointer; " + buttonDisplay + "'/>";
  2575.  
  2576. if (GM_getValue("league_report_button") === "checked") {
  2577. buttonDisplay = ""
  2578. } else {
  2579. buttonDisplay = "display:none;";
  2580. }
  2581. iner += "<img alt='' src='https://statsxente.com/MZ1/View/Images/report.png' width='" + GM_getValue("league_image_size") + "px' height='" + GM_getValue("league_image_size") + "px' id='but2" + id + "' style='cursor:pointer; " + buttonDisplay + "'/>";
  2582.  
  2583. if (GM_getValue("league_calendar_button") === "checked") {
  2584. buttonDisplay = ""
  2585. } else {
  2586. buttonDisplay = "display:none;";
  2587. }
  2588. iner += " <img alt='' src='https://statsxente.com/MZ1/View/Images/calendar.png' width='" + GM_getValue("league_image_size") + "px' height='" + GM_getValue("league_image_size") + "px' id='but3" + id + "' style='cursor:pointer; " + buttonDisplay + "'/>";
  2589. iner += "</center>";
  2590.  
  2591. nuevaColumna.innerHTML = iner
  2592. filasDatos[i].appendChild(nuevaColumna);
  2593. nuevaColumna = document.createElement("td");
  2594. (function (currentId, currentLSport, lang) {
  2595. document.getElementById("but1" + currentId).addEventListener('click', function () {
  2596. let link = "https://statsxente.com/MZ1/Graficos/graficoProgresoEquipo.php?idEquipo=" + currentId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") + "&deporte=" + currentLSport;
  2597. openWindow(link, 0.95, 1.25);
  2598. });
  2599. })(id, window.lsport, window.lang);
  2600.  
  2601.  
  2602. (function (currentId, currentLSport, lang, currentCat) {
  2603. document.getElementById("but2" + currentId).addEventListener('click', function () {
  2604. let src = "filtroGraficoEquiposHistoricoHockey";
  2605. if (currentLSport === "F") {
  2606. src = "filtroGraficoLinealEquiposHistorico";
  2607. }
  2608.  
  2609. let link = "https://statsxente.com/MZ1/View/" + src + ".php?tamper=yes&categoria=" + currentCat + "&idEquipo=" + currentId + "&idioma=" + lang + "&modal=yes&valor=nota&season=75&season_actual=75&equipo=-"
  2610. openWindow(link, 0.95, 1.25);
  2611. });
  2612. })(id, window.lsport, window.lang, cat);
  2613.  
  2614.  
  2615. (function (currentId, currentEquipo, currentCat, currentSport, lang) {
  2616. document.getElementById("but" + currentId).addEventListener('click', function () {
  2617. let link = "https://statsxente.com/MZ1/View/filtroStatsEquiposHistorico.php?tamper=no&idEquipo=" + currentId + "&idioma=" + lang + "&modal=yes&deporte=" + currentSport + "&season=77&season_actual=77&categoria=" + currentCat + "&equipo=" + currentEquipo + "&cerrar=no";
  2618. openWindow(link, 0.95, 1.25);
  2619. });
  2620. })(id, equipo, cat, window.sport, window.lang);
  2621.  
  2622.  
  2623.  
  2624.  
  2625. (function (currentId, type, currentCat, currentSport, lang, flagS, flagS23, flagS21, flagS18) {
  2626. document.getElementById("but3" + currentId).addEventListener('click', function () {
  2627. let link = "https://statsxente.com/MZ1/Graficos/graficoRachaEquipoELO.php?tamper=yes&team_id=" + currentId + "&idioma=" + lang + "&deporte=" + currentSport + "&type=" + type + "&cat=" + currentCat + "&flagSenior=" +
  2628. flagS + "&flagSub23=" + flagS23 + "&flagSub21=" + flagS21 + "&flagSub18=" + flagS18;
  2629. openWindow(link, 0.95, 1.25);
  2630. });
  2631. })(id, eloType, cats_elo[cat], window.sport, window.lang, flagSenior, flagSub23, flagSub21, flagSub18);
  2632.  
  2633. }
  2634.  
  2635. }
  2636. let thead = document.getElementsByClassName("seriesHeader")[table_index]
  2637. let ths = thead.querySelectorAll("th");
  2638. ths.forEach(function (th, index) {
  2639. th.addEventListener("click", function () {
  2640. ordenarTabla(index, true, "nice_table",true);
  2641. });
  2642. });
  2643. }
  2644. });
  2645.  
  2646.  
  2647. }
  2648. //Match page
  2649. async function match() {
  2650. let team_div = document.getElementsByClassName("flex-grow-0 textCenter team-table block")
  2651. if (team_div.length===0){
  2652. team_div = document.getElementsByClassName("flex-grow-0 textCenter team-table no-match-buttons block")
  2653. }
  2654. let teams_ = []
  2655.  
  2656.  
  2657.  
  2658.  
  2659.  
  2660. let linkIds=""
  2661. let contIds=0
  2662. for (let x = 0; x < 2; x++) {
  2663. let as = team_div[x].getElementsByTagName("a")
  2664. let urlObj = new URL("https://www.managerzone.com/" + as[0].getAttribute('href'));
  2665. let params = new URLSearchParams(urlObj.search);
  2666. let tidValue = params.get('tid');
  2667. teams_[x] = { "team_name": as[0].innerHTML, "team_id": tidValue, "inserted": "" }
  2668. linkIds += "&idEquipo" + contIds + "=" + tidValue
  2669. contIds++
  2670. }
  2671.  
  2672.  
  2673.  
  2674. GM_xmlhttpRequest({
  2675. method: "GET",
  2676. url: "https://statsxente.com/MZ1/Functions/tamper_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + linkIds,
  2677. headers: {
  2678. "Content-Type": "application/json"
  2679. },
  2680. onload: function (response) {
  2681.  
  2682. let jsonResponse = JSON.parse(response.responseText);
  2683.  
  2684. const divs = document.querySelectorAll('div'); // Selecciona todos los divs
  2685. const divsConAltura15px = Array.from(divs).filter(div => {
  2686. const computedStyle = window.getComputedStyle(div);
  2687. return computedStyle.height === '15px' && div.innerHTML === "";
  2688. });
  2689.  
  2690.  
  2691. for(let m=0;m<2;m++){
  2692.  
  2693. let aux=teams_[m]['team_id']
  2694.  
  2695. let top="TOP 11"
  2696.  
  2697. if(window.sport==="hockey"){
  2698. top="TOP 21"
  2699. }
  2700.  
  2701. let teamTable='<div style="display: flex;flex-direction: column;justify-content: center;align-items: center;flex-wrap: wrap;max-height: 100%;">'
  2702. teamTable+='<table class="matchValuesTable"><thead><tr>'
  2703. teamTable+='<th id=thTransparent'+m+' style="background-color:transparent; border:0;"></th>'
  2704. teamTable+='<th style="border-top-left-radius: 5px;">Value</th><th>LM Value</th>'
  2705. teamTable+='<th >'+top+'</th><th style="border-top-right-radius: 5px;">ELO</th></tr></thead><tbody>'
  2706. let valor=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor']))
  2707. let valorLM=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valorUPSenior']))
  2708. let valor11=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor11']))
  2709. let elo=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['elo']))
  2710. teamTable+='<tr><th style="border-top-left-radius: 5px;">Senior</th><td>'+valor+'</td><td>'+valorLM+'</td><td>'+valor11+'</td><td style="border-right:1px solid '+GM_getValue("bg_native")+';">'+elo+'</td></tr>'
  2711.  
  2712. valor=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor23']))
  2713. valorLM=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valorUPSUB23']))
  2714. valor11=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor11_23']))
  2715. elo=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['elo23']))
  2716. teamTable+='<tr><th>U23</th><td>'+valor+'</td><td>'+valorLM+'</td><td>'+valor11+'</td><td style="border-right:1px solid '+GM_getValue("bg_native")+';">'+elo+'</td></tr>'
  2717.  
  2718.  
  2719. valor=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor21']))
  2720. valorLM=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valorUPSUB21']))
  2721. valor11=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor11_21']))
  2722. elo=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['elo21']))
  2723. teamTable+='<tr><th>U21</th><td>'+valor+'</td><td>'+valorLM+'</td><td>'+valor11+'</td><td style="border-right:1px solid '+GM_getValue("bg_native")+';">'+elo+'</td></tr>'
  2724.  
  2725. valor=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor18']))
  2726. valorLM=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valorUPSUB18']))
  2727. valor11=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor11_18']))
  2728. elo=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['elo18']))
  2729. teamTable+='<tr><th style="border-bottom-left-radius: 5px;">U18</th><td style="border-bottom:1px solid '+GM_getValue("bg_native")+';">'+valor+'</td>'
  2730. teamTable+='<td style="border-bottom:1px solid '+GM_getValue("bg_native")+';">'+valorLM+'</td>'
  2731. teamTable+='<td style="border-bottom:1px solid '+GM_getValue("bg_native")+';;">'+valor11+'</td>'
  2732. teamTable+='<td style="border-radius: 0 0 10px 0; border-bottom:1px solid '+GM_getValue("bg_native")+'; border-right:1px solid '+GM_getValue("bg_native")+';">'+elo+'</td></tr>'
  2733.  
  2734.  
  2735. teamTable+='</tbody></table></div>'
  2736.  
  2737. divsConAltura15px[m].insertAdjacentHTML('afterend',teamTable)
  2738.  
  2739.  
  2740.  
  2741. }
  2742.  
  2743.  
  2744. const thElements = document.querySelectorAll('table.matchValuesTable th');
  2745.  
  2746. // Cambia el color de fondo de cada <th>
  2747. thElements.forEach(th => {
  2748. th.style.backgroundColor = GM_getValue("bg_native");
  2749. th.style.color = GM_getValue("color_native");
  2750.  
  2751. });
  2752. document.getElementById("thTransparent0").style.backgroundColor="transparent";
  2753. document.getElementById("thTransparent1").style.backgroundColor="transparent";
  2754.  
  2755.  
  2756.  
  2757.  
  2758. }
  2759. });
  2760.  
  2761.  
  2762.  
  2763. let elems = document.getElementsByClassName("hitlist " + window.sport + " statsLite marker tablesorter");
  2764. for (let x = 0; x < 2; x++) {
  2765. let linkIds = ""
  2766. let contIds = 0;
  2767. let tabla = elems[x]
  2768. let filas = tabla.getElementsByTagName("tr");
  2769. let fila = filas[1];
  2770.  
  2771. for (let i = 2; i < filas.length - 1; i++) {
  2772.  
  2773. fila = filas[i];
  2774. let tds = fila.getElementsByTagName("td");
  2775. let as_ = tds[2].getElementsByTagName("a");
  2776. let urlObj = new URL("https://www.managerzone.com/" + as_[0].getAttribute("href"));
  2777. let params = new URLSearchParams(urlObj.search);
  2778. let pid = params.get('pid');
  2779.  
  2780. linkIds += "&id" + contIds + "=" + pid
  2781. contIds++;
  2782. }
  2783.  
  2784. let link = "http://statsxente.com/MZ1/Functions/tamper_check_stats_player.php?sport=" + window.sport + linkIds
  2785. teams_[x]["inserted"]= await fetchExistPlayers(link);
  2786.  
  2787. }
  2788.  
  2789.  
  2790. elems = document.getElementsByClassName("hitlist " + window.sport + " statsLite marker tablesorter");
  2791. for (let x = 0; x < 2; x++) {
  2792. if (teams_[x]['inserted']['total'] > 0) {
  2793. let tabla = elems[x]
  2794. let firstTrThead = tabla.querySelector('thead td');
  2795. let currentColspan = firstTrThead.getAttribute('colspan');
  2796. currentColspan = parseInt(currentColspan, 10) + 1;
  2797. firstTrThead.setAttribute('colspan', currentColspan);
  2798. let secondTrThead = tabla.querySelector('thead tr:nth-of-type(2)')
  2799. let newTd = document.createElement('td');
  2800. newTd.textContent = '';
  2801. secondTrThead.appendChild(newTd);
  2802. let filas = tabla.getElementsByTagName("tr");
  2803. let dato = document.createElement("td");
  2804. let tfoot = tabla.querySelector("tfoot");
  2805. let primeraFilaTfoot = tfoot.querySelector("tr");
  2806. let primerTDTfoot = primeraFilaTfoot.querySelector("td");
  2807. primerTDTfoot.setAttribute("colspan", "9");
  2808.  
  2809. let elems2 = document.getElementsByClassName("listHeadColor");
  2810. let lista = elems2[0]
  2811.  
  2812. let nuevoElementoDD = document.createElement("dd");
  2813. nuevoElementoDD.textContent = "Nuevo elemento";
  2814. nuevoElementoDD.className = "c6"
  2815. lista.appendChild(nuevoElementoDD);
  2816.  
  2817. for (let i = 2; i < filas.length - 1; i++) {
  2818. let fila = filas[i];
  2819.  
  2820. let tds = fila.getElementsByTagName("td");
  2821. let as_ = tds[2].getElementsByTagName("a");
  2822. let urlObj = new URL("https://www.managerzone.com/" + as_[0].getAttribute("href"));
  2823. let params = new URLSearchParams(urlObj.search);
  2824. let pid = params.get('pid');
  2825. if (teams_[x]['inserted'][pid] === "yes") {
  2826. dato = document.createElement("td");
  2827. //aa
  2828.  
  2829. dato.innerHTML = "<img alt='' src='https://statsxente.com/MZ1/View/Images/main_icon.png' width='20px' height='20px' id='but" + pid + "' style='cursor:pointer;'/>"
  2830. fila.appendChild(dato);
  2831.  
  2832.  
  2833.  
  2834. (function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
  2835. document.getElementById("but" + currentId).addEventListener('click', function () {
  2836.  
  2837. let link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
  2838. + "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
  2839. "&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
  2840. openWindow(link, 0.95, 1.25);
  2841. });
  2842. })(pid, teams_[x]['team_id'], window.sport, window.lang, teams_[x]['team_name'], as_[0].innerHTML);
  2843.  
  2844.  
  2845. }else{
  2846. dato = document.createElement("td");
  2847. fila.appendChild(dato);
  2848. }
  2849. }
  2850. }
  2851. }
  2852. }
  2853. //Players page
  2854. async function playersPage() {
  2855. const blob = new Blob([workerCode], { type: "application/javascript" });
  2856. const workerURL = URL.createObjectURL(blob);
  2857. const worker = new Worker(workerURL);
  2858. const tacticsList = [];
  2859. const sport= window.sport
  2860. const elementos = Array.from(document.getElementsByClassName('playerContainer')).map((el) => {
  2861. const playerId = el.querySelector('.player_id_span').textContent.trim();
  2862. const age = el.querySelector('.dg_playerview_info table td').textContent.split(':')[1].trim();
  2863. const skills = Array.from(el.querySelectorAll('.skills-container .skillval')).map(skill => {
  2864. const cleanedText = skill.textContent.trim().replace(/[()]/g, ''); // Reemplaza ( y ) con ''
  2865. return parseInt(cleanedText, 10);
  2866. });
  2867.  
  2868. let tactics
  2869.  
  2870. if(sport==="soccer"){
  2871.  
  2872. tactics = Array.from(el.querySelectorAll('.player_tactic.gradientSunriseIcon'))
  2873. .map(t => ({
  2874. name: t.textContent.split('(')[0].trim(),
  2875. line: t.textContent.split('(')[1].split(')')[0].trim(),
  2876. }))
  2877. .filter((value, index, self) => {
  2878. const tacticString = `${value.name}-${value.line}`;
  2879. return self.findIndex(t => `${t.name}-${t.line}` === tacticString) === index;
  2880. });
  2881.  
  2882.  
  2883.  
  2884. }else{
  2885.  
  2886.  
  2887. tactics = Array.from(el.querySelectorAll('.player_tactic.gradientSunriseIcon'))
  2888. .map(t => {
  2889. const textContent = t.textContent.trim();
  2890. const [namePart, linePart] = textContent.split('(');
  2891.  
  2892. const name = namePart.trim();
  2893. let line = '';
  2894.  
  2895. if (linePart) {
  2896. line = linePart.replace(')', '').trim();
  2897. if (line.includes(':')) {
  2898. line = line.split(':')[0].trim();
  2899. }else{
  2900. gk_line=line
  2901. }
  2902. }
  2903.  
  2904.  
  2905. return { name, line };
  2906. })
  2907. .filter((value, index, self) => {
  2908. const tacticString = `${value.name}-${value.line}`;
  2909. return self.findIndex(t => `${t.name}-${t.line}` === tacticString) === index;
  2910. });
  2911.  
  2912. }
  2913.  
  2914.  
  2915.  
  2916.  
  2917.  
  2918. tactics.forEach(tactic => {
  2919. tacticsList.push(tactic.name);
  2920. });
  2921.  
  2922. return { id: playerId, age, skills, tactics };
  2923. });
  2924. const skillsNames = Array.from(document.querySelectorAll('.player_skills .clippable')).map(el => el.textContent.trim()).filter((value, index, self) => self.indexOf(value) === index);
  2925. let flagStats = true
  2926. let urlParams = new URLSearchParams(window.location.search);
  2927. if (urlParams.has('tid')) {
  2928. flagStats = false
  2929.  
  2930. }
  2931.  
  2932. if(flagStats){
  2933. let elementos1 = document.getElementsByClassName('playerContainer');
  2934. for (let i = 0; i < elementos1.length; i++) {
  2935. let ids = elementos1[i].getElementsByClassName('player_id_span');
  2936. let elementos_ = elementos1[i].getElementsByClassName('p_sublinks');
  2937. let txt = '<span id=but' + ids[0].textContent + ' class="player_icon_placeholder"><a href="#" onclick="return false"'
  2938. txt += 'title="Stats Xente" class="player_icon"><span class="player_icon_wrapper">'
  2939. txt += '<span class="player_icon_image" style="background-image: url(\'https://www.statsxente.com/MZ1/View/Images/main_icon_mini.png\'); width: 21px; height: 18px; background-size: auto;'
  2940. txt += 'z-index: 0;"></span><span class="player_icon_text"></span></span></a></span>'
  2941.  
  2942. let index=0
  2943. if(window.stx_device!=="computer"){index=1}
  2944. elementos_[index].innerHTML += txt;
  2945. }
  2946.  
  2947.  
  2948. }
  2949.  
  2950. if(sport==="soccer"){
  2951. skillsNames.pop();
  2952. //GK Line detect
  2953. const playerImages = document.querySelectorAll('.player-image');
  2954. const elementWithGK1 = Array.from(playerImages).find(el => {
  2955. return el.innerHTML.includes('gk=1');
  2956. });
  2957.  
  2958.  
  2959.  
  2960. let tactics1 = elementWithGK1.parentNode.getElementsByClassName("player_tactic gradientSunriseIcon")
  2961. let ini = tactics1[0].textContent.indexOf('(');
  2962. let fin = tactics1[0].textContent.indexOf(')');
  2963. gk_line = tactics1[0].textContent.substring(ini + 2, fin - 1);
  2964.  
  2965.  
  2966. }
  2967. worker.postMessage({ elementos, sport, skillsNames, tacticsList, flagStats});
  2968. worker.onmessage = function (e) {
  2969. const players=e.data.players
  2970. const lines=e.data.lines
  2971. const tacticsList=e.data.tacticsList
  2972. const skillsNames= e.data.skillsNames
  2973.  
  2974. su_line=e.data.su_line
  2975.  
  2976. if(su_line===""){
  2977. su_line="unsetted"
  2978. }
  2979.  
  2980. const container = document.getElementById("squad-search-toggle");
  2981. let contenidoNuevo = "<div id='containerTactics' style='background-color: #e3e3e3; margin: 0 auto; text-align:center;'></br>";
  2982. contenidoNuevo += "<div id=selectDiv>Choose Tactic: <select id=tactics_select>";
  2983. contenidoNuevo += "<option value='All Team' selected>All Team</option>";
  2984.  
  2985.  
  2986. for (let x = 0; x < tacticsList.length; x++) {
  2987. let selected="";
  2988. contenidoNuevo += `<option ${selected} value='${tacticsList[x]}'>${tacticsList[x]}</option>`;
  2989. }
  2990.  
  2991. contenidoNuevo += "</select></div></br><div id=divMenu></div></center></div>";
  2992. container.innerHTML = contenidoNuevo + container.innerHTML;
  2993.  
  2994. document.getElementById("tactics_select").addEventListener('change', function () {
  2995. const selectedTactic = this.value;
  2996. document.getElementById("divMenu").innerHTML = ""
  2997. skillDistrib(selectedTactic, players, lines, skillsNames,gk_line,su_line);
  2998. });
  2999.  
  3000. skillDistrib("All Team", players, lines, skillsNames,gk_line,su_line);
  3001.  
  3002.  
  3003. maximizationsPlayersPage()
  3004.  
  3005.  
  3006.  
  3007. };
  3008. }
  3009. async function maximizationsPlayersPage(){
  3010. let elementos1 = document.getElementsByClassName('weeklyReportBox weeklyReportBoxResponsive');
  3011. let elementosConBall = Array.from(elementos1).filter(el => el.innerHTML.includes('ball')&& el.innerHTML.includes('improvement'));
  3012. for (let i = 0; i < elementosConBall.length; i++) {
  3013. let improvementDiv=elementosConBall[i].getElementsByClassName("improvementLabel")
  3014. let trainedSkill=elementosConBall[i].getElementsByClassName("clippable")
  3015. let skills=elementosConBall[i].parentNode.parentNode.parentNode.parentNode.getElementsByClassName("player_skills player_skills_responsive")
  3016. let elementosConHola = Array.from(skills[0].getElementsByClassName("clippable")).filter(el => el.innerText.includes(trainedSkill[0].innerText));
  3017. let currentTd = elementosConHola[0].closest('td');
  3018. if(currentTd.nextElementSibling?.nextElementSibling?.nextElementSibling?.nextElementSibling?.nextElementSibling.innerHTML.includes("maxed")){
  3019. improvementDiv[0].style.backgroundColor="#db5d5d"
  3020. }
  3021. }
  3022. }
  3023. async function skillDistrib(tactic,players, lines, skills_names,gk_line,su_line) {
  3024. let t = tactic
  3025. let l=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  3026. if (window.sport === "hockey") {
  3027. l = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0]
  3028. }
  3029.  
  3030. let li_t = {}
  3031. for (let i = 0; i < lines.length; i++) {
  3032. li_t[lines[i]] = [...l];
  3033. }
  3034.  
  3035. let no_gk_line = "Tactic -(" + gk_line + ")"
  3036. li_t["Team"] = [...l];
  3037. li_t["U23"] = [...l];
  3038. li_t["U21"] = [...l];
  3039. li_t["U18"] = [...l];
  3040. li_t["Tactic"] = [...l];
  3041. li_t[no_gk_line] = [...l];
  3042.  
  3043. let i,j
  3044. for (i = 0; i < players.length; i++) {
  3045. if (players[i]['tactics'].includes(t)) {
  3046. for (j = 0; j < players[i]['skills'].length; j++) {
  3047. li_t[players[i]['tacticsPosition'][t]][j] += players[i]['skills'][j]
  3048. li_t['Tactic'][j] += players[i]['skills'][j]
  3049. if (players[i]['tacticsPosition'][t] !== gk_line) {
  3050. li_t[no_gk_line][j] += players[i]['skills'][j]
  3051. }
  3052. }
  3053. li_t[players[i]['tacticsPosition'][t]][j] += 1
  3054. li_t['Tactic'][j] += 1
  3055. if (players[i]['tacticsPosition'][t] !== gk_line) {
  3056. li_t[no_gk_line][j] += 1
  3057. }
  3058. } else {
  3059.  
  3060. for (let j = 0; j < players[i]['skills'].length; j++) {
  3061. if (players[i]['age'] <= 23) {
  3062. li_t['U23'][j] += players[i]['skills'][j]
  3063. }
  3064. if (players[i]['age'] <= 23) {
  3065. li_t['U21'][j] += players[i]['skills'][j]
  3066. }
  3067. if (players[i]['age'] <= 23) {
  3068. li_t['U18'][j] += players[i]['skills'][j]
  3069. }
  3070. li_t['Team'][j] += players[i]['skills'][j]
  3071. }
  3072.  
  3073. if (players[i]['age'] <= 23) {
  3074. li_t['U23'][li_t["U23"].length - 1] += 1
  3075. }
  3076.  
  3077. if (players[i]['age'] <= 21) {
  3078. li_t['U21'][li_t["U21"].length - 1] += 1
  3079. }
  3080. if (players[i]['age'] <= 18) {
  3081. li_t['U18'][li_t["U18"].length - 1] += 1
  3082. }
  3083. li_t['Team'][li_t["Team"].length - 1] += 1
  3084. }
  3085. }
  3086.  
  3087. const container = document.getElementById("divMenu")
  3088. let contenidoNuevo = "<table id=showMenu style='width:95%;font-size:13px; margin: 0 auto; text-align:center;'><thead style='background-color:" + GM_getValue("bg_native") + "; color:" + GM_getValue("color_native") + ";'><tr>";
  3089. contenidoNuevo += '<th style="padding:4px; margin: 0 auto; text-align:center;">Line</th>'
  3090. for (let q = 0; q < skills_names.length; q++) {
  3091. contenidoNuevo += '<th style="padding:4px; margin: 0 auto; text-align:center;">' + skills_names[q] + '</th>'
  3092. }
  3093. contenidoNuevo += '</tr></thead>';
  3094. let l_aux = lines
  3095. l_aux = l_aux.filter(item => item !== gk_line);
  3096. l_aux.sort((a, b) => {
  3097. let numA = parseInt(a.substring(1), 10);
  3098. let numB = parseInt(b.substring(1), 10);
  3099. return numA - numB;
  3100. });
  3101.  
  3102. l_aux.unshift(gk_line);
  3103. l_aux.push("Tactic");
  3104. l_aux.push(no_gk_line);
  3105.  
  3106. if (window.sport === "hockey") {
  3107. if (li_t["L4"][10] === 0) {
  3108. let index = l_aux.indexOf('L4');
  3109. if (index !== -1) {
  3110. l_aux.splice(index, 1);
  3111. }
  3112. }
  3113. }
  3114.  
  3115. if (t === "All Team") {
  3116. l_aux = ["Team", "U23", "U21", "U18"]
  3117. }
  3118. l_aux = l_aux.filter(item => !item.includes(su_line));
  3119.  
  3120. for (let w = 0; w < l_aux.length; w++) {
  3121. let key = l_aux[w]
  3122. if (li_t.hasOwnProperty(key)) {
  3123. contenidoNuevo += "<tr>";
  3124. contenidoNuevo += "<td style='padding:2px; margin: 0 auto; text-align:center;'><strong>" + key + "</strong></td>";
  3125. for (let x = 0; x < li_t[key].length - 1; x++) {
  3126. contenidoNuevo += "<td style='padding:2px; margin: 0 auto; text-align:center;'>" + Math.round(li_t[key][x] / li_t[key][li_t[key].length - 1] * 100) / 100 + "</td>";
  3127. }
  3128. contenidoNuevo += "</tr>";
  3129. }
  3130. }
  3131. container.innerHTML += contenidoNuevo;
  3132. }
  3133.  
  3134. //Players links to stats
  3135. async function playersPageStats() {
  3136. let element = document.getElementById('thePlayers_0');
  3137. let elementos_ = element.getElementsByClassName('p_sublinks');
  3138. let subheaders = element.getElementsByClassName('subheader clearfix');
  3139. let enlace = subheaders[0].querySelector('.subheader a');
  3140. let urlObj = new URL("https://www.managerzone.com/" + enlace.getAttribute('href'));
  3141. let params = new URLSearchParams(urlObj.search);
  3142. let tid = params.get('tid');
  3143. let playerName = enlace.querySelector('.player_name').textContent
  3144. let ids = element.getElementsByClassName('player_id_span');
  3145. let txt = '<span id=but' + ids[0].textContent + ' class="player_icon_placeholder"><a href="#" onclick="return false"'
  3146. txt += 'title="Stats Xente" class="player_icon"><span class="player_icon_wrapper">'
  3147. txt += '<span class="player_icon_image" style="background-image: url(\'https://www.statsxente.com/MZ1/View/Images/main_icon_mini.png\'); width: 21px; height: 18px; background-size: auto;'
  3148. txt += 'z-index: 0;"></span><span class="player_icon_text"></span></span></a></span>'
  3149. let index=0
  3150. if(window.stx_device!=="computer"){
  3151. index=1
  3152. }
  3153.  
  3154. elementos_[index].innerHTML += txt;
  3155. (function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
  3156. document.getElementById("but" + currentId).addEventListener('click', function () {
  3157. let link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
  3158. + "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
  3159. "&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
  3160. openWindow(link, 0.95, 1.25);
  3161. });
  3162. })(ids[0].textContent, tid, window.sport, window.lang, "[undefined]", playerName);
  3163. }
  3164. //Country ranking page
  3165. function countryRank() {
  3166. let table_values = ["players", "age", "value", "top11", "salary", "elo", "elo21", "lm", "lmu21"]
  3167. let newContent = "<div style='margin: 0 auto; text-align:center;'>";
  3168. newContent += '<label><input class="statsxente" type="checkbox" checked id="value" value="Value">Value</label>';
  3169. if (window.sport === "soccer") {
  3170. newContent += '<label><input class="statsxente" type="checkbox" id="top11" value="TOP 11">TOP 11</label>';
  3171. } else {
  3172. newContent += '<label><input class="statsxente" type="checkbox" id="top11" value="TOP 21">TOP 21</label>';
  3173. }
  3174.  
  3175. newContent += '<label><input class="statsxente" type="checkbox" id="players" value="Players">Players</label>';
  3176. newContent += '<label><input class="statsxente" type="checkbox" id="salary" value="Salary">Salary</label>';
  3177. newContent += '<label><input class="statsxente" type="checkbox" id="age" value="Age">Age</label>';
  3178. newContent += '<label><input class="statsxente" type="checkbox" checked id="elo" value="Elo">ELO</label>';
  3179. newContent += '<label><input class="statsxente" type="checkbox" checked id="elo21" value="U21 ELO">U21 ELO</label>';
  3180. newContent += '<label><input class="statsxente" type="checkbox" checked id="lm" value="LM">LM</label>';
  3181. newContent += '<label><input class="statsxente" type="checkbox" checked id="lmu21" value="U21 LM">U21 LM</label>';
  3182.  
  3183. let contenedor = document.getElementById('countryRankTable');
  3184. contenedor.insertAdjacentHTML('beforebegin', newContent);
  3185.  
  3186. GM_xmlhttpRequest({
  3187. method: "GET",
  3188. url: "https://statsxente.com/MZ1/Functions/tamper_national_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport,
  3189. headers: {
  3190. "Content-Type": "application/json"
  3191. },
  3192. onload: function (response) {
  3193. let data = JSON.parse(response.responseText);
  3194.  
  3195. let type = 1;
  3196. if (window.sport === "soccer") {
  3197. type = 2
  3198. }
  3199. let table = document.getElementById('countryRankTable');
  3200. for (let i = 0; i < table.rows.length; i++) {
  3201. let row = table.rows[i];
  3202. let insertIndex = row.cells.length - 1;
  3203. let raw_str = row.cells[3].innerHTML
  3204. row.deleteCell(3);
  3205. let cell_name = row.cells[2]
  3206. if (i > 0) {
  3207. cell_name.innerHTML = raw_str + " " + cell_name.innerHTML
  3208. }
  3209. let index = 0;
  3210. let cell0 = row.insertCell(insertIndex + index);
  3211. index++;
  3212. let cell1 = row.insertCell(insertIndex + index);
  3213. index++;
  3214. let cell2 = row.insertCell(insertIndex + index);
  3215. index++;
  3216. let cell3 = row.insertCell(insertIndex + index);
  3217. index++;
  3218. let cell4 = row.insertCell(insertIndex + index);
  3219. index++;
  3220. let cell5 = row.insertCell(insertIndex + index);
  3221. index++;
  3222. let cell6 = row.insertCell(insertIndex + index);
  3223. index++;
  3224. let cell7 = row.insertCell(insertIndex + index);
  3225. index++;
  3226. let cell8 = row.insertCell(insertIndex + index);
  3227. index++;
  3228. let cell9 = row.insertCell(insertIndex + index);
  3229.  
  3230.  
  3231.  
  3232. if (i === 0) {
  3233. cell0.outerHTML = "<th id='players_th' style='display:none;' class='header'><a href='#'>Players</a></th>";
  3234. cell1.outerHTML = "<th id='age_th' class='header' style='display:none;'><a href='#'>Age</a></th>";
  3235. cell2.outerHTML = "<th id='value_th' class='header' style='display:table-cell;'><a href='#'>Value</a></th>";
  3236. cell3.outerHTML = "<th id='top11_th' class='header' style='display:none;'><a href='#'>Top11</a></th>";
  3237. cell4.outerHTML = "<th id='salary_th' class='header' style='display:none;'><a href='#'>Salary</a></th>";
  3238. cell5.outerHTML = "<th id='elo_th' class='header' style='display:table-cell;'><a href='#'>ELO</a></th>";
  3239. cell6.outerHTML = "<th id='elo21_th' class='header' style='display:table-cell;'><a href='#'>U21 ELO</a></th>";
  3240. cell7.outerHTML = "<th id='lm_th' class='header' style='display:table-cell;'><a href='#'>LM</a></th>";
  3241. cell8.outerHTML = "<th id='lmu21_th' class='header' style='display:table-cell;'><a href='#'>U21 LM</a></th>";
  3242. cell9.outerHTML = "<th id='image' class='header' style='display:table-cell;'><a href='#'></a></th>";
  3243. } else {
  3244. let ini = raw_str.indexOf("s_");
  3245. let fin = raw_str.indexOf(".", ini + 1);
  3246. let c_code = raw_str.substring(ini + 2, fin)
  3247. cell0.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["numJugadores"]))
  3248. cell0.className = "players"
  3249. cell0.style.display = "none"
  3250.  
  3251. cell1.innerHTML = new Intl.NumberFormat(window.userLocal, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(data[c_code]["edad"])
  3252. cell1.className = "age"
  3253. cell1.style.display = "none"
  3254.  
  3255. cell2.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valor"]))
  3256. cell2.className = "value"
  3257. cell2.style.display = "table-cell"
  3258.  
  3259. cell3.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valor11"]))
  3260. cell3.className = "top11"
  3261. cell3.style.display = "none"
  3262.  
  3263. cell4.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["salario"]))
  3264. cell4.className = "salary"
  3265. cell4.style.display = "none"
  3266.  
  3267. cell5.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["elo"]))
  3268. cell5.className = "elo"
  3269. cell5.style.display = "table-cell"
  3270.  
  3271. cell6.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["elo21"]))
  3272. cell6.className = "elo21"
  3273. cell6.style.display = "table-cell"
  3274.  
  3275. cell7.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valorLM"]))
  3276. cell7.className = "lm"
  3277. cell7.style.display = "table-cell"
  3278.  
  3279. cell8.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valorLM21"]))
  3280. cell8.className = "lmu21"
  3281. cell8.style.display = "table-cell"
  3282.  
  3283. cell9.innerHTML = '<img alt="" style="cursor:pointer;" src="https://statsxente.com/MZ1/View/Images/calendar.png" width="20" height="20">'
  3284. let actual_id = "image" + i
  3285. cell9.id = actual_id
  3286. cell9.style.display = "table-cell";
  3287.  
  3288.  
  3289. (function (id, code, type_) {
  3290. document.getElementById(id).addEventListener('click', function () {
  3291. let link = "https://www.statsxente.com/MZ1/Graficos/graficoRachaEquipoELONT.php?tamper=yes&team_id=" + data[code]["idSenior"] +
  3292. "&team_id_u21=" + data[code]["idSub21"] + "&idioma=" + window.lang + "&type=" + type_ + "&cat=SENIOR&sport=" + window.sport;
  3293. openWindow(link, 0.95, 1.25);
  3294. });
  3295. })(actual_id, c_code, type);
  3296. }
  3297. }
  3298.  
  3299. setTimeout(function () {
  3300. for (let f = 0; f < table_values.length; f++) {
  3301.  
  3302. (function (actual_value, f) {
  3303.  
  3304. document.getElementById(actual_value + "_th").addEventListener('click', function () {
  3305. if (document.getElementById(actual_value + "_th").className === "header") {
  3306. document.getElementById(actual_value + "_th").className = "header headerSortDown";
  3307. } else {
  3308.  
  3309. if (document.getElementById(actual_value + "_th").className === "header headerSortDown") {
  3310. document.getElementById(actual_value + "_th").className = "header headerSortUp";
  3311. } else {
  3312. document.getElementById(actual_value + "_th").className = "header headerSortDown";
  3313. }
  3314.  
  3315. }
  3316. let index_ = 3 + f
  3317. ordenarTabla(index_, false, "countryRankTable",false)
  3318. });
  3319. document.getElementById(actual_value).addEventListener('click', function () {
  3320. let display = "table-cell"
  3321. if (document.getElementById(actual_value + "_th").style.display === "table-cell") {
  3322. display = "none"
  3323. }
  3324. let elementos = document.getElementsByClassName(actual_value)
  3325. Array.prototype.forEach.call(elementos, function (elemento) {
  3326. let aux_display = "table-cell"
  3327. if (document.getElementById(actual_value + "_th").style.display === "table-cell") {
  3328. aux_display = "none"
  3329. }
  3330. elemento.style.display = aux_display;
  3331. });
  3332. document.getElementById(actual_value + "_th").style.display = display
  3333. });
  3334. })(table_values[f], f);
  3335. }
  3336. }, 1000);
  3337. }
  3338. });
  3339. }
  3340. //Stats Xente competitions matches
  3341. function StatsXenteNextMatchesClubhouse() {
  3342. let h1Elements = document.querySelectorAll('h1.box_dark');
  3343. let team_name = h1Elements[0].innerText
  3344. let team_id = document.getElementById("tid1").value;
  3345.  
  3346. GM_xmlhttpRequest({
  3347. method: "GET",
  3348. url: "https://statsxente.com/MZ1/Functions/tamper_user_next_matches.php?team_id=" + team_id,
  3349. headers: {
  3350. "Content-Type": "application/json"
  3351. },
  3352. onload: function (response) {
  3353. let data = JSON.parse(response.responseText);
  3354. if (data.length > 0) {
  3355.  
  3356.  
  3357. GM_xmlhttpRequest({
  3358. method: "GET",
  3359. url: "http://www.managerzone.com/xml/team_matchlist.php?sport_id=" + window.sport_id + "&team_id=" + team_id + "&match_status=2&limit=100",
  3360. headers: {
  3361. "Content-Type": "application/json"
  3362. },
  3363. onload: function (response) {
  3364.  
  3365. let matchesDate = []
  3366. let parser = new DOMParser();
  3367. let xmlDoc = parser.parseFromString(response.responseText, "text/xml");
  3368. let matches = xmlDoc.getElementsByTagName("Match");
  3369.  
  3370. let last_date = ""
  3371.  
  3372.  
  3373. for (let i = 0; i < matches.length; i++) {
  3374. let dateOnly = matches[i].getAttribute("date").split(" ")[0];
  3375. last_date = dateOnly
  3376. let teams = matches[i].getElementsByTagName("Team");
  3377.  
  3378. for (let j = 0; j < teams.length; j++) {
  3379. if (teams[j].getAttribute("teamId") !== team_id) {
  3380. matchesDate.push(teams[j].getAttribute("teamId") + "-" + dateOnly)
  3381.  
  3382. }
  3383. }
  3384.  
  3385.  
  3386. }
  3387.  
  3388.  
  3389.  
  3390.  
  3391. let newContent = `
  3392. <div id="tour-container" class="widgets-container">
  3393. <div class="flex-wrap hub-widget-container">
  3394. <div class="flex-grow-1 box_dark">
  3395. <div id="clubhouse-widget-tour" class="widget-content clearfix">
  3396. <i class="fa minimize-button fa-minus-square" aria-hidden="true" data-time="1722549599"></i>
  3397. <span class="fa fa-stack fa-2x floatRight">
  3398. <i class="fa fa-circle fa-stack-2x fa-inverse"></i>
  3399. <i class="fa fa-thumbs-up fa-stack-1x green" aria-hidden="true"></i>
  3400. </span>
  3401. <h3 style="background-image: url('https://www.statsxente.com/MZ1/View/Images/main_icon.png');">Stats Xente</h3>
  3402. <div class="widget-content-wrapper">
  3403. <div class="flex-wrap" style="margin-bottom: 35px;">
  3404. <div class="flex-grow-0" style="margin: 0 auto">
  3405. <img src="https://www.statsxente.com/MZ1/View/Images/main_icon.png" alt="" width="130" height="130">
  3406. </div>
  3407. <div class="flex-grow-1 textLeft">`
  3408.  
  3409. data.forEach(function (match_data) {
  3410.  
  3411. let dateObj1 = new Date(last_date);
  3412. let dateObj2 = new Date(match_data['fecha']);
  3413.  
  3414.  
  3415. let icon_ = "fa-check-square"
  3416. let style_ = ""
  3417. let flagFriendly = false;
  3418. if (dateObj1 < dateObj2) {
  3419. icon_ = "fa-calendar-minus-o"
  3420. style_ = "style='color:#e5ac00;'"
  3421. flagFriendly = true;
  3422. } else {
  3423.  
  3424. if (matchesDate.includes(match_data['rival_id'] + "-" + match_data['fecha'])) {
  3425. if (window.sport === "hockey") {
  3426. style_ = "style='color:#6d93fd;'"
  3427. }
  3428. } else {
  3429. icon_ = "fa-times-square"
  3430. style_ = "style='color:#AD4039;'"
  3431. flagFriendly = true;
  3432.  
  3433.  
  3434. }
  3435.  
  3436. }
  3437.  
  3438.  
  3439. let match = '<img alt="" src="https://www.managerzone.com/dynimg/badge.php?team_id=' + match_data['idEquipoLocal'] + '&sport="' + window.sport + ' width="15px" height="15px"/> '
  3440. + team_name + ' - ' + match_data['rival_name'] + ' <img alt="" src="https://www.managerzone.com/dynimg/badge.php?team_id=' + match_data['idEquipoVisitante'] + '&sport="' + window.sport + ' width="15px" height="15px"/>'
  3441. if (match_data['field'] === "away") {
  3442. match = '<img alt="" src="https://www.managerzone.com/dynimg/badge.php?team_id=' + match_data['idEquipoLocal'] + '&sport="' + window.sport + ' width="15px" height="15px"/> '
  3443. + match_data['rival_name'] + ' - ' + team_name + ' <img alt="" src="https://www.managerzone.com/dynimg/badge.php?team_id=' + match_data['idEquipoVisitante'] + '&sport="' + window.sport + ' width="15px" height="15px"/>'
  3444. }
  3445.  
  3446.  
  3447. newContent += '<fieldset class="grouping self box_light_on_dark flex-nowrap" style="max-width: 555px; margin-left: 10px;">'
  3448. newContent += '<legend>' + match_data['clash_name'] + '</legend>'
  3449. newContent += '<div class="flex-grow-0 mission-icon">'
  3450. newContent += '<i class="fa ' + icon_ + ' green fa-2x t-checked" aria-hidden="true" ' + style_ + '></i>'
  3451. newContent += '</div>'
  3452. newContent += '<div class="flex-grow-1 mission">'
  3453.  
  3454. let link = "CompAmis_CALENDAR_View.php?" + 'id=' + match_data['idComp']
  3455. if (match_data['comp'] === "cup") {
  3456. link = 'CompAmis_Cup_CALENDAR_View.php?grupo=' + match_data['grupo'] + '&id=' + match_data['idComp']
  3457. }
  3458.  
  3459.  
  3460. newContent += '<p><b><a href="https://www.statsxente.com/MZ1/View/' + link + '" target="_blank">' + match + '</a></b>'
  3461. newContent += "</br></p>"
  3462. newContent += 'Date: ' + match_data['fecha']
  3463. if (flagFriendly) {
  3464. newContent += "<a href='https://www.managerzone.com/?p=challenges&challenge-tid=" + match_data['rival_id'] + "'><i class='fa fa-thumbs-up fa-lg challenge-thumb' aria-hidden='true'></i></a>"
  3465. }
  3466.  
  3467.  
  3468. newContent += '</p>'
  3469. newContent += '</div>'
  3470. newContent += '</fieldset>'
  3471. });
  3472.  
  3473.  
  3474.  
  3475.  
  3476. newContent += `</div>
  3477. </div>
  3478. </div>
  3479. </div>
  3480. </div>
  3481. </div>
  3482. </div>`;
  3483.  
  3484.  
  3485.  
  3486.  
  3487. let contenedor = document.getElementById('tour-container');
  3488. if (data.length > 0) {
  3489. contenedor.insertAdjacentHTML('beforebegin', newContent);
  3490.  
  3491. }
  3492.  
  3493.  
  3494. }
  3495.  
  3496. });
  3497.  
  3498. }
  3499.  
  3500.  
  3501. }
  3502. });
  3503.  
  3504. }
  3505.  
  3506.  
  3507.  
  3508. //HANDLERS FUNCTIONS
  3509. function handleClick(event) {
  3510.  
  3511. if(document.getElementById("eloCompareCol")){
  3512. document.getElementById("trELOCompare").style.display="none";
  3513. let elems = document.getElementsByClassName("nice_table");
  3514. let table = elems[0]
  3515. let th = document.getElementById("eloCompareCol");
  3516. let columnIndex = th.cellIndex;
  3517. for (let i = 0; i < table.rows.length; i++) {
  3518. let row = table.rows[i];
  3519. if (row.cells.length > columnIndex) {
  3520. row.deleteCell(columnIndex);
  3521. }
  3522. }
  3523. }
  3524.  
  3525. let urlParams = new URLSearchParams(window.location.search);
  3526. let elems = document.getElementsByClassName("nice_table");
  3527. let tabla = elems[0]
  3528. let filas = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  3529. let thSegundo = tabla.querySelector("thead th:nth-child(2)");
  3530.  
  3531. if (urlParams.get('fsid')) {
  3532. thSegundo.style.width = "180px";
  3533. } else {
  3534. thSegundo.style.width = "250px";
  3535. }
  3536.  
  3537.  
  3538. for (let i = 0; i < filas.length; i++) {
  3539. if (checkClassNameExists(filas[i], searchClassName)) {
  3540. let celda = filas[i].cells[1];
  3541. let team_data=extractTeamData(celda.getElementsByTagName("a"));
  3542. let id=team_data[0]
  3543. let celdas = filas[i].getElementsByTagName("td");
  3544. let ultimaCelda = celdas[celdas.length - 2];
  3545. let selects = document.getElementsByTagName('select');
  3546. let index_select = 1;
  3547. if (selects[index_select] === undefined) {
  3548. index_select = 0;
  3549. }
  3550.  
  3551.  
  3552. let selectedIndex = selects[index_select].selectedIndex;
  3553. let selectedOption = selects[index_select].options[selectedIndex];
  3554. let selectedText = selectedOption.text;
  3555.  
  3556.  
  3557.  
  3558. let key_actual_league = "Top";
  3559. if (selectedText.includes(".")) {
  3560. key_actual_league = selectedText.substring(0, 4)
  3561. }
  3562.  
  3563. let valor = 0;
  3564.  
  3565. if (teams_data[id] === undefined) {
  3566. valor = 0
  3567. } else {
  3568.  
  3569. let table_key = "";
  3570. let agg_value = 0;
  3571. let cat
  3572.  
  3573. switch (event.target.id) {
  3574. case 'edad':
  3575. valor = new Intl.NumberFormat(window.userLocal, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(teams_data[id][event.target.id])
  3576. break;
  3577. case "leagues":
  3578. table_key = "league"
  3579. agg_value = teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3580. valor = "(" + teams_data[id]['league_' + key_actual_league] + '/' + agg_value + ")"
  3581. break;
  3582.  
  3583. case "world_leagues":
  3584. table_key = "world_league"
  3585. agg_value = teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3586. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  3587. break;
  3588.  
  3589. case "youth_leagues":
  3590. cat = GM_getValue("actual_league_cat").toLowerCase()
  3591. table_key = "league_" + cat
  3592. agg_value = teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3593. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  3594. break;
  3595.  
  3596. case "world_youth_leagues":
  3597. cat = GM_getValue("actual_league_cat").toLowerCase()
  3598. table_key = "world_league_" + cat
  3599. agg_value = teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3600. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  3601. break;
  3602.  
  3603. case "leagues_all":
  3604. table_key = "league"
  3605. valor = teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3606. break;
  3607.  
  3608.  
  3609. case "world_leagues_all":
  3610. table_key = "world_league"
  3611. valor = teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3612. break;
  3613.  
  3614. case "youth_leagues_all":
  3615. table_key = "league_u23"
  3616. valor += teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3617. table_key = "league_u21"
  3618. valor += teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3619. table_key = "league_u18"
  3620. valor += teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3621. break;
  3622.  
  3623. case "world_youth_leagues_all":
  3624. table_key = "world_league_u23"
  3625. valor += teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3626. table_key = "world_league_u21"
  3627. valor += teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3628. table_key = "world_league_u18"
  3629. valor += teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3630. break;
  3631.  
  3632. case "federation_leagues":
  3633. table_key = "federation_league"
  3634. agg_value = teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3635. valor = agg_value
  3636. break;
  3637.  
  3638.  
  3639. default:
  3640. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(teams_data[id][event.target.id]))
  3641. break;
  3642.  
  3643.  
  3644. }
  3645. }
  3646.  
  3647. ultimaCelda.innerHTML = valor;
  3648. }
  3649. }
  3650. let checkboxes = document.querySelectorAll('.statsxente');
  3651. let thead = tabla.querySelector('thead');
  3652. let tr = thead.querySelectorAll('tr');
  3653. let td = tr[0].querySelectorAll('th');
  3654. td[td.length - 2].textContent = event.target.value;
  3655. checkboxes.forEach(function (checkbox) {
  3656. if (checkbox.id !== event.target.id) {
  3657. checkbox.checked = false;
  3658. }
  3659. });
  3660. }
  3661. function handleClickClash(event) {
  3662. let elems = document.getElementsByClassName("nice_table");
  3663. let tabla = elems[0]
  3664. let filas = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  3665. let thSegundo = tabla.querySelector("thead th:nth-child(2)");
  3666. thSegundo.style.width = "250px";
  3667. for (let i = 0; i < filas.length; i++) {
  3668. let celda = tabla.rows[i + 1].cells[1];
  3669. let imagen = celda.querySelector('img');
  3670. let url = new URL(imagen.src);
  3671. let id = url.searchParams.get('fid');
  3672.  
  3673.  
  3674. let celdas = filas[i].getElementsByTagName("td");
  3675. let ultimaCelda = celdas[celdas.length - 2];
  3676.  
  3677. let valor = 0;
  3678.  
  3679. if (teams_data[id] === undefined) {
  3680. valor = 0
  3681. } else {
  3682. if (event.target.id === "edad") {
  3683. valor = new Intl.NumberFormat(window.userLocal, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(teams_data[id][event.target.id])
  3684. } else {
  3685. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(teams_data[id][event.target.id]))
  3686. }
  3687.  
  3688. }
  3689.  
  3690. ultimaCelda.innerHTML = valor;
  3691. }
  3692. let checkboxes = document.querySelectorAll('.statsxente');
  3693. let thead = tabla.querySelector('thead');
  3694. let tr = thead.querySelectorAll('tr');
  3695. let td = tr[0].querySelectorAll('th');
  3696. td[td.length - 2].textContent = event.target.value;
  3697. checkboxes.forEach(function (checkbox) {
  3698. if (checkbox.id !== event.target.id) {
  3699. checkbox.checked = false;
  3700. }
  3701. });
  3702. }
  3703. function handleClickUserRank(event) {
  3704. let tabla = document.getElementById("userRankTable");
  3705. let filas = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  3706.  
  3707. for (let i = 0; i < filas.length; i++) {
  3708. let celda = filas[i].cells[3];
  3709. let team_data=extractTeamData(celda.getElementsByTagName("a"));
  3710. let id=team_data[0]
  3711. let equipo=team_data[1]
  3712. let celdas = filas[i].getElementsByTagName("td");
  3713. let ultimaCelda = celdas[celdas.length - 1];
  3714. let selects = document.getElementsByTagName('select');
  3715. let index_select = 1;
  3716. if (selects[index_select] === undefined) {
  3717. index_select = 0;
  3718. }
  3719.  
  3720.  
  3721. let selectedIndex = selects[index_select].selectedIndex;
  3722. let selectedOption = selects[index_select].options[selectedIndex];
  3723. let selectedText = selectedOption.text;
  3724.  
  3725.  
  3726.  
  3727. let key_actual_league = "Top";
  3728. if (selectedText.includes(".")) {
  3729. key_actual_league = selectedText.substring(0, 4)
  3730. }
  3731.  
  3732. let valor = 0;
  3733.  
  3734. if (teams_data[id] === undefined) {
  3735. valor = 0
  3736. } else {
  3737.  
  3738. let table_key = "";
  3739. let agg_value = 0;
  3740. let cat
  3741.  
  3742. switch (event.target.id) {
  3743. case 'edad':
  3744. valor = new Intl.NumberFormat(window.userLocal, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(teams_data[id][event.target.id])
  3745. break;
  3746. case "leagues":
  3747. table_key = "league"
  3748. agg_value = teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3749. valor = "(" + teams_data[id]['league_' + key_actual_league] + '/' + agg_value + ")"
  3750. break;
  3751.  
  3752. case "world_leagues":
  3753. table_key = "world_league"
  3754. agg_value = teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3755. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  3756. break;
  3757.  
  3758. case "youth_leagues":
  3759. cat = GM_getValue("actual_league_cat").toLowerCase()
  3760. table_key = "league_" + cat
  3761. agg_value = teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3762. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  3763. break;
  3764.  
  3765. case "world_youth_leagues":
  3766. cat = GM_getValue("actual_league_cat").toLowerCase()
  3767. table_key = "world_league_" + cat
  3768. agg_value = teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3769. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  3770. break;
  3771.  
  3772. case "leagues_all":
  3773. table_key = "league"
  3774. valor = teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3775. break;
  3776.  
  3777.  
  3778. case "world_leagues_all":
  3779. table_key = "world_league"
  3780. valor = teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3781. break;
  3782.  
  3783. case "youth_leagues_all":
  3784. table_key = "league_u23"
  3785. valor += teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3786. table_key = "league_u21"
  3787. valor += teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3788. table_key = "league_u18"
  3789. valor += teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3790. break;
  3791.  
  3792. case "world_youth_leagues_all":
  3793. table_key = "world_league_u23"
  3794. valor += teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3795. table_key = "world_league_u21"
  3796. valor += teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3797. table_key = "world_league_u18"
  3798. valor += teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3799. break;
  3800.  
  3801. case "federation_leagues":
  3802. table_key = "federation_league"
  3803. agg_value = teams_data[id][table_key + '_Top'] + teams_data[id][table_key + '_div1'] + teams_data[id][table_key + '_div2'] + teams_data[id][table_key + '_div3'] + teams_data[id][table_key + '_div4'] + teams_data[id][table_key + '_div5']
  3804. valor = agg_value
  3805. break;
  3806.  
  3807.  
  3808. default:
  3809. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(teams_data[id][event.target.id]))
  3810. break;
  3811.  
  3812.  
  3813. }
  3814. }
  3815.  
  3816. ultimaCelda.innerHTML = valor;
  3817.  
  3818. }
  3819. let checkboxes = document.querySelectorAll('.statsxente');
  3820. let thead = tabla.querySelector('thead');
  3821. let tr = thead.querySelectorAll('tr');
  3822. let td = tr[0].querySelectorAll('th');
  3823. td[td.length - 1].innerHTML = '<a href="#">'+event.target.value+'</a>'
  3824. checkboxes.forEach(function (checkbox) {
  3825. if (checkbox.id !== event.target.id) {
  3826. checkbox.checked = false;
  3827. }
  3828. });
  3829. }
  3830.  
  3831. //FETCH FUNCTIONS
  3832. function fetchExistsFL(id) {
  3833. return new Promise((resolve, reject) => {
  3834.  
  3835. GM_xmlhttpRequest({
  3836. method: "GET",
  3837. url: "https://statsxente.com/MZ1/Functions/tamper_check_fl.php?fl_id="+id,
  3838. headers: {
  3839. "Content-Type": "application/json"
  3840. },
  3841. onload: function (response) {
  3842. let jsonResponse = JSON.parse(response.responseText);
  3843. resolve(jsonResponse)
  3844. },
  3845. onerror: function () {
  3846. reject("none");
  3847. }
  3848. });
  3849. });
  3850. }
  3851. function fetchAgeRestriction(url) {
  3852. return new Promise((resolve, reject) => {
  3853.  
  3854. GM_xmlhttpRequest({
  3855. method: "GET",
  3856. url: url,
  3857. headers: {
  3858. "Content-Type": "application/json"
  3859. },
  3860. onload: function (response) {
  3861. let parser = new DOMParser();
  3862. let doc = parser.parseFromString(response.responseText, "text/html");
  3863. let strongElements = doc.getElementsByTagName("b");
  3864. let nextSibling = strongElements[1].nextSibling;
  3865. try {
  3866. while (nextSibling && nextSibling.nodeName === "BR") {
  3867. nextSibling = nextSibling.nextSibling;
  3868. }
  3869.  
  3870. if (nextSibling && nextSibling.nodeType === Node.TEXT_NODE) {
  3871. let age_restriction = nextSibling.textContent.trim();
  3872. resolve(age_restriction);
  3873. } else {
  3874. resolve("none");
  3875. }
  3876. } catch (error) {
  3877. reject("none");
  3878. }
  3879. },
  3880. onerror: function () {
  3881. reject("none");
  3882. }
  3883. });
  3884. });
  3885. }
  3886. function fetchCupAgeRestriction(url) {
  3887. return new Promise((resolve, reject) => {
  3888.  
  3889. GM_xmlhttpRequest({
  3890. method: "GET",
  3891. url: url,
  3892. headers: {
  3893. "Content-Type": "application/json"
  3894. },
  3895. onload: function (response) {
  3896. let parser = new DOMParser();
  3897. try {
  3898. let doc = parser.parseFromString(response.responseText, "text/html")
  3899. let tables = doc.getElementsByTagName("table");
  3900. let table = tables[1]
  3901. let tds = table.getElementsByTagName("td");
  3902. resolve(tds[5].innerHTML)
  3903. } catch (error) {
  3904. reject("none");
  3905. }
  3906. },
  3907. onerror: function () {
  3908. reject("none");
  3909. }
  3910. });
  3911. });
  3912. }
  3913. function fetchExistTeam(url) {
  3914. return new Promise((resolve, reject) => {
  3915.  
  3916. GM_xmlhttpRequest({
  3917. method: "GET",
  3918. url: url,
  3919. headers: {
  3920. "Content-Type": "application/json"
  3921. },
  3922. onload: function (response) {
  3923. let jsonResponse = JSON.parse(response.responseText);
  3924. resolve(jsonResponse['inserted'])
  3925. },
  3926. onerror: function () {
  3927. reject("no");
  3928. }
  3929. });
  3930. });
  3931. }
  3932. function fetchExistPlayers(url) {
  3933. return new Promise((resolve, reject) => {
  3934.  
  3935. GM_xmlhttpRequest({
  3936. method: "GET",
  3937. url: url,
  3938. headers: {
  3939. "Content-Type": "application/json"
  3940. },
  3941. onload: function (response) {
  3942. let jsonResponse = JSON.parse(response.responseText);
  3943. resolve(jsonResponse)
  3944. },
  3945. onerror: function () {
  3946. reject("no");
  3947. }
  3948. });
  3949. });
  3950. }
  3951.  
  3952. function fetchAndProcessPlayerData(link,skill,toChange,device) {
  3953. return new Promise((resolve, reject) => {
  3954.  
  3955. GM_xmlhttpRequest({
  3956. method: 'GET',
  3957. url:link,
  3958. onload: function (response) {
  3959.  
  3960. let parser = new DOMParser();
  3961. let doc = parser.parseFromString(response.responseText, 'text/html');
  3962.  
  3963. let player_cointainer=doc.getElementById("thePlayers_0")
  3964.  
  3965. let elements = player_cointainer.querySelectorAll('.skillval');
  3966. elements.forEach(element => {
  3967.  
  3968. let previousTd = element.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling;
  3969. let maxs = element.getElementsByClassName("maxed")
  3970.  
  3971. let clips = previousTd.getElementsByClassName("clippable")
  3972. if((clips[0].innerText.trim()===skill.trim())&&(maxs.length>0)){
  3973.  
  3974. if(device!=="computer"){
  3975. toChange.style.padding="3px"
  3976. }
  3977. toChange.style.backgroundColor="#db5d5d"
  3978. toChange.style.fontWeight="bold"
  3979. toChange.style.borderRadius="5px"
  3980.  
  3981.  
  3982. }
  3983.  
  3984.  
  3985. });
  3986. resolve("Done")
  3987. },
  3988. onerror: function (error) {
  3989. reject(error);
  3990. }
  3991. });
  3992.  
  3993. }
  3994. );
  3995.  
  3996. }
  3997.  
  3998. //UTILS FUNCTIONS
  3999. function waitToDOM(function_to_execute, classToSearch, elementIndex,miliseconds) {
  4000. let interval = setInterval(function () {
  4001. let elements = document.querySelectorAll(classToSearch);
  4002. if (elements.length > 0 && elements[elementIndex]) {
  4003. clearInterval(interval);
  4004. clearTimeout(timeout);
  4005. function_to_execute();
  4006. }
  4007. }, 100);
  4008.  
  4009.  
  4010. let timeout = setTimeout(function () {
  4011. clearInterval(interval);
  4012. }, miliseconds);
  4013. }
  4014. function waitToDOMById(function_to_execute, idToSearch,miliseconds) {
  4015. let interval = setInterval(function () {
  4016. let element = document.getElementById(idToSearch);
  4017. if (element) {
  4018. clearInterval(interval);
  4019. clearTimeout(timeout);
  4020. function_to_execute();
  4021. }
  4022. }, 100);
  4023.  
  4024.  
  4025. let timeout = setTimeout(function () {
  4026. clearInterval(interval);
  4027. }, miliseconds);
  4028. }
  4029. function openWindow(link, porAncho, porAlto) {
  4030. let ventanaAncho = (window.innerWidth) * porAncho
  4031. let ventanaAlto = (window.innerHeight) * porAlto
  4032. let ventanaIzquierda = (window.innerWidth - ventanaAncho) / 2;
  4033. let ventanaArriba = (window.innerHeight - ventanaAlto) / 2;
  4034. let opcionesVentana = "width=" + ventanaAncho +
  4035. ",height=" + ventanaAlto +
  4036. ",left=" + ventanaIzquierda +
  4037. ",top=" + ventanaArriba;
  4038.  
  4039. if ((GM_getValue("tabsConfig") === false) && (GM_getValue("windowsConfig") === true)) {
  4040. window.open(link, "_blank", opcionesVentana);
  4041. }
  4042. if ((GM_getValue("tabsConfig") === true) && (GM_getValue("windowsConfig") === false)) {
  4043. window.open(link, "_blank");
  4044. }
  4045. }
  4046. function ordenarTabla(col, byClassName, param,putSortIconFlag) {
  4047. let table
  4048. if (byClassName) {
  4049. let elems = document.getElementsByClassName(param);
  4050. table = elems[0]
  4051. } else {
  4052. table = document.getElementById(param)
  4053. }
  4054. if(putSortIconFlag){putSortIcon(col, table)}
  4055. let rows = Array.from(table.tBodies[0].rows);
  4056. let isAsc = document.getElementById("ord_table").value === "ascendente";
  4057. rows.sort(function (a, b) {
  4058. let aNum = parseFloat(a.cells[col].textContent.trim().replace(/\./g, '').replace(/,/g, '')) || 0;
  4059. let bNum = parseFloat(b.cells[col].textContent.trim().replace(/\./g, '').replace(/,/g, '')) || 0;
  4060. return isAsc ? aNum - bNum : bNum - aNum;
  4061. });
  4062.  
  4063. rows.forEach(function (row) {
  4064. table.tBodies[0].appendChild(row);
  4065. });
  4066.  
  4067. if (isAsc) {
  4068. document.getElementById("ord_table").value = "descendente";
  4069. } else {
  4070. document.getElementById("ord_table").value = "ascendente";
  4071. }
  4072.  
  4073. let filas = table.getElementsByTagName("tr");
  4074. for (let i = 1; i < filas.length; i++) {
  4075. let primeraCelda = filas[i].getElementsByTagName("td")[0];
  4076. primeraCelda.textContent = i;
  4077. }
  4078.  
  4079.  
  4080. }
  4081. function ordenarTablaText(col, byClassName, param,putSortIconFlag) {
  4082. let table = document.getElementById(param)
  4083. let rows = Array.from(table.tBodies[0].rows);
  4084. let isAsc = document.getElementById("ord_table").value === "ascendente";
  4085. if(putSortIconFlag){putSortIcon(col, table)}
  4086. rows.sort(function (a, b) {
  4087. let aText = a.cells[col].textContent.toLowerCase().trim();
  4088. let bText = b.cells[col].textContent.toLowerCase().trim();
  4089. if (aText < bText) {
  4090. return isAsc ? -1 : 1;
  4091. }
  4092. if (aText > bText) {
  4093. return isAsc ? 1 : -1;
  4094. }
  4095. return 0;
  4096. });
  4097.  
  4098. rows.forEach(function (row) {
  4099. table.tBodies[0].appendChild(row);
  4100. });
  4101.  
  4102. if (isAsc) {
  4103. document.getElementById("ord_table").value = "descendente";
  4104. } else {
  4105. document.getElementById("ord_table").value = "ascendente";
  4106. }
  4107.  
  4108.  
  4109. let filas = table.getElementsByTagName("tr");
  4110. for (let i = 1; i < filas.length; i++) {
  4111. let primeraCelda = filas[i].getElementsByTagName("td")[0];
  4112. primeraCelda.textContent = i;
  4113. }
  4114.  
  4115. }
  4116. function checkClassNameExists(element, className) {
  4117. if (className === "") {
  4118. return true;
  4119. } else {
  4120. return element.classList.contains(className);
  4121. }
  4122. }
  4123. function getCookie(nombre) {
  4124. let regex = new RegExp("(?:(?:^|.*;\\s*)" + nombre + "\\s*\\=\\s*([^;]*).*$)|^.*$");
  4125. let valorCookie = document.cookie.replace(regex, "$1");
  4126. return decodeURIComponent(valorCookie);
  4127. }
  4128. function generateValuesSelect(cat) {
  4129.  
  4130.  
  4131. let defaults = new Map();
  4132. defaults.set('senior', 'valor');
  4133. defaults.set('u23', 'valor23');
  4134. defaults.set('u21', 'valor21');
  4135. defaults.set('u18', 'valor18');
  4136.  
  4137. let values = new Map();
  4138. values.set('valor', 'Value');
  4139. values.set('valor23', 'U23 Value');
  4140. values.set('valor21', 'U21 Value');
  4141. values.set('valor18', 'U18 Value');
  4142. values.set('salario', 'Salary');
  4143. values.set('valorUPSenior', 'LM Value');
  4144. values.set('valorUPSUB23', 'U23 LM Value');
  4145. values.set('valorUPSUB21', 'U21 LM Value');
  4146. values.set('valorUPSUB18', 'U18 LM Value');
  4147. values.set('edad', 'Age');
  4148. values.set('valor11', 'TOP 11/21');
  4149. values.set('valor11_23', 'U23 TOP 11/21');
  4150. values.set('valor11_21', 'U21 TOP 11/21');
  4151. values.set('valor11_18', 'U18 TOP 11/21');
  4152. values.set('noNac', 'Foreigners');
  4153. values.set('elo', 'ELO Score');
  4154. values.set('elo23', 'U23 ELO Score');
  4155. values.set('elo21', 'U21 ELO Score');
  4156. values.set('elo18', 'U18 ELO Score');
  4157. values.set('numJugadores', 'Number of players');
  4158.  
  4159.  
  4160. let default_value = GM_getValue("league_default_" + cat, defaults.get(cat))
  4161. GM_setValue("league_default_" + cat, default_value)
  4162.  
  4163. let select = "<select id='league_default_select_" + cat + "' style='width:9em;'>";
  4164. values.forEach((valor, clave) => {
  4165. let checked = ""
  4166. if (clave === default_value) {
  4167. checked = "selected"
  4168. }
  4169. select += "<option " + checked + " value='" + clave + "'>" + valor + "</option>";
  4170. });
  4171. select += "</select>"
  4172. return select;
  4173.  
  4174. }
  4175. function createLeagueConfigOptionsListeners() {
  4176.  
  4177. let defaults = new Map();
  4178. defaults.set('senior', 'valor');
  4179. defaults.set('u23', 'valor23');
  4180. defaults.set('u21', 'valor21');
  4181. defaults.set('u18', 'valor18');
  4182.  
  4183.  
  4184.  
  4185. defaults.forEach((valor, clave) => {
  4186.  
  4187.  
  4188.  
  4189. document.getElementById("league_default_select_" + clave).addEventListener('change', function () {
  4190.  
  4191. let selectElement = document.getElementById("league_default_select_" + clave);
  4192. GM_setValue("league_default_" + clave, selectElement.value)
  4193. });
  4194.  
  4195. });
  4196. document.getElementById("league_graph_check").addEventListener('click', function () {
  4197.  
  4198. if (document.getElementById("league_graph_check").checked) {
  4199. GM_setValue("league_graph_button", "checked")
  4200. } else {
  4201. GM_setValue("league_graph_button", "")
  4202. }
  4203.  
  4204.  
  4205. });
  4206.  
  4207.  
  4208. document.getElementById("league_report_check").addEventListener('click', function () {
  4209.  
  4210. if (document.getElementById("league_report_check").checked) {
  4211. GM_setValue("league_report_button", "checked")
  4212. } else {
  4213. GM_setValue("league_report_button", "")
  4214. }
  4215.  
  4216.  
  4217. });
  4218.  
  4219. document.getElementById("league_calendar_check").addEventListener('click', function () {
  4220.  
  4221. if (document.getElementById("league_calendar_check").checked) {
  4222. GM_setValue("league_calendar_button", "checked")
  4223. } else {
  4224. GM_setValue("league_calendar_button", "")
  4225. }
  4226.  
  4227.  
  4228. });
  4229.  
  4230.  
  4231.  
  4232.  
  4233.  
  4234.  
  4235. }
  4236. function createModalMenu() {
  4237. let newElement = document.createElement("div");
  4238. newElement.id = "legendDiv";
  4239. newElement.className = "stx_legend";
  4240. let txtToInsert= '<div style="writing-mode: tb-rl;-webkit-writing-mode: vertical-rl; margin: 0 auto; text-align:center;">'
  4241. if(GM_getValue("available_new_version")==="yes"){
  4242. txtToInsert+='<img alt="" src="https://statsxente.com/MZ1/View/Images/alert.png" style="width:15px;height:15px;"/>'
  4243. }
  4244. txtToInsert+='<img alt="" src="https://statsxente.com/MZ1/View/Images/main_icon.png" style="width:25px;height:25px;"/>'
  4245. txtToInsert+='</div>';
  4246. newElement.innerHTML=txtToInsert;
  4247. let body = document.body;
  4248. body.appendChild(newElement);
  4249.  
  4250. let newModalElement = document.createElement('div');
  4251. newModalElement.innerHTML = '<div id="snackbar_stx" style="margin: 0 auto; text-align:center;"></div><div id="myModal_cargando" class="modal_cargando"><div class="modal-content_cargando" id="modal_content_div_cargando"><div id="contenido_modal_cargando" style="overflow-x:auto; background-color:#f2f2f200;"></div></div></div>'
  4252. body.insertBefore(newModalElement, body.firstChild);
  4253.  
  4254. if (GM_getValue("leagueFlag") === undefined) {
  4255. GM_setValue("leagueFlag", true)
  4256. }
  4257.  
  4258. if (GM_getValue("matchFlag") === undefined) {
  4259. GM_setValue("matchFlag", true)
  4260. }
  4261.  
  4262. if (GM_getValue("federationFlag") === undefined) {
  4263. GM_setValue("federationFlag", true)
  4264. }
  4265.  
  4266. if (GM_getValue("playersFlag") === undefined) {
  4267. GM_setValue("playersFlag", true)
  4268. }
  4269.  
  4270. if (GM_getValue("countryRankFlag") === undefined) {
  4271. GM_setValue("countryRankFlag", true)
  4272. }
  4273.  
  4274.  
  4275. if (GM_getValue("league_graph_button") === undefined) {
  4276. GM_setValue("league_graph_button", "checked")
  4277. }
  4278.  
  4279. if (GM_getValue("league_report_button") === undefined) {
  4280. GM_setValue("league_report_button", "checked")
  4281. }
  4282.  
  4283. if (GM_getValue("league_calendar_button") === undefined) {
  4284. GM_setValue("league_calendar_button", "checked")
  4285. }
  4286.  
  4287. if (GM_getValue("windowsConfig") === undefined) {
  4288. GM_setValue("windowsConfig", true)
  4289. }
  4290.  
  4291. if (GM_getValue("tabsConfig") === undefined) {
  4292. GM_setValue("tabsConfig", false)
  4293. }
  4294.  
  4295. if (GM_getValue("show_league_selects") === undefined) {
  4296. GM_setValue("show_league_selects", true)
  4297. }
  4298.  
  4299. if (GM_getValue("league_image_size") === undefined) {
  4300. GM_setValue("league_image_size", 20)
  4301. }
  4302.  
  4303. if (GM_getValue("eloNextMatchesFlag") === undefined) {
  4304. GM_setValue("eloNextMatchesFlag", true)
  4305. }
  4306.  
  4307. if (GM_getValue("eloPlayedMatchesFlag") === undefined) {
  4308. GM_setValue("eloPlayedMatchesFlag", true)
  4309. }
  4310.  
  4311. if (GM_getValue("teamPageFlag") === undefined) {
  4312. GM_setValue("teamPageFlag", true)
  4313. }
  4314.  
  4315. if (GM_getValue("trainingReportFlag") === undefined) {
  4316. GM_setValue("trainingReportFlag", true)
  4317. }
  4318.  
  4319.  
  4320.  
  4321.  
  4322.  
  4323.  
  4324. let leagueFlag = "", matchFlag = "", federationFlag = "", playersFlag = "", countryRankFlag = "",eloNextMatchesFlag="",eloPlayedMatchesFlag="",teamFlag="",trainingReportFlag=""
  4325.  
  4326. if (GM_getValue("federationFlag")) federationFlag = "checked"
  4327. if (GM_getValue("matchFlag")) matchFlag = "checked"
  4328. if (GM_getValue("leagueFlag")) leagueFlag = "checked"
  4329. if (GM_getValue("playersFlag")) playersFlag = "checked"
  4330. if (GM_getValue("countryRankFlag")) countryRankFlag = "checked"
  4331. if (GM_getValue("eloNextMatchesFlag")) eloNextMatchesFlag = "checked"
  4332. if (GM_getValue("eloPlayedMatchesFlag")) eloPlayedMatchesFlag = "checked"
  4333. if (GM_getValue("teamPageFlag")) teamFlag = "checked"
  4334.  
  4335. if (GM_getValue("trainingReportFlag")) trainingReportFlag = "checked"
  4336.  
  4337.  
  4338.  
  4339.  
  4340.  
  4341. let newContent = '<div style="margin: 0 auto; text-align:center;"><img alt="" id="closeButton" src="https://statsxente.com/MZ1/View/Images/error.png" style="width:40px; height:40px; cursor:pointer;"/></div></br></br>'
  4342. newContent += '<div style="margin: 0 auto; text-align:center;" id=alert_tittle class="caja_mensaje_50">Config</div><div id="div1" class="modal_div_content_main" style="display: flex; flex-direction: column; overflow: auto; max-width: 100%;">'
  4343. newContent +='</br><table style="width:75%; margin: 0 auto; text-align:left;"><tbody><tr>';
  4344. newContent += '<td><label class="containerPeqAmarillo">League<input type="checkbox" id="leagueSelect" ' + leagueFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  4345. newContent += '<td><label class="containerPeqAmarillo">Federation<input type="checkbox" id="federationSelect" ' + federationFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  4346. newContent += '<td><label class="containerPeqAmarillo">Match<input type="checkbox" id="matchSelect" ' + matchFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  4347. newContent += '<td><label class="containerPeqAmarillo">ELO Played Matches<input type="checkbox" id="eloPlayedSelect" ' + eloPlayedMatchesFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  4348. newContent += '<td><label class="containerPeqAmarillo">Training Report<input type="checkbox" id="trainingReportSelect" ' + trainingReportFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  4349. newContent += '</tr><tr>'
  4350. newContent += '<td><label class="containerPeqAmarillo">Players<input type="checkbox" id="playersSelect" ' + playersFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  4351. newContent += '<td><label class="containerPeqAmarillo">Country Rank<input type="checkbox" id="countryRankSelect" ' + countryRankFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  4352. newContent += '<td><label class="containerPeqAmarillo">Team<input type="checkbox" id="teamSelect" ' + teamFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  4353. newContent += '<td><label class="containerPeqAmarillo">ELO Scheduled Matches<input type="checkbox" id="eloScheduledSelect" ' + eloNextMatchesFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  4354.  
  4355. newContent += "</tr></tbody></table>"
  4356.  
  4357. newContent += "<hr>"
  4358. newContent += "<h3 style='text-align: left; padding-left:7px;'>Leagues Config</h3>"
  4359.  
  4360. newContent += "<table style='margin: 0 auto; text-align:center;'><tr>"
  4361. newContent += "<td>Default Senior Param: <td>" + generateValuesSelect('senior') + "</td>";
  4362. newContent += "<td>Default U23 Param: <td>" + generateValuesSelect('u23') + "</td>";
  4363. newContent += "<td>Default U21 Param: <td>" + generateValuesSelect('u21') + "</td>";
  4364. newContent += "<td>Default U18 Param: <td>" + generateValuesSelect('u18') + "</td>";
  4365.  
  4366. newContent += "</tr><tr>"
  4367.  
  4368.  
  4369. let checked_graph = GM_getValue("league_graph_button")
  4370. let checked_report = GM_getValue("league_report_button")
  4371. let checked_calendar = GM_getValue("league_calendar_button")
  4372.  
  4373. newContent += "<td style='margin: 0 auto; text-align:center;' colspan='8'><table style='margin: 0 auto; text-align:center;'><tr><td><label><input " + checked_graph + " type='checkbox' value='graph' class='textMiddle' id='league_graph_check'><img alt='' class='textMiddle' src='https://statsxente.com/MZ1/View/Images/graph.png' width='20px' height='20px'/> <span class='textMiddle'>Progress</span></label></td>"
  4374. newContent += "<td style='margin: 0 auto; text-align:center;'><label><input " + checked_report + " type='checkbox' value='graph' id='league_report_check' class='textMiddle'><img alt='' class='textMiddle' src='https://statsxente.com/MZ1/View/Images/report.png' width='20px' height='20px'/> <span class='textMiddle'>Graph</span></label></td>"
  4375.  
  4376. newContent += "<td style='margin: 0 auto; text-align:center;'><label><input " + checked_calendar + " type='checkbox' value='graph' id='league_calendar_check' class='textMiddle'><img alt='' class='textMiddle' src='https://statsxente.com/MZ1/View/Images/calendar.png' width='20px' height='20px'/> <span class='textMiddle'>ELO Matches</span></label></td></tr></table></td>"
  4377.  
  4378. newContent += '</tr><tr>';
  4379.  
  4380. newContent += '<td colspan="4"><label><span class="textMiddle">Icons Size</span> <input class="textMiddle" id="slider_input" class="range-slider_input" type="range" value="' + GM_getValue("league_image_size") + '" min="10" max="30">'
  4381. newContent += '<img alt="" class="textMiddle" id="testImage" src="https://statsxente.com/MZ1/View/Images/calendar.png" width="20px" height="20px"/>'
  4382. newContent += '<span class="textMiddle" style="padding-left:10px;" id="sizeImageLeagueSpan"> (' + GM_getValue("league_image_size") + ')</span></label></center></td>'
  4383.  
  4384.  
  4385.  
  4386. let checkedLeagueSelects = ""
  4387. if (GM_getValue("show_league_selects")) {
  4388. checkedLeagueSelects = "checked"
  4389. }
  4390.  
  4391. newContent += '<td style=\'margin: 0 auto; text-align:center;\' colspan="4"><label class="textMiddle"><input ' + checkedLeagueSelects + ' type="checkbox" class="textMiddle" value="graph" id="show_league_checkbox">Show selects</label></center></td>'
  4392. newContent += "</tr></table>"
  4393. newContent += "<hr>"
  4394. newContent += "<h3 style='text-align: left; padding-left:7px;'>Tabs Config</h3>"
  4395. newContent += "<table style='display:flex;'><tr><td>"
  4396.  
  4397. let checkedTab = ""
  4398. if (GM_getValue("tabsConfig")) {
  4399. checkedTab = "checked"
  4400. }
  4401.  
  4402. let checkedWin = ""
  4403. if (GM_getValue("windowsConfig")) {
  4404. checkedWin = "checked"
  4405. }
  4406.  
  4407.  
  4408. newContent += "<label><input type='checkbox' id='windowsConfig' " + checkedWin + ">Windows</label>";
  4409. newContent += "<label><input type='checkbox' id='tabsConfig' " + checkedTab + ">Tabs</label>";
  4410. newContent += "</td></tr></table></br></br>"
  4411.  
  4412. if(GM_getValue("available_new_version")==="yes"){
  4413. newContent += '<div style="padding-bottom:10px; margin: 0 auto; text-align:center;"><h2>New vesion available: '+GM_getValue("stx_latest_version")+'</h2>'
  4414. newContent += '<button class="btn-update" id="updateButton"><i class="bi bi-arrow-down-circle-fill" style="font-style:normal;"> Update</i></button></div>'
  4415. }
  4416.  
  4417.  
  4418.  
  4419.  
  4420.  
  4421. newContent += '<div style="padding-bottom:10px; margin: 0 auto; text-align:center;"><button class="btn-save" id="saveButton"><i class="bi bi-house-door-fill" style="font-style:normal;">Save</i></button><button id="deleteButton" class="btn-delete" style="margin-left:10px;"><i class="bi bi-trash-fill" style="font-style:normal;">Reset</i></button></div>'
  4422. newContent += '</div></center></br></br>';
  4423. document.getElementById("contenido_modal_cargando").innerHTML = newContent
  4424. createLeagueConfigOptionsListeners();
  4425. document.getElementById("contenido_modal_cargando").style.width = "75%";
  4426. document.getElementById("myModal_cargando").style.display = "none"
  4427. getNativeTableStyles()
  4428.  
  4429. document.getElementById("alert_tittle").style.backgroundColor = GM_getValue("bg_native")
  4430.  
  4431. if(GM_getValue("available_new_version")==="yes"){
  4432.  
  4433. document.getElementById("updateButton").addEventListener('click', function () {
  4434. GM_setValue("date_checked_version","-")
  4435. window.open("https://update.greasyfork.org/scripts/491442/Stats%20Xente%20Script.user.js", "_blank");
  4436. });
  4437. }
  4438.  
  4439.  
  4440.  
  4441.  
  4442.  
  4443. document.getElementById("legendDiv").addEventListener('click', function () {
  4444.  
  4445. if (document.getElementById("myModal_cargando").style.display === "none") {
  4446. document.getElementById("myModal_cargando").style.display = "flex";
  4447. } else {
  4448. document.getElementById("myModal_cargando").style.display = "none";
  4449. }
  4450.  
  4451. });
  4452.  
  4453.  
  4454. document.getElementById("closeButton").addEventListener('click', function () {
  4455. document.getElementById("myModal_cargando").style.display = "none";
  4456. });
  4457.  
  4458.  
  4459. document.getElementById("saveButton").addEventListener('click', function () {
  4460. window.location.reload();
  4461. });
  4462.  
  4463.  
  4464.  
  4465.  
  4466. (function () {
  4467. document.getElementById("deleteButton").addEventListener('click', function () {
  4468. let keys = GM_listValues();
  4469. keys.forEach(function (key) {
  4470. GM_deleteValue(key);
  4471. });
  4472. window.location.reload();
  4473. });
  4474. })();
  4475.  
  4476.  
  4477.  
  4478.  
  4479.  
  4480. // }, 3000);
  4481.  
  4482. }
  4483. function getNativeTableStyles() {
  4484. let elemento = document.querySelector('.subheader.clearfix');
  4485. if (elemento) {
  4486. let estilo = getComputedStyle(elemento);
  4487. let bg = estilo.backgroundColor
  4488. let color = "white"
  4489. if (estilo.backgroundColor === "rgba(0, 0, 0, 0)") {
  4490. bg = "#a9b0b4"
  4491. }
  4492. GM_setValue("bg_native", bg)
  4493. GM_setValue("color_native", color)
  4494. }
  4495.  
  4496.  
  4497. }
  4498. function getDeviceFormat(){
  4499. const script = document.createElement('script');
  4500. script.textContent = `
  4501. let newElement = document.createElement("input");
  4502. newElement.id= "deviceFormatStx";
  4503. newElement.type = "hidden";
  4504. newElement.value=window.device;
  4505. let body = document.body;
  4506. body.appendChild(newElement);
  4507.  
  4508. `;
  4509. document.documentElement.appendChild(script);
  4510. script.remove();
  4511.  
  4512. window.stx_device=document.getElementById("deviceFormatStx").value
  4513. }
  4514. function extractTeamData(as){
  4515. let main_a=""
  4516. Array.from(as).forEach(a => {
  4517. if (a.href.includes('tid')) {
  4518. main_a=a
  4519. }
  4520. })
  4521. let href = main_a.getAttribute('href');
  4522. let urlParams = new URLSearchParams(href.split('?')[1]);
  4523. return [urlParams.get('tid'),main_a.textContent]
  4524.  
  4525. }
  4526. function createModalEventListeners() {
  4527. document.getElementById('leagueSelect').addEventListener('click', function () {
  4528. GM_setValue("leagueFlag", !GM_getValue("leagueFlag"))
  4529. });
  4530.  
  4531.  
  4532. document.getElementById('federationSelect').addEventListener('click', function () {
  4533. GM_setValue("federationFlag", !GM_getValue("federationFlag"))
  4534. });
  4535.  
  4536. document.getElementById('matchSelect').addEventListener('click', function () {
  4537. GM_setValue("matchFlag", !GM_getValue("matchFlag"))
  4538. });
  4539.  
  4540. document.getElementById('playersSelect').addEventListener('click', function () {
  4541. GM_setValue("playersFlag", !GM_getValue("playersFlag"))
  4542. });
  4543.  
  4544. document.getElementById('countryRankSelect').addEventListener('click', function () {
  4545. GM_setValue("countryRankFlag", !GM_getValue("countryRankFlag"))
  4546. });
  4547.  
  4548. document.getElementById('eloPlayedSelect').addEventListener('click', function () {
  4549.  
  4550. GM_setValue("eloPlayedMatchesFlag", !GM_getValue("eloPlayedMatchesFlag"))
  4551. });
  4552.  
  4553. document.getElementById('eloScheduledSelect').addEventListener('click', function () {
  4554. GM_setValue("eloNextMatchesFlag", !GM_getValue("eloNextMatchesFlag"))
  4555. });
  4556.  
  4557. document.getElementById('teamSelect').addEventListener('click', function () {
  4558. GM_setValue("teamPageFlag", !GM_getValue("teamPageFlag"))
  4559. });
  4560.  
  4561. document.getElementById('trainingReportSelect').addEventListener('click', function () {
  4562. GM_setValue("trainingReportFlag", !GM_getValue("trainingReportFlag"))
  4563. });
  4564.  
  4565.  
  4566.  
  4567.  
  4568. document.getElementById('show_league_checkbox').addEventListener('click', function () {
  4569. GM_setValue("show_league_selects", !GM_getValue("show_league_selects"))
  4570. });
  4571.  
  4572.  
  4573.  
  4574. document.getElementById('windowsConfig').addEventListener('click', function () {
  4575.  
  4576. document.getElementById('tabsConfig').checked = !document.getElementById('windowsConfig').checked;
  4577.  
  4578. GM_setValue("windowsConfig", !GM_getValue("windowsConfig"))
  4579. GM_setValue("tabsConfig", !GM_getValue("tabsConfig"))
  4580.  
  4581.  
  4582. });
  4583.  
  4584.  
  4585. document.getElementById('tabsConfig').addEventListener('click', function () {
  4586. document.getElementById('windowsConfig').checked = !document.getElementById('tabsConfig').checked;
  4587. GM_setValue("windowsConfig", !GM_getValue("windowsConfig"))
  4588. GM_setValue("tabsConfig", !GM_getValue("tabsConfig"))
  4589.  
  4590.  
  4591. });
  4592.  
  4593.  
  4594.  
  4595.  
  4596.  
  4597. (function () {
  4598. document.getElementById("slider_input").addEventListener('input', function () {
  4599. document.getElementById("testImage").style.width = document.getElementById("slider_input").value + "px";
  4600. document.getElementById("testImage").style.height = document.getElementById("slider_input").value + "px";
  4601.  
  4602. document.getElementById("sizeImageLeagueSpan").innerText = "(" + document.getElementById("slider_input").value + ")"
  4603.  
  4604.  
  4605. GM_setValue("league_image_size", document.getElementById("slider_input").value)
  4606.  
  4607.  
  4608. });
  4609. })();
  4610.  
  4611. }
  4612. function setLangSportCats() {
  4613.  
  4614. let langs = new Map();
  4615. langs.set('es', 'SPANISH');
  4616. langs.set('ar', 'SPANISH')
  4617. langs.set('en', 'ENGLISH');
  4618. langs.set('br', 'PORTUGUES');
  4619. langs.set('pt', 'PORTUGUES');
  4620. langs.set('pl', 'POLISH');
  4621. langs.set('ro', 'ROMANIAN');
  4622. langs.set('tr', 'TURKISH');
  4623.  
  4624. let lanCookie = getCookie("MZLANG");
  4625. if (langs.has(lanCookie)) {
  4626. window.lang = langs.get(lanCookie);
  4627. } else {
  4628. window.lang = "ENGLISH";
  4629. }
  4630.  
  4631. let sportCookie = getCookie("MZSPORT");
  4632.  
  4633. if(sportCookie===""){
  4634. sportCookie=getSportByLink()
  4635. }
  4636.  
  4637. if(sportCookie===""){
  4638. sportCookie=getSportByScript()
  4639. }
  4640.  
  4641. let lsport = "F"
  4642. let sport_id = 1;
  4643. if (sportCookie === "hockey") {
  4644. lsport = "H";
  4645. sport_id = 2;
  4646. }
  4647.  
  4648. let cats = {};
  4649. cats["senior"] = "senior";
  4650. cats["world"] = "seniorw";
  4651. cats["u23"] = "SUB23";
  4652. cats["u21"] = "SUB21";
  4653. cats["u18"] = "SUB18";
  4654. cats["u23_world"] = "SUB23w";
  4655. cats["u21_world"] = "SUB21w";
  4656. cats["u18_world"] = "SUB18w";
  4657.  
  4658.  
  4659. window.cats = cats;
  4660. window.sport = sportCookie;
  4661. window.lsport = lsport;
  4662. window.sport_id = sport_id;
  4663. window.userLocal = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.language;
  4664.  
  4665. }
  4666. function getSportByLink(){
  4667. let element = document.getElementById("settings-wrapper");
  4668. if (element) {
  4669. var firstLink = element.getElementsByTagName("a")[0];
  4670. if (firstLink) {
  4671. if(firstLink.href.includes("soccer")){
  4672. return "hockey"
  4673. }else{
  4674. return "soccer"
  4675. }
  4676. }
  4677. }
  4678. }
  4679. function getSportByScript(){
  4680. const script = document.createElement('script');
  4681. script.textContent = `
  4682. let newElement = document.createElement("input");
  4683. newElement.id= "stx_sport";
  4684. newElement.type = "hidden";
  4685. newElement.value=window.ajaxSport;
  4686. let body = document.body;
  4687. body.appendChild(newElement);
  4688.  
  4689. `;
  4690. document.documentElement.appendChild(script);
  4691. script.remove();
  4692. return document.getElementById("stx_sport").value
  4693. }
  4694.  
  4695. function getUsernameData() {
  4696. if ((GM_getValue("currency") === undefined) || (GM_getValue("currency") === "")
  4697. ||(GM_getValue("soccer_team_id") === undefined) || (GM_getValue("soccer_team_id") === "")
  4698. ||(GM_getValue("hockey_team_id") === undefined) || (GM_getValue("hockey_team_id") === "")) {
  4699. let username = document.getElementById("header-username").innerText
  4700. GM_xmlhttpRequest({
  4701. method: "GET",
  4702. url: "http://www.managerzone.com/xml/manager_data.php?sport_id=" + window.sport_id + "&username=" + username,
  4703. headers: {
  4704. "Content-Type": "application/json"
  4705. },
  4706. onload: function (response) {
  4707.  
  4708. let parser = new DOMParser();
  4709. let xmlDoc = parser.parseFromString(response.responseText, "text/xml");
  4710. let userTeamsData = xmlDoc.getElementsByTagName("Team");
  4711. let index = 1;
  4712.  
  4713. if (userTeamsData[0].getAttribute("sport")==="soccer"){
  4714. GM_setValue("soccer_team_id", userTeamsData[0].getAttribute("teamId"))
  4715. }
  4716. if (userTeamsData[0].getAttribute("sport")==="hockey"){
  4717. GM_setValue("hockey_team_id", userTeamsData[0].getAttribute("teamId"))
  4718. }
  4719.  
  4720.  
  4721. if (userTeamsData[1].getAttribute("sport")==="soccer"){
  4722. GM_setValue("soccer_team_id", userTeamsData[1].getAttribute("teamId"))
  4723. }
  4724. if (userTeamsData[1].getAttribute("sport")==="hockey"){
  4725. GM_setValue("hockey_team_id", userTeamsData[1].getAttribute("teamId"))
  4726. }
  4727.  
  4728.  
  4729.  
  4730. if (userTeamsData[0].getAttribute("sport") === window.sport) {
  4731. index = 0;
  4732. }
  4733. GM_xmlhttpRequest({
  4734. method: "GET",
  4735. url: "http://www.managerzone.com/xml/team_playerlist.php?sport_id=" + window.sport_id + "&team_id=" + userTeamsData[index].getAttribute("teamId"),
  4736. headers: {
  4737. "Content-Type": "application/json"
  4738. },
  4739. onload: function (response) {
  4740. let parser = new DOMParser();
  4741. let xmlDoc = parser.parseFromString(response.responseText, "text/xml");
  4742. let team_data = xmlDoc.getElementsByTagName("TeamPlayers");
  4743. GM_setValue("currency", team_data[0].getAttribute("teamCurrency"))
  4744. }
  4745. });
  4746. }
  4747. });
  4748.  
  4749. }
  4750.  
  4751.  
  4752. }
  4753. function getActualDate(){
  4754. const fechaActual = new Date();
  4755. const year = fechaActual.getFullYear();
  4756. const month = String(fechaActual.getMonth() + 1).padStart(2, '0');
  4757. const day = String(fechaActual.getDate()).padStart(2, '0');
  4758. return `${year}-${month}-${day}`;
  4759. }
  4760. function compareVersions(installedVersion, latestVersion) {
  4761. const installedParts = installedVersion.split('.').map(Number);
  4762. const latestParts = latestVersion.split('.').map(Number);
  4763. for (let i = 0; i < Math.max(installedParts.length, latestParts.length); i++) {
  4764. const installed = installedParts[i] || 0;
  4765. const latest = latestParts[i] || 0;
  4766. if (installed < latest) {
  4767. GM_setValue("available_new_version","yes")
  4768. notifySnackBarNewVersion()
  4769. }else{
  4770. GM_setValue("available_new_version","no")
  4771. }
  4772. }
  4773.  
  4774. }
  4775. function getParsedValidDateText(text){
  4776. let initialDate="undefined"
  4777. let fecha=text
  4778. if(fecha.includes("-")){
  4779.  
  4780. let [day, month, year] = fecha.split("-");
  4781. initialDate = `${year}-${month}-${day}`;
  4782. }
  4783. if(fecha.includes("/")){
  4784. let [day, month, year] = fecha.split("/");
  4785. initialDate = `${year}-${month}-${day}`;
  4786.  
  4787. }
  4788.  
  4789. return initialDate
  4790.  
  4791.  
  4792.  
  4793. }
  4794. function getParsedValidDate(texto) {
  4795. let fecha = new Date(texto);
  4796. if (!isNaN(fecha.getTime())) {
  4797. return fecha.toISOString().split('T')[0];
  4798. } else {
  4799. let hoy = new Date();
  4800. hoy.setDate(hoy.getDate() - 5);
  4801. return hoy.toISOString().split('T')[0];
  4802. }
  4803. }
  4804. function notifySnackBarNewVersion(){
  4805. if(GM_getValue("stx_notified_version")!==GM_getValue("stx_latest_version")){
  4806. GM_setValue("stx_notified_version",GM_getValue("stx_latest_version"))
  4807. let x = document.getElementById("snackbar_stx");
  4808. let txt = "<img alt='' src='https://statsxente.com/MZ1/View/Images/main_icon.png' width='25px' height='25px'> <span style='color:#2da8ef; font-size: 17px;'>Stats Xente Script: </span>New version available</br></br>"
  4809. txt+="<button type='button' id='button-snackbar-update'>UPDATE</button>"
  4810. x.innerHTML = txt;
  4811. x.className = "showSnackBar_stx";
  4812. document.getElementById("button-snackbar-update").addEventListener('click', function () {
  4813. GM_setValue("date_checked_version","-")
  4814. window.open("https://update.greasyfork.org/scripts/491442/Stats%20Xente%20Script.user.js", "_blank");
  4815. });
  4816. setTimeout(function () { x.className = x.className.replace("showSnackBar_stx", ""); }, 8000);
  4817. }
  4818. }
  4819. async function checkScriptVersion(){
  4820. const actual_date=getActualDate()
  4821. if(actual_date!==GM_getValue("date_checked_version")){
  4822. GM_setValue("date_checked_version", actual_date)
  4823. const greasyForkURL = 'https://greasyfork.org/es/scripts/491442-stats-xente-script';
  4824. fetch(greasyForkURL)
  4825. .then(response => response.text())
  4826. .then(data => {
  4827. const parser = new DOMParser();
  4828. const doc = parser.parseFromString(data, 'text/html');
  4829. const versionElement = doc.querySelector('dd.script-show-version');
  4830. const latestVersion = versionElement ? versionElement.textContent.trim() : 'No se encontró versión';
  4831. const installedVersion = GM_info.script.version;
  4832. GM_setValue("stx_latest_version",latestVersion)
  4833. compareVersions(installedVersion, latestVersion);
  4834. })
  4835. .catch(error => {
  4836. console.error('Error al obtener la versión del script:', error);
  4837. });
  4838.  
  4839.  
  4840.  
  4841. }
  4842.  
  4843. }
  4844. function putSortIcon(a, tabla_) {
  4845. let filaEncabezado = tabla_.querySelector('thead tr');
  4846. let celdas = filaEncabezado.getElementsByTagName('th');
  4847. if (celdas.length === 0) {
  4848. celdas = filaEncabezado.getElementsByTagName('td');
  4849. }
  4850. let elementos = tabla_.querySelectorAll('.bi.bi-arrow-down-short');
  4851. elementos.forEach(function (elemento) {
  4852. elemento.remove();
  4853. })
  4854.  
  4855. elementos = tabla_.querySelectorAll('.bi.bi-arrow-up-short');
  4856. elementos.forEach(function (elemento) {
  4857. elemento.remove();
  4858. })
  4859.  
  4860.  
  4861.  
  4862. let iconAsc = '<svg class="bi bi-arrow-up-short" xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="12" height="12" viewBox="0 0 320 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M182.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-128 128c-9.2 9.2-11.9 22.9-6.9 34.9s16.6 19.8 29.6 19.8l256 0c12.9 0 24.6-7.8 29.6-19.8s2.2-25.7-6.9-34.9l-128-128z"/></svg>'
  4863. let iconDesc = '<svg class="bi bi-arrow-down-short" xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="12" height="12" viewBox="0 0 320 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M182.6 470.6c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-9.2-9.2-11.9-22.9-6.9-34.9s16.6-19.8 29.6-19.8l256 0c12.9 0 24.6 7.8 29.6 19.8s2.2 25.7-6.9 34.9l-128 128z"/></svg>'
  4864.  
  4865. let icon = iconAsc;
  4866. if (document.getElementById("ord_table").value === "descendente") {
  4867. icon = iconDesc;
  4868. }
  4869.  
  4870.  
  4871. celdas[a].innerHTML = icon + celdas[a].innerHTML;
  4872. }
  4873. function ordenarTablaq(columna, byClassName, param) {
  4874. let tabla
  4875. if (byClassName) {
  4876. let elems = document.getElementsByClassName(param);
  4877. tabla = elems[0]
  4878. } else {
  4879. tabla = document.getElementById(param)
  4880. }
  4881. let filas, switching, i, x, y, debeCambiar, direccion, cambioRealizado;
  4882. switching = true;
  4883. direccion = document.getElementById("ord_table").value
  4884. while (switching) {
  4885. switching = false;
  4886. filas = tabla.rows;
  4887. for (i = 1; i < (filas.length - 1); i++) {
  4888. debeCambiar = false;
  4889. x = filas[i].getElementsByTagName("td")[columna];
  4890. y = filas[i + 1].getElementsByTagName("td")[columna];
  4891. let xValue = parseFloat(x.innerHTML.replace(/\./g, "").replace(/[^0-9,-]+/g, "").replace(",", "."));
  4892. let yValue = parseFloat(y.innerHTML.replace(/\./g, "").replace(/[^0-9,-]+/g, "").replace(",", "."));
  4893. if (direccion === "ascendente") {
  4894. if (isNaN(xValue)) {
  4895. if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
  4896. debeCambiar = true;
  4897. break;
  4898. }
  4899. } else {
  4900. if (xValue > yValue) {
  4901. debeCambiar = true;
  4902. break;
  4903. }
  4904. }
  4905. } else if (direccion === "descendente") {
  4906. if (isNaN(xValue)) {
  4907. if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) {
  4908. debeCambiar = true;
  4909. break;
  4910. }
  4911. } else {
  4912. if (xValue < yValue) {
  4913. debeCambiar = true;
  4914. break;
  4915. }
  4916. }
  4917. }
  4918. }
  4919.  
  4920.  
  4921.  
  4922. if (debeCambiar) {
  4923. filas[i].parentNode.insertBefore(filas[i + 1], filas[i]);
  4924. switching = true;
  4925. cambioRealizado = true;
  4926. } else {
  4927. if (!cambioRealizado && direccion === "descendente") {
  4928. //direccion = "ascendente";
  4929. switching = true;
  4930. }
  4931. }
  4932. }
  4933.  
  4934. if (document.getElementById("ord_table").value === "descendente") {
  4935. document.getElementById("ord_table").value = "ascendente";
  4936. } else {
  4937. document.getElementById("ord_table").value = "descendente";
  4938. }
  4939.  
  4940.  
  4941. filas = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  4942. for (i = 0; i < filas.length; i++) {
  4943. let primerTd = filas[i].querySelector("td");
  4944. primerTd.innerHTML = (i + 1);
  4945. }
  4946. }
  4947. function darkenColor(rgb, percent) {
  4948. let result = rgb.match(/\d+/g);
  4949.  
  4950. // Convertir los valores RGB a enteros
  4951. let r = parseInt(result[0]);
  4952. let g = parseInt(result[1]);
  4953. let b = parseInt(result[2]);
  4954. // Reducir cada componente en un porcentaje
  4955. r = Math.floor(r * (1 - percent / 100));
  4956. g = Math.floor(g * (1 - percent / 100));
  4957. b = Math.floor(b * (1 - percent / 100));
  4958.  
  4959. // Asegurarse de que los valores estén dentro del rango válido (0-255)
  4960. r = Math.max(0, Math.min(255, r));
  4961. g = Math.max(0, Math.min(255, g));
  4962. b = Math.max(0, Math.min(255, b));
  4963.  
  4964. // Convertir de vuelta a hexadecimal y retornar el valor oscuro
  4965. return "#" + [r, g, b].map(x => {
  4966. const hex = x.toString(16);
  4967. return hex.length === 1 ? "0" + hex : hex;
  4968. }).join("");
  4969. }
  4970. function setCSSStyles(){
  4971. let link = document.createElement('link');
  4972. link.href = 'https://fonts.googleapis.com/css?family=Roboto&display=swap';
  4973. link.rel = 'stylesheet';
  4974.  
  4975. let link1 = document.createElement('link');
  4976. link1.href = 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css';
  4977. link1.rel = 'stylesheet';
  4978. document.head.appendChild(link)
  4979. document.head.appendChild(link1)
  4980.  
  4981. let inputHidden = document.createElement('input');
  4982. inputHidden.type = 'hidden';
  4983. inputHidden.id = 'ord_table';
  4984. inputHidden.value = 'ascendente';
  4985. document.body.appendChild(inputHidden);
  4986. GM_addStyle(`#snackbar_stx {
  4987. visibility: hidden;
  4988. position: fixed;
  4989. /*display: flex;*/
  4990. align-items: center;
  4991. left: 50%;
  4992. transform: translate(-50%, -50%);
  4993. min-width: 350px;
  4994. background-color: #323232;
  4995. color: #ffffffb3;
  4996. text-align: center;
  4997. border-radius: 2px;
  4998. padding: 16px;
  4999. z-index: 1;
  5000. bottom: 30px;
  5001. font-size: 17px;
  5002. border-radius: 5px;
  5003. box-shadow: 0 3px 5px -1px #0003, 0 6px 10px #00000024, 0 1px 18px #0000001f;
  5004. }
  5005.  
  5006. #snackbar_stx.showSnackBar_stx {
  5007. visibility: visible;
  5008. -webkit-animation: fadein 0.5s, fadeout 0.5s 8s forwards;
  5009. animation: fadein 0.5s, fadeout 0.5s 8s forwards;
  5010. }
  5011.  
  5012. @-webkit-keyframes fadein {
  5013. from {bottom: 0; opacity: 0;}
  5014. to {bottom: 30px; opacity: 1;}
  5015. }
  5016.  
  5017. @keyframes fadein {
  5018. from {bottom: 0; opacity: 0;}
  5019. to {bottom: 30px; opacity: 1;}
  5020. }
  5021.  
  5022. @-webkit-keyframes fadeout {
  5023. from {bottom: 30px; opacity: 1;}
  5024. to {bottom: 0; opacity: 0;}
  5025. }
  5026.  
  5027. @keyframes fadeout {
  5028. from {bottom: 30px; opacity: 1;}
  5029. to {bottom: 0; opacity: 0;}
  5030. }
  5031.  
  5032.  
  5033. .divAlert {
  5034. width: 75%;
  5035. padding: 4px 3px;
  5036. border-radius: 4px;
  5037. border-style: solid;
  5038. border-width: 1px;
  5039. font-size: 13px;
  5040. background-color: #ffc107;
  5041. color: #161515;
  5042. border-color: #ffffff;
  5043. font-weight: bold;
  5044. text-shadow: 1px 1px #ffffff;
  5045. }.modal_cargando {
  5046. display: none;
  5047. /* Hidden by default */
  5048. position: fixed;
  5049. /* Stay in place */
  5050. z-index: 150;
  5051. /* Sit on top */
  5052. padding-top: 25px;
  5053. /* Location of the box */
  5054. left: 0;
  5055. top: 0;
  5056. width: 100%;
  5057. /* Full width */
  5058. height: 100%;
  5059. /* Full height */
  5060. overflow: auto;
  5061. /* Enable scroll if needed */
  5062. background-color: rgb(0, 0, 0);
  5063. /* Fallback color */
  5064. background-color: rgba(0, 0, 0, 0.75);
  5065. /* Black w/ opacity */
  5066. justify-content: center;
  5067. align-items: center;
  5068. }
  5069.  
  5070. .modal-content_cargando {
  5071. position:relative;
  5072. border-radius:7px;
  5073. background-color: #fefefe00;
  5074. width: 90%;
  5075. height: 40%;
  5076. display: flex;
  5077. justify-content: center;
  5078. align-items: center;
  5079. }
  5080.  
  5081.  
  5082. .btn-save{
  5083. width:8em;
  5084. border-color:transparent;
  5085. border-radius: 3px;
  5086. display: inline-block;
  5087. padding: 10px 5px;
  5088. text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  5089. box-shadow: 0 1px 1px rgba(0,0,0,0.3);
  5090. cursor:pointer;
  5091. color: white;
  5092. font-family: 'Roboto', sans-serif;
  5093. background-color: #3CC93F;/*Color de fondo*/
  5094. }
  5095. .btn-save:hover{
  5096. background-color: #37B839;/*Color de fondo*/
  5097. }
  5098. .btn-save:active{
  5099. background-color: #29962A;/*Color de fondo*/
  5100. }
  5101.  
  5102.  
  5103. .btn-update{
  5104. width:8em;
  5105. border-color:transparent;
  5106. border-radius: 3px;
  5107. display: inline-block;
  5108. padding: 10px 5px;
  5109. text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  5110. box-shadow: 0 1px 1px rgba(0,0,0,0.3);
  5111. cursor:pointer;
  5112. color: white;
  5113. font-family: 'Roboto', sans-serif;
  5114. background-color: #2da8ef;/*Color de fondo*/
  5115. }
  5116. .btn-update:hover{
  5117. background-color: #2187c2;/*Color de fondo*/
  5118. }
  5119. .btn-update:active{
  5120. background-color: #2187c2;/*Color de fondo*/
  5121. }
  5122.  
  5123.  
  5124. .btn-comp-fed{
  5125. width:17em;
  5126. font-family: 'Roboto', sans-serif;
  5127. border:1px solid black;
  5128. border-radius: 5px;
  5129. display: inline-block;
  5130. padding: 7px 3px;
  5131. cursor:pointer;
  5132. color: white;
  5133. background-color: #2da8ef;/*Color de fondo*/
  5134. }
  5135. .btn-comp-fed:hover{
  5136. background-color: #2187c2;/*Color de fondo*/
  5137. }
  5138. .btn-comp-fed:active{
  5139. background-color: #2187c2;/*Color de fondo*/
  5140. }
  5141.  
  5142. .btn-delete{
  5143. width:8em;
  5144. border-color:transparent;
  5145. border-radius: 3px;
  5146. display: inline-block;
  5147. padding: 10px 5px;
  5148. text-decoration: none;
  5149. text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  5150. box-shadow: 0 1px 1px rgba(0,0,0,0.3);
  5151. cursor:pointer;
  5152. color: white;
  5153. font-family: 'Roboto', sans-serif;
  5154. background-color: #e6413e;/*Color de fondo*/
  5155. }
  5156. .btn-delete:hover{
  5157. background-color: #C93832;/*Color de fondo*/
  5158. }
  5159. .btn-delete:active{
  5160. background-color: #ad2a24;/*Color de fondo*/
  5161. }
  5162.  
  5163. .cerrar {
  5164. position: absolute;
  5165. top: 0;
  5166. right: 0;
  5167. padding: 5px;
  5168. cursor: pointer;
  5169. color: #fff;
  5170. }
  5171.  
  5172. .close_cargando {
  5173. color: #aaaaaa;
  5174. float: right;
  5175. font-size: 28px;
  5176. font-weight: bold;
  5177. }
  5178.  
  5179. .close_cargando:hover,
  5180. .close_cargando:focus {
  5181. color: #000;
  5182. text-decoration: none;
  5183. cursor: pointer;
  5184. }.stx_legend {
  5185. z-index:300;
  5186. position: fixed;
  5187. bottom: 60%;
  5188. right: 1px;
  5189. border: 1px solid #2bacf5;
  5190. padding-right: 13px;
  5191. padding-left: 3px;
  5192. padding-top: 3px;
  5193. padding-bottom: 3px;
  5194. width: 14px;
  5195. font-size: 13px;
  5196. border-radius: 4px;
  5197. text-shadow: 1px 1px 3px #676767;
  5198. background-color: #246355;
  5199. color: #246355;
  5200. cursor: default;
  5201. cursor: pointer;
  5202. }.loader {
  5203. width: 100%;
  5204. height: 15px;
  5205. border-radius: 40px;
  5206. color: #ffc107;
  5207. border: 2px solid;
  5208. position: relative;
  5209. overflow: hidden;
  5210. }
  5211. .loader::before {
  5212. content: "";
  5213. position: absolute;
  5214. margin: 2px;
  5215. width: 14px;
  5216. top: 0;
  5217. bottom: 0;
  5218. left: -20px;
  5219. border-radius: inherit;
  5220. background: currentColor;
  5221. box-shadow: -10px 0 12px 3px currentColor;
  5222. clip-path: polygon(0 5%, 100% 0,100% 100%,0 95%,-30px 50%);
  5223. animation: l14 1s infinite linear;
  5224. }
  5225. @keyframes l14 {
  5226. 100% {left: calc(100% + 20px)}
  5227. }
  5228. .containerPeqAmarillo {
  5229. display: block;
  5230. position: relative;
  5231. padding-left: 35px;
  5232. margin-bottom: 12px;
  5233. font-size:medium;
  5234. padding-top:5px;
  5235. cursor: pointer;
  5236. -webkit-user-select: none;
  5237. -moz-user-select: none;
  5238. -ms-user-select: none;
  5239. user-select: none;
  5240. }
  5241.  
  5242. /* Hide the browser's default checkbox */
  5243. .containerPeqAmarillo input {
  5244. position: absolute;
  5245. opacity: 0;
  5246. cursor: pointer;
  5247. height: 0;
  5248. width: 0;
  5249. }
  5250.  
  5251. /* Create a custom checkbox */
  5252. .checkmarkPeqAmarillo {
  5253. position: absolute;
  5254. top: 0;
  5255. left: 0;
  5256. height: 25px;
  5257. width: 25px;
  5258. background-color: #a1a1a1;
  5259. }
  5260.  
  5261. /* On mouse-over, add a grey background color */
  5262. .containerPeqAmarillo:hover input ~ .checkmarkPeqAmarillo {
  5263. background-color: #5c5151;
  5264. }
  5265.  
  5266. /* When the checkbox is checked, add a blue background */
  5267. .containerPeqAmarillo input:checked ~ .checkmarkPeqAmarillo {
  5268. background-color: #FFCC00;
  5269. }
  5270.  
  5271. /* Create the checkmark/indicator (hidden when not checked) */
  5272. .checkmarkPeqAmarillo:after {
  5273. content: "";
  5274. position: absolute;
  5275. display: none;
  5276. }
  5277.  
  5278. /* Show the checkmark when checked */
  5279. .containerPeqAmarillo input:checked ~ .checkmarkPeqAmarillo:after {
  5280. display: block;
  5281. }
  5282.  
  5283. /* Style the checkmark/indicator */
  5284. .containerPeqAmarillo .checkmarkPeqAmarillo:after {
  5285. left: 9px;
  5286. top: 5px;
  5287. width: 5px;
  5288. height: 10px;
  5289. border: solid white;
  5290. border-width: 0 3px 3px 0;
  5291. -webkit-transform: rotate(45deg);
  5292. -ms-transform: rotate(45deg);
  5293. transform: rotate(45deg);
  5294. }
  5295. #showMenu {
  5296. text-align: left;
  5297. border-collapse: collapse;
  5298. width: 75%;
  5299. font-size: 14px;
  5300. font-family: 'Roboto', sans-serif
  5301. }
  5302.  
  5303. /* #showMenu th,td {
  5304. padding: 4px;
  5305. }*/
  5306.  
  5307. #showMenu td {
  5308. background-color: white;
  5309. }
  5310.  
  5311. #showMenu thead {
  5312. background-color: #246355;
  5313. border-bottom: solid 2px #0F362D;
  5314. color: white;
  5315. }
  5316.  
  5317. #showMenu tfoot {
  5318. font-family: 'Righteous', cursive;
  5319. background-color: #246355;
  5320. border-bottom: solid 5px #0F362D;
  5321. font-size: 13px;
  5322. color: white;
  5323. }
  5324.  
  5325.  
  5326.  
  5327. #showMenu tr td,
  5328. th {
  5329. border-top-right-radius: 0;
  5330. border-top-left-radius: 0;
  5331. border-bottom-left-radius: 0;
  5332. border-bottom-right-radius: 0;
  5333. }
  5334.  
  5335. #showMenu th:first-child {
  5336. border-top-left-radius: 5px;
  5337. }
  5338.  
  5339. #showMenu th:last-child {
  5340. border-top-right-radius: 5px;
  5341. }
  5342.  
  5343. #showMenu tr {
  5344. background-color: transparent;
  5345. border-color: transparent;
  5346. font-family: 'Roboto';
  5347. }
  5348.  
  5349. #show3{
  5350.  
  5351. width: 75%;
  5352. background-color: transparent;
  5353. border-collapse: separate;
  5354. border-spacing: 0;
  5355. }
  5356.  
  5357.  
  5358.  
  5359. #show3 td {
  5360. background-color: white;
  5361. }
  5362.  
  5363. #show3 tr:last-child td:last-child {
  5364. border-bottom-right-radius: 5px;
  5365. }
  5366.  
  5367.  
  5368. #show3 tr:last-child td:first-child {
  5369. border-bottom-left-radius: 5px;
  5370. }
  5371.  
  5372. .caja_mensaje_50 {
  5373. font-family: 'Roboto', sans-serif;
  5374. background: #98D398;
  5375. color: #FFFFFF;
  5376. font-weight: bold;
  5377. padding: 4px;
  5378. text-align: center;
  5379. width: 50%;
  5380. font-size: 2.0em;
  5381. border-radius: 5px;
  5382. }
  5383.  
  5384. .modal_div_content_main{
  5385. width: 100%;
  5386. background-color: #f2f2f2;
  5387. min-height: 115px;
  5388. border-radius: 5px;
  5389. }
  5390.  
  5391.  
  5392.  
  5393.  
  5394. .expandable-icon {
  5395. right: 0px;
  5396. top: 0px;
  5397. transform: rotateZ(45deg);
  5398. border-radius: 5px;
  5399. width: 20px;
  5400. height: 20px;
  5401. background: rgb(12, 47, 94);
  5402. transition: all .3s;
  5403. }
  5404.  
  5405. .expandable-item.active .expandable-icon{
  5406. transform: rotateZ(0);
  5407. }
  5408.  
  5409. .expandable-icon .line {
  5410. width: 15px;
  5411. height: 2px;
  5412. background: white;
  5413. position: absolute;
  5414. top: 0;
  5415. left: 0;
  5416. right: 0;
  5417. bottom: 0;
  5418. margin: auto;
  5419. transition: all .4s;
  5420. }
  5421.  
  5422. .expandable-icon .line:nth-child(1) {
  5423. transform: rotateZ(45deg);
  5424. }
  5425.  
  5426. .expandable-icon .line:nth-child(2) {
  5427. transform: rotateZ(-45deg);
  5428. }
  5429.  
  5430.  
  5431. .imgMiddle {
  5432. display: inline-block;
  5433. vertical-align: middle;
  5434. }
  5435.  
  5436. .textMiddle {
  5437. display: inline-block;
  5438. vertical-align: middle;
  5439. }
  5440.  
  5441.  
  5442. table.matchValuesTable {
  5443. border-collapse: collapse;
  5444. width: 80%;
  5445. margin: 5px 0;
  5446. z-index:15;
  5447.  
  5448. }
  5449. table.matchValuesTable th, table.matchValuesTable td {
  5450. border: 1px solid #ddd;
  5451. text-align: center;
  5452. padding: 6px;
  5453. border: 0px;
  5454. }
  5455. table.matchValuesTable th {
  5456. background-color: #e4c800;
  5457. color: white;
  5458. border: 0px;
  5459. }
  5460.  
  5461. table.matchValuesTable th:first-child {
  5462. border-top: none; /* Quita el borde superior de la primera celda del encabezado */
  5463. }
  5464.  
  5465.  
  5466. #button-snackbar-update{
  5467. color: #2da8ef;
  5468. background-color: transparent;
  5469. border: 1px solid #2da8ef;
  5470. padding: .15rem .50rem;
  5471. font-size: 0.90rem;
  5472. line-height: 1.5;
  5473. border-radius: .25rem;
  5474. cursor:pointer;
  5475. }
  5476.  
  5477. #button-snackbar-update:hover{
  5478. color: white;
  5479. background-color: #2da8ef;
  5480. border: 1px solid #2da8ef;
  5481. padding: .15rem .50rem;
  5482. font-size: 0.90rem;
  5483. line-height: 1.5;
  5484. border-radius: .25rem;
  5485. cursor:pointer;
  5486. }.loader-soccer {
  5487. width: 100%;
  5488. height: 15px;
  5489. border-radius: 40px;
  5490. color: #5d7f13;
  5491. border: 2px solid;
  5492. position: relative;
  5493. overflow: hidden;
  5494. }
  5495. .loader-soccer::before {
  5496. content: "";
  5497. position: absolute;
  5498. margin: 2px;
  5499. width: 14px;
  5500. top: 0;
  5501. bottom: 0;
  5502. left: -20px;
  5503. border-radius: inherit;
  5504. background: currentColor;
  5505. box-shadow: -10px 0 12px 3px currentColor;
  5506. clip-path: polygon(0 5%, 100% 0,100% 100%,0 95%,-30px 50%);
  5507. animation: l14 1s infinite linear;
  5508. }
  5509.  
  5510. .loader-hockey {
  5511. width: 100%;
  5512. height: 15px;
  5513. border-radius: 40px;
  5514. color: #148cac;
  5515. border: 2px solid;
  5516. position: relative;
  5517. overflow: hidden;
  5518. }
  5519. .loader-hockey::before {
  5520. content: "";
  5521. position: absolute;
  5522. margin: 2px;
  5523. width: 14px;
  5524. top: 0;
  5525. bottom: 0;
  5526. left: -20px;
  5527. border-radius: inherit;
  5528. background: currentColor;
  5529. box-shadow: -10px 0 12px 3px currentColor;
  5530. clip-path: polygon(0 5%, 100% 0,100% 100%,0 95%,-30px 50%);
  5531. animation: l14 1s infinite linear;
  5532. }
  5533. @keyframes l14 {
  5534. 100% {left: calc(100% + 20px)}
  5535. }
  5536. `)
  5537.  
  5538. }
  5539.  
  5540. async function playersPage1() {
  5541. setTimeout(function () {
  5542. let player_images
  5543. let elementos = document.getElementsByClassName('playerContainer');
  5544.  
  5545. let player_values = {}
  5546. let tactics_list = []
  5547.  
  5548. let urlParams = new URLSearchParams(window.location.search);
  5549. let flagStats = true
  5550. if (urlParams.has('tid')) {
  5551. flagStats = false
  5552. }
  5553.  
  5554. if (flagStats) {
  5555. let habil_container = elementos[0].getElementsByClassName("player_skills")
  5556. let habil = habil_container[0].getElementsByClassName("clippable")
  5557.  
  5558. if (window.sport === "hockey") {
  5559. for (let q = 1; q < habil.length; q++) {
  5560. skills_names.push(habil[q].textContent)
  5561. }
  5562. } else {
  5563.  
  5564. for (let q = 0; q < habil.length - 1; q++) {
  5565. skills_names.push(habil[q].textContent)
  5566. }
  5567. player_images = document.getElementsByClassName("player-image soccer")
  5568. }
  5569. }
  5570.  
  5571. let ids_ = []
  5572.  
  5573. for (let i = 0; i < elementos.length; i++) {
  5574. let ids = elementos[i].getElementsByClassName('player_id_span');
  5575.  
  5576. let elementos_ = elementos[i].getElementsByClassName('p_sublinks');
  5577.  
  5578. let subheaders = elementos[i].getElementsByClassName('subheader clearfix');
  5579.  
  5580.  
  5581. let enlace = subheaders[0].querySelector('.subheader a');
  5582. let playerName = enlace.querySelector('.player_name').textContent
  5583.  
  5584. ids_.push({ "id": ids[0].textContent, "name": playerName });
  5585.  
  5586.  
  5587. let txt = '<span id=but' + ids[0].textContent + ' class="player_icon_placeholder"><a href="#" onclick="return false"'
  5588. txt += 'title="Stats Xente" class="player_icon"><span class="player_icon_wrapper">'
  5589. txt += '<span class="player_icon_image" style="background-image: url(\'https://www.statsxente.com/MZ1/View/Images/main_icon_mini.png\'); width: 21px; height: 18px; background-size: auto;'
  5590. txt += 'z-index: 0;"></span><span class="player_icon_text"></span></span></a></span>'
  5591.  
  5592. let index=0
  5593. if(window.stx_device!=="computer"){index=1}
  5594. elementos_[index].innerHTML += txt;
  5595.  
  5596. if (flagStats) {
  5597. let flag_gk = false;
  5598. let age_div = elementos[i].getElementsByClassName('dg_playerview_info');
  5599. let age_table = age_div[0].getElementsByTagName('table')[0];
  5600.  
  5601. let ini_age = age_table.getElementsByTagName('td')[0].textContent.indexOf(":")
  5602. let age = age_table.getElementsByTagName('td')[0].textContent.substring(ini_age + 2, ini_age + 4);
  5603.  
  5604.  
  5605. if ((window.sport === "soccer") && (player_images[i].innerHTML.includes("gk=1"))) {
  5606. flag_gk = true
  5607. }
  5608.  
  5609. let tactics = elementos[i].getElementsByClassName('player_tactic gradientSunriseIcon');
  5610.  
  5611. player_values = {
  5612. "id": ids[0].textContent,
  5613. "skills": [],
  5614. "lines": [],
  5615. "tactics-position": {},
  5616. "tactics": [],
  5617. "age": parseInt(age)
  5618. }
  5619.  
  5620. for (let j = 0; j < tactics.length; j++) {
  5621. let fin = 0;
  5622. let line = ""
  5623. let ini = tactics[j].textContent.indexOf('(');
  5624. let tactic = tactics[j].textContent.substring(0, ini - 1);
  5625.  
  5626. if (window.sport === "hockey") {
  5627.  
  5628. if (!tactics[j].textContent.includes(":")) {
  5629. ini = tactics[j].textContent.indexOf('(');
  5630. fin = tactics[j].textContent.indexOf(')');
  5631. line = tactics[j].textContent.substring(ini + 2, fin - 1);
  5632. gk_line = line;
  5633. } else {
  5634. ini = tactics[j].textContent.indexOf('(');
  5635. fin = tactics[j].textContent.indexOf(':');
  5636. line = tactics[j].textContent.substring(ini + 2, fin);
  5637. }
  5638.  
  5639. } else {
  5640. ini = tactics[j].textContent.indexOf('(');
  5641. fin = tactics[j].textContent.indexOf(')');
  5642. line = tactics[j].textContent.substring(ini + 2, fin - 1);
  5643. if (flag_gk) {
  5644. gk_line = line;
  5645. }
  5646. if (tactics[j].textContent.includes(",")) {
  5647. ini = tactics[j].textContent.indexOf('(');
  5648. fin = tactics[j].textContent.indexOf(',');
  5649. su_line = tactics[j].textContent.substring(ini + 2, fin);
  5650. }
  5651. }
  5652.  
  5653. if (!player_values['lines'].includes(line)) {
  5654. player_values['lines'].push(line);
  5655. }
  5656. if (!player_values['tactics'].includes(tactic)) {
  5657. player_values['tactics'].push(tactic);
  5658. }
  5659.  
  5660. player_values['tactics-position'][tactic] = line
  5661.  
  5662. if ((!lines.includes(line))) {
  5663. lines.push(line);
  5664. }
  5665.  
  5666. if (!tactics_list.includes(tactic)) {
  5667. tactics_list.push(tactic);
  5668. }
  5669.  
  5670.  
  5671. }
  5672. let skills_container=elementos[i].getElementsByClassName('skills-container floatLeft clearfix')
  5673. let skills = skills_container[0].getElementsByClassName('skillval');
  5674.  
  5675. if (window.sport === "hockey") {
  5676.  
  5677. for (let j = 1; j < skills.length; j++) {
  5678. let cleanedText = skills[j].textContent.replace(')', '');
  5679. cleanedText = cleanedText.replace('(', '');
  5680. let number = parseInt(cleanedText, 10);
  5681. player_values['skills'].push(number);
  5682. }
  5683.  
  5684. } else {
  5685. for (let j = 0; j < skills.length - 1; j++) {
  5686.  
  5687. let cleanedText = skills[j].textContent.replace(')', '');
  5688. cleanedText = cleanedText.replace('(', '');
  5689. let number = parseInt(cleanedText, 10);
  5690. player_values['skills'].push(number);
  5691. }
  5692. }
  5693. players.push(player_values)
  5694. }
  5695. }
  5696. if (flagStats) {
  5697. const container = document.getElementById("squad-search-toggle")
  5698. let contenidoNuevo = "<div id='containerTactics' style='background-color: #e3e3e3; margin: 0 auto; text-align:center;'></br>"
  5699. contenidoNuevo += "<div id=selectDiv>Choose Tactic: <select id=tactics_select>"
  5700. contenidoNuevo += "<option value='All Team'>All Team</option>"
  5701. for (let x = 0; x < tactics_list.length; x++) {
  5702. let selected = ""
  5703. if (x === 0) {
  5704. selected = "selected=''";
  5705. }
  5706. contenidoNuevo += "<option " + selected + " value='" + tactics_list[x] + "'>" + tactics_list[x] + "</option>"
  5707. }
  5708. contenidoNuevo += "</select></div></br><div id=divMenu></div></center></div>"
  5709. container.innerHTML = contenidoNuevo + container.innerHTML;
  5710. skillDistrib(tactics_list[0]);
  5711. document.getElementById("tactics_select").addEventListener('change', function () {
  5712. let select = document.getElementById('tactics_select');
  5713. let valorSeleccionado = select.value;
  5714. document.getElementById("divMenu").innerHTML = ""
  5715. skillDistrib(valorSeleccionado)
  5716. });
  5717. }
  5718.  
  5719. let team_id
  5720. if(window.sport==="soccer"){
  5721. team_id=GM_getValue("soccer_team_id")
  5722. }else{
  5723. team_id=GM_getValue("hockey_team_id")
  5724. }
  5725.  
  5726.  
  5727. for (let i = 0; i < ids_.length; i++) {
  5728. (function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
  5729. document.getElementById("but" + currentId).addEventListener('click', function () {
  5730. let link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
  5731. + "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
  5732. "&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
  5733. openWindow(link, 0.95, 1.25);
  5734. });
  5735. })(ids_[i]['id'], team_id, window.sport, window.lang, "[undefined]", ids_[i]['name']);
  5736. }
  5737.  
  5738. }, 1000);
  5739. }
  5740. function skillDistrib1(tactic) {
  5741. let t = tactic
  5742. let l=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  5743. if (window.sport === "hockey") {
  5744. l = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  5745. }
  5746.  
  5747. let li_t = {}
  5748. for (let i = 0; i < lines.length; i++) {
  5749. li_t[lines[i]] = [...l];
  5750. }
  5751.  
  5752. let no_gk_line = "Tactic -(" + gk_line + ")"
  5753. li_t["Team"] = [...l];
  5754. li_t["U23"] = [...l];
  5755. li_t["U21"] = [...l];
  5756. li_t["U18"] = [...l];
  5757. li_t["Tactic"] = [...l];
  5758. li_t[no_gk_line] = [...l];
  5759.  
  5760. let i,j
  5761. for (i = 0; i < players.length; i++) {
  5762. if (players[i]['tactics'].includes(t)) {
  5763. for (j = 0; j < players[i]['skills'].length; j++) {
  5764. li_t[players[i]['tactics-position'][t]][j] += players[i]['skills'][j]
  5765. li_t['Tactic'][j] += players[i]['skills'][j]
  5766. if (players[i]['tactics-position'][t] !== "Po") {
  5767. li_t[no_gk_line][j] += players[i]['skills'][j]
  5768. }
  5769. }
  5770. li_t[players[i]['tactics-position'][t]][j] += 1
  5771. li_t['Tactic'][j] += 1
  5772. if (players[i]['tactics-position'][t] !== "Po") {
  5773. li_t[no_gk_line][j] += 1
  5774. }
  5775. } else {
  5776.  
  5777. for (let j = 0; j < players[i]['skills'].length; j++) {
  5778. if (players[i]['age'] <= 23) {
  5779. li_t['U23'][j] += players[i]['skills'][j]
  5780. }
  5781. if (players[i]['age'] <= 23) {
  5782. li_t['U21'][j] += players[i]['skills'][j]
  5783. }
  5784. if (players[i]['age'] <= 23) {
  5785. li_t['U18'][j] += players[i]['skills'][j]
  5786. }
  5787. li_t['Team'][j] += players[i]['skills'][j]
  5788. }
  5789.  
  5790. if (players[i]['age'] <= 23) {
  5791. li_t['U23'][li_t["U23"].length - 1] += 1
  5792. }
  5793.  
  5794. if (players[i]['age'] <= 21) {
  5795. li_t['U21'][li_t["U21"].length - 1] += 1
  5796. }
  5797. if (players[i]['age'] <= 18) {
  5798. li_t['U18'][li_t["U18"].length - 1] += 1
  5799. }
  5800. li_t['Team'][li_t["Team"].length - 1] += 1
  5801. }
  5802. }
  5803.  
  5804. const container = document.getElementById("divMenu")
  5805. let contenidoNuevo = "<table id=showMenu style='width:95%;font-size:13px; margin: 0 auto; text-align:center;'><thead style='background-color:" + GM_getValue("bg_native") + "; color:" + GM_getValue("color_native") + ";'><tr>";
  5806. contenidoNuevo += '<th style="padding:4px; margin: 0 auto; text-align:center;">Line</th>'
  5807. for (let q = 0; q < skills_names.length; q++) {
  5808. contenidoNuevo += '<th style="padding:4px; margin: 0 auto; text-align:center;">' + skills_names[q] + '</th>'
  5809. }
  5810. contenidoNuevo += '</tr></thead>';
  5811. let l_aux = lines
  5812. l_aux = l_aux.filter(item => item !== gk_line);
  5813. l_aux.sort((a, b) => {
  5814. let numA = parseInt(a.substring(1), 10);
  5815. let numB = parseInt(b.substring(1), 10);
  5816. return numA - numB;
  5817. });
  5818.  
  5819. l_aux.unshift(gk_line);
  5820. l_aux.push("Tactic");
  5821. l_aux.push(no_gk_line);
  5822.  
  5823. if (window.sport === "hockey") {
  5824. if (li_t["L4"][10] === 0) {
  5825. let index = l_aux.indexOf('L4');
  5826. if (index !== -1) {
  5827. l_aux.splice(index, 1);
  5828. }
  5829. }
  5830. }
  5831.  
  5832. if (t === "All Team") {
  5833. l_aux = ["Team", "U23", "U21", "U18"]
  5834. }
  5835.  
  5836. l_aux = l_aux.filter(item => !item.includes(su_line));
  5837.  
  5838. for (let w = 0; w < l_aux.length; w++) {
  5839. let key = l_aux[w]
  5840. if (li_t.hasOwnProperty(key)) {
  5841. contenidoNuevo += "<tr>";
  5842. contenidoNuevo += "<td style='padding:2px; margin: 0 auto; text-align:center;'><strong>" + key + "</strong></td>";
  5843. for (let x = 0; x < li_t[key].length - 1; x++) {
  5844. contenidoNuevo += "<td style='padding:2px; margin: 0 auto; text-align:center;'>" + Math.round(li_t[key][x] / li_t[key][li_t[key].length - 1] * 100) / 100 + "</td>";
  5845. }
  5846. contenidoNuevo += "</tr>";
  5847.  
  5848. }
  5849. }
  5850. container.innerHTML += contenidoNuevo;
  5851. }
  5852.  
  5853.  
  5854.  
  5855. })();