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