Greasy Fork 还支持 简体中文。

Stats Xente Script

Stats Xente script for inject own data on Managerzone site

目前為 2025-02-24 提交的版本,檢視 最新版本

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