Stats Xente Script

Stats Xente script for inject own data on Managerzone site

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

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