Stats Xente Script

Stats Xente script for inject own data on Managerzone site

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

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