Stats Xente Script

Stats Xente script for inject own data on Managerzone site

目前為 2025-01-28 提交的版本,檢視 最新版本

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