Stats Xente Script

Stats Xente script for inject own data on Managerzone site

当前为 2025-01-06 提交的版本,查看 最新版本

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