Stats Xente Script

Stats Xente script for inject own data on Managerzone site

当前为 2025-05-29 提交的版本,查看 最新版本

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