Stats Xente Script

Stats Xente script for inject own data on Managerzone site

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

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