Stats Xente Script

Stats Xente script for inject own data on Managerzone site

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

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