Stats Xente Script

Stats Xente script for inject own data on Managerzone site

当前为 2025-04-23 提交的版本,查看 最新版本

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