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.143
  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. console.log("a")
  3518. let urlParams = new URLSearchParams(window.location.search);
  3519. var match_id=urlParams.get("mid")
  3520. GM_xmlhttpRequest({
  3521. method: "GET",
  3522. url: "https://statsxente.com/MZ1/Functions/tamper_elo_change_match.php?sport=" + window.sport + "&match_id="+match_id,
  3523. headers: {
  3524. "Content-Type": "application/json"
  3525. },
  3526. onload: function (response) {
  3527. var elo_data= JSON.parse(response.responseText);
  3528. const matchResultDiv = document.getElementById('gw_match_result');
  3529. const parentDiv = matchResultDiv?.parentNode;
  3530. const newDiv = document.createElement('div');
  3531. 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">'
  3532. newT+='<span style="font-weight:bold; margin-left: 5px;">'+elo_data['elo_variation'].toFixed(2)+'</span></div></center>'
  3533. newDiv.innerHTML = newT;
  3534. if (parentDiv) {
  3535. parentDiv.appendChild(newDiv);
  3536. }
  3537.  
  3538. }});
  3539. console.log("a-fin")
  3540.  
  3541.  
  3542.  
  3543. let linkIds=""
  3544. let contIds=0
  3545. for (let x = 0; x < 2; x++) {
  3546. let as = team_div[x].getElementsByTagName("a")
  3547. let urlObj = new URL("https://www.managerzone.com/" + as[0].getAttribute('href'));
  3548. let params = new URLSearchParams(urlObj.search);
  3549. let tidValue = params.get('tid');
  3550. teams_[x] = { "team_name": as[0].innerHTML, "team_id": tidValue, "inserted": "" }
  3551. linkIds += "&idEquipo" + contIds + "=" + tidValue
  3552. contIds++
  3553. }
  3554.  
  3555.  
  3556. GM_xmlhttpRequest({
  3557. method: "GET",
  3558. url: "https://statsxente.com/MZ1/Functions/tamper_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + linkIds,
  3559. headers: {
  3560. "Content-Type": "application/json"
  3561. },
  3562. onload: function (response) {
  3563.  
  3564. let jsonResponse = JSON.parse(response.responseText);
  3565. const divs = document.querySelectorAll('div'); // Selecciona todos los divs
  3566. const divsConAltura15px = Array.from(divs).filter(div => {
  3567. const computedStyle = window.getComputedStyle(div);
  3568. return computedStyle.height === '15px' && div.innerHTML === "";
  3569. });
  3570.  
  3571.  
  3572. for(let m=0;m<2;m++){
  3573.  
  3574. let aux=teams_[m]['team_id']
  3575.  
  3576. let top="TOP 11"
  3577.  
  3578. if(window.sport==="hockey"){
  3579. top="TOP 21"
  3580. }
  3581.  
  3582. let teamTable='<div style="display: flex;flex-direction: column;justify-content: center;align-items: center;flex-wrap: wrap;max-height: 100%;">'
  3583. teamTable+='<table class="matchValuesTable"><thead><tr>'
  3584. teamTable+='<th id=thTransparent'+m+' style="background-color:transparent; border:0;"></th>'
  3585. teamTable+='<th style="border-top-left-radius: 5px;">Value</th><th>LM Value</th>'
  3586. teamTable+='<th >'+top+'</th><th style="border-top-right-radius: 5px;">ELO</th></tr></thead><tbody>'
  3587. let valor=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor']))
  3588. let valorLM=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valorUPSenior']))
  3589. let valor11=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor11']))
  3590. let elo=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['elo']))
  3591. 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>'
  3592.  
  3593. valor=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor23']))
  3594. valorLM=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valorUPSUB23']))
  3595. valor11=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor11_23']))
  3596. elo=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['elo23']))
  3597. 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>'
  3598.  
  3599.  
  3600. valor=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor21']))
  3601. valorLM=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valorUPSUB21']))
  3602. valor11=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor11_21']))
  3603. elo=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['elo21']))
  3604. 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>'
  3605.  
  3606. valor=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor18']))
  3607. valorLM=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valorUPSUB18']))
  3608. valor11=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor11_18']))
  3609. elo=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['elo18']))
  3610. teamTable+='<tr><th style="border-bottom-left-radius: 5px;">U18</th><td style="border-bottom:1px solid '+GM_getValue("bg_native")+';">'+valor+'</td>'
  3611. teamTable+='<td style="border-bottom:1px solid '+GM_getValue("bg_native")+';">'+valorLM+'</td>'
  3612. teamTable+='<td style="border-bottom:1px solid '+GM_getValue("bg_native")+';;">'+valor11+'</td>'
  3613. 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>'
  3614.  
  3615.  
  3616. teamTable+='</tbody></table></div>'
  3617.  
  3618. divsConAltura15px[m].insertAdjacentHTML('afterend',teamTable)
  3619.  
  3620.  
  3621.  
  3622. }
  3623.  
  3624.  
  3625. const thElements = document.querySelectorAll('table.matchValuesTable th');
  3626.  
  3627. // Cambia el color de fondo de cada <th>
  3628. thElements.forEach(th => {
  3629. th.style.backgroundColor = GM_getValue("bg_native");
  3630. th.style.color = GM_getValue("color_native");
  3631.  
  3632. });
  3633. document.getElementById("thTransparent0").style.backgroundColor="transparent";
  3634. document.getElementById("thTransparent1").style.backgroundColor="transparent";
  3635.  
  3636.  
  3637.  
  3638.  
  3639. }
  3640. });
  3641.  
  3642.  
  3643.  
  3644. let elems = document.getElementsByClassName("hitlist " + window.sport + " statsLite marker tablesorter");
  3645. for (let x = 0; x < 2; x++) {
  3646. let linkIds = ""
  3647. let contIds = 0;
  3648. let tabla = elems[x]
  3649. let filas = tabla.getElementsByTagName("tr");
  3650. let fila = filas[1];
  3651.  
  3652. for (let i = 2; i < filas.length - 1; i++) {
  3653.  
  3654. fila = filas[i];
  3655. let tds = fila.getElementsByTagName("td");
  3656. let as_ = tds[2].getElementsByTagName("a");
  3657. let urlObj = new URL("https://www.managerzone.com/" + as_[0].getAttribute("href"));
  3658. let params = new URLSearchParams(urlObj.search);
  3659. let pid = params.get('pid');
  3660.  
  3661. linkIds += "&id" + contIds + "=" + pid
  3662. contIds++;
  3663. }
  3664.  
  3665. let link = "http://statsxente.com/MZ1/Functions/tamper_check_stats_player.php?sport=" + window.sport + linkIds
  3666. teams_[x]["inserted"]= await fetchExistPlayers(link);
  3667.  
  3668. }
  3669.  
  3670.  
  3671. elems = document.getElementsByClassName("hitlist " + window.sport + " statsLite marker tablesorter");
  3672. for (let x = 0; x < 2; x++) {
  3673. if (teams_[x]['inserted']['total'] > 0) {
  3674. let tabla = elems[x]
  3675. let firstTrThead = tabla.querySelector('thead td');
  3676. let currentColspan = firstTrThead.getAttribute('colspan');
  3677. currentColspan = parseInt(currentColspan, 10) + 1;
  3678. firstTrThead.setAttribute('colspan', currentColspan);
  3679. let secondTrThead = tabla.querySelector('thead tr:nth-of-type(2)')
  3680. let newTd = document.createElement('td');
  3681. newTd.textContent = '';
  3682. secondTrThead.appendChild(newTd);
  3683. let filas = tabla.getElementsByTagName("tr");
  3684. let dato = document.createElement("td");
  3685. let tfoot = tabla.querySelector("tfoot");
  3686. let primeraFilaTfoot = tfoot.querySelector("tr");
  3687. let primerTDTfoot = primeraFilaTfoot.querySelector("td");
  3688. primerTDTfoot.setAttribute("colspan", "9");
  3689.  
  3690. let elems2 = document.getElementsByClassName("listHeadColor");
  3691. let lista = elems2[0]
  3692.  
  3693. let nuevoElementoDD = document.createElement("dd");
  3694. nuevoElementoDD.textContent = "Nuevo elemento";
  3695. nuevoElementoDD.className = "c6"
  3696. lista.appendChild(nuevoElementoDD);
  3697.  
  3698. for (let i = 2; i < filas.length - 1; i++) {
  3699. let fila = filas[i];
  3700.  
  3701. let tds = fila.getElementsByTagName("td");
  3702. let as_ = tds[2].getElementsByTagName("a");
  3703. let urlObj = new URL("https://www.managerzone.com/" + as_[0].getAttribute("href"));
  3704. let params = new URLSearchParams(urlObj.search);
  3705. let pid = params.get('pid');
  3706. if (teams_[x]['inserted'][pid] === "yes") {
  3707. dato = document.createElement("td");
  3708. //aa
  3709.  
  3710. dato.innerHTML = "<img alt='' src='https://statsxente.com/MZ1/View/Images/main_icon.png' width='20px' height='20px' id='but" + pid + "' style='cursor:pointer;'/>"
  3711. fila.appendChild(dato);
  3712.  
  3713.  
  3714.  
  3715. (function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
  3716. document.getElementById("but" + currentId).addEventListener('click', function () {
  3717.  
  3718. let link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
  3719. + "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
  3720. "&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
  3721. openWindow(link, 0.95, 1.25);
  3722. });
  3723. })(pid, teams_[x]['team_id'], window.sport, window.lang, teams_[x]['team_name'], as_[0].innerHTML);
  3724.  
  3725.  
  3726. }else{
  3727. dato = document.createElement("td");
  3728. fila.appendChild(dato);
  3729. }
  3730. }
  3731. }
  3732. }
  3733.  
  3734.  
  3735.  
  3736. }
  3737. //Players page
  3738. async function playersPage() {
  3739. const blob = new Blob([workerCode], { type: "application/javascript" });
  3740. const workerURL = URL.createObjectURL(blob);
  3741. const worker = new Worker(workerURL);
  3742. const tacticsList = [];
  3743. const sport= window.sport
  3744. const elementos = Array.from(document.getElementsByClassName('playerContainer')).map((el) => {
  3745. const playerId = el.querySelector('.player_id_span').textContent.trim();
  3746. const age = el.querySelector('.dg_playerview_info table td').textContent.split(':')[1].trim();
  3747. const skills = Array.from(el.querySelectorAll('.skills-container .skillval')).map(skill => {
  3748. const cleanedText = skill.textContent.trim().replace(/[()]/g, ''); // Reemplaza ( y ) con ''
  3749. return parseInt(cleanedText, 10);
  3750. });
  3751.  
  3752. let tactics
  3753.  
  3754. if(sport==="soccer"){
  3755.  
  3756. tactics = Array.from(el.querySelectorAll('.player_tactic.gradientSunriseIcon'))
  3757. .map(t => ({
  3758. name: t.textContent.split('(')[0].trim(),
  3759. line: t.textContent.split('(')[1].split(')')[0].trim(),
  3760. }))
  3761. .filter((value, index, self) => {
  3762. const tacticString = `${value.name}-${value.line}`;
  3763. return self.findIndex(t => `${t.name}-${t.line}` === tacticString) === index;
  3764. });
  3765.  
  3766.  
  3767.  
  3768. }else{
  3769.  
  3770.  
  3771. tactics = Array.from(el.querySelectorAll('.player_tactic.gradientSunriseIcon'))
  3772. .map(t => {
  3773. const textContent = t.textContent.trim();
  3774. const [namePart, linePart] = textContent.split('(');
  3775.  
  3776. const name = namePart.trim();
  3777. let line = '';
  3778.  
  3779. if (linePart) {
  3780. line = linePart.replace(')', '').trim();
  3781. if (line.includes(':')) {
  3782. line = line.split(':')[0].trim();
  3783. }else{
  3784. gk_line=line
  3785. }
  3786. }
  3787.  
  3788.  
  3789. return { name, line };
  3790. })
  3791. .filter((value, index, self) => {
  3792. const tacticString = `${value.name}-${value.line}`;
  3793. return self.findIndex(t => `${t.name}-${t.line}` === tacticString) === index;
  3794. });
  3795.  
  3796. }
  3797.  
  3798.  
  3799.  
  3800.  
  3801.  
  3802. tactics.forEach(tactic => {
  3803. tacticsList.push(tactic.name);
  3804. });
  3805.  
  3806. return { id: playerId, age, skills, tactics };
  3807. });
  3808. const skillsNames = Array.from(document.querySelectorAll('.player_skills .clippable')).map(el => el.textContent.trim()).filter((value, index, self) => self.indexOf(value) === index);
  3809. let flagStats = true
  3810. let urlParams = new URLSearchParams(window.location.search);
  3811. if (urlParams.has('tid')) {
  3812. flagStats = false
  3813.  
  3814. }
  3815.  
  3816. if(flagStats){
  3817. let team_id
  3818. if(window.sport==="soccer"){
  3819.  
  3820. if ((GM_getValue("soccer_team_id") === undefined) || (GM_getValue("soccer_team_id") === "")){
  3821. let div_player=document.getElementById("thePlayers_0")
  3822. let h2s=div_player.getElementsByTagName("h2");
  3823. let as=h2s[0].getElementsByTagName("a")
  3824. let urlObj = new URL("https://www.managerzone.com/"+as[0].getAttribute("href"));
  3825. let params = new URLSearchParams(urlObj.search);
  3826. let tid = params.get('tid');
  3827. GM_setValue("soccer_team_id",tid)
  3828. }
  3829.  
  3830.  
  3831. team_id=GM_getValue("soccer_team_id")
  3832. }else{
  3833. if ((GM_getValue("hockey_team_id") === undefined) || (GM_getValue("hockey_team_id") === "")){
  3834. let div_player=document.getElementById("thePlayers_0")
  3835. let h2s=div_player.getElementsByTagName("h2");
  3836. let as=h2s[0].getElementsByTagName("a")
  3837. let urlObj = new URL("https://www.managerzone.com/"+as[0].getAttribute("href"));
  3838. let params = new URLSearchParams(urlObj.search);
  3839. let tid = params.get('tid');
  3840. GM_setValue("hockey_team_id",tid)
  3841. }
  3842. team_id=GM_getValue("hockey_team_id")
  3843. }
  3844. let elementos1 = document.getElementsByClassName('playerContainer');
  3845. for (let i = 0; i < elementos1.length; i++) {
  3846. let ids = elementos1[i].getElementsByClassName('player_id_span');
  3847. let playerName = elementos1[i].querySelector('.player_name').textContent
  3848. let elementos_ = elementos1[i].getElementsByClassName('p_sublinks');
  3849. let txt = '<span id=but' + ids[0].textContent + ' class="player_icon_placeholder"><a href="#" onclick="return false"'
  3850. txt += 'title="Stats Xente" class="player_icon"><span class="player_icon_wrapper">'
  3851. 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;'
  3852. txt += 'z-index: 0;"></span><span class="player_icon_text"></span></span></a></span>'
  3853.  
  3854. let index=0
  3855. if(window.stx_device!=="computer"){index=1}
  3856. elementos_[index].innerHTML += txt;
  3857.  
  3858.  
  3859.  
  3860. (function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
  3861. document.getElementById("but" + currentId).addEventListener('click', function () {
  3862. let link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
  3863. + "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
  3864. "&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
  3865. openWindow(link, 0.95, 1.25);
  3866. });
  3867. })(ids[0].textContent, team_id, window.sport, window.lang, "[undefined]", playerName);
  3868.  
  3869.  
  3870.  
  3871.  
  3872. }
  3873.  
  3874.  
  3875. }
  3876.  
  3877. if(sport==="soccer"){
  3878. skillsNames.pop();
  3879. //GK Line detect
  3880. const playerImages = document.querySelectorAll('.player-image');
  3881. const elementWithGK1 = Array.from(playerImages).find(el => {
  3882. return el.innerHTML.includes('gk=1');
  3883. });
  3884.  
  3885.  
  3886.  
  3887. let tactics1 = elementWithGK1.parentNode.getElementsByClassName("player_tactic gradientSunriseIcon")
  3888. let ini = tactics1[0].textContent.indexOf('(');
  3889. let fin = tactics1[0].textContent.indexOf(')');
  3890. gk_line = tactics1[0].textContent.substring(ini + 2, fin - 1);
  3891.  
  3892.  
  3893. }
  3894. worker.postMessage({ elementos, sport, skillsNames, tacticsList, flagStats});
  3895. worker.onmessage = function (e) {
  3896. const players=e.data.players
  3897. const lines=e.data.lines
  3898. const tacticsList=e.data.tacticsList
  3899. const skillsNames= e.data.skillsNames
  3900.  
  3901. su_line=e.data.su_line
  3902.  
  3903. if(su_line===""){
  3904. su_line="unsetted"
  3905. }
  3906.  
  3907. const container = document.getElementById("squad-search-toggle");
  3908. let contenidoNuevo = "<div id='containerTactics' style='background-color: #e3e3e3; margin: 0 auto; text-align:center;'></br>";
  3909. contenidoNuevo += "<div id=selectDiv>Choose Tactic: <select id=tactics_select>";
  3910. contenidoNuevo += "<option value='All Team' selected>All Team</option>";
  3911.  
  3912.  
  3913. for (let x = 0; x < tacticsList.length; x++) {
  3914. let selected="";
  3915. contenidoNuevo += `<option ${selected} value='${tacticsList[x]}'>${tacticsList[x]}</option>`;
  3916. }
  3917.  
  3918. contenidoNuevo += "</select></div></br><div id=divMenu></div></center></div>";
  3919. container.innerHTML = contenidoNuevo + container.innerHTML;
  3920.  
  3921. document.getElementById("tactics_select").addEventListener('change', function () {
  3922. const selectedTactic = this.value;
  3923. document.getElementById("divMenu").innerHTML = ""
  3924. skillDistrib(selectedTactic, players, lines, skillsNames,gk_line,su_line);
  3925. });
  3926.  
  3927. skillDistrib("All Team", players, lines, skillsNames,gk_line,su_line);
  3928.  
  3929.  
  3930. maximizationsPlayersPage()
  3931.  
  3932.  
  3933.  
  3934. };
  3935. }
  3936. async function maximizationsPlayersPage(){
  3937. let elementos1 = document.getElementsByClassName('weeklyReportBox weeklyReportBoxResponsive');
  3938. let elementosConBall = Array.from(elementos1).filter(el => el.innerHTML.includes('ball')&& el.innerHTML.includes('improvement'));
  3939. for (let i = 0; i < elementosConBall.length; i++) {
  3940. let improvementDiv=elementosConBall[i].getElementsByClassName("improvementLabel")
  3941. let trainedSkill=elementosConBall[i].getElementsByClassName("clippable")
  3942. let skills=elementosConBall[i].parentNode.parentNode.parentNode.parentNode.getElementsByClassName("player_skills player_skills_responsive")
  3943. let elementosConHola = Array.from(skills[0].getElementsByClassName("clippable")).filter(el => el.innerText.includes(trainedSkill[0].innerText));
  3944. let currentTd = elementosConHola[0].closest('td');
  3945. if(currentTd.nextElementSibling?.nextElementSibling?.nextElementSibling?.nextElementSibling?.nextElementSibling.innerHTML.includes("maxed")){
  3946. improvementDiv[0].style.backgroundColor="#db5d5d"
  3947. }
  3948. }
  3949. }
  3950. async function skillDistrib(tactic,players, lines, skills_names,gk_line,su_line) {
  3951. let t = tactic
  3952. let l=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  3953. if (window.sport === "hockey") {
  3954. l = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0]
  3955. }
  3956.  
  3957. let li_t = {}
  3958. for (let i = 0; i < lines.length; i++) {
  3959. li_t[lines[i]] = [...l];
  3960. }
  3961.  
  3962. let no_gk_line = "Tactic -(" + gk_line + ")"
  3963. li_t["Team"] = [...l];
  3964. li_t["U23"] = [...l];
  3965. li_t["U21"] = [...l];
  3966. li_t["U18"] = [...l];
  3967. li_t["Tactic"] = [...l];
  3968. li_t[no_gk_line] = [...l];
  3969.  
  3970. let i,j
  3971. for (i = 0; i < players.length; i++) {
  3972. if (players[i]['tactics'].includes(t)) {
  3973. for (j = 0; j < players[i]['skills'].length; j++) {
  3974. li_t[players[i]['tacticsPosition'][t]][j] += players[i]['skills'][j]
  3975. li_t['Tactic'][j] += players[i]['skills'][j]
  3976. if (players[i]['tacticsPosition'][t] !== gk_line) {
  3977. li_t[no_gk_line][j] += players[i]['skills'][j]
  3978. }
  3979. }
  3980. li_t[players[i]['tacticsPosition'][t]][j] += 1
  3981. li_t['Tactic'][j] += 1
  3982. if (players[i]['tacticsPosition'][t] !== gk_line) {
  3983. li_t[no_gk_line][j] += 1
  3984. }
  3985. } else {
  3986.  
  3987. for (let j = 0; j < players[i]['skills'].length; j++) {
  3988. if (players[i]['age'] <= 23) {
  3989. li_t['U23'][j] += players[i]['skills'][j]
  3990. }
  3991. if (players[i]['age'] <= 23) {
  3992. li_t['U21'][j] += players[i]['skills'][j]
  3993. }
  3994. if (players[i]['age'] <= 23) {
  3995. li_t['U18'][j] += players[i]['skills'][j]
  3996. }
  3997. li_t['Team'][j] += players[i]['skills'][j]
  3998. }
  3999.  
  4000. if (players[i]['age'] <= 23) {
  4001. li_t['U23'][li_t["U23"].length - 1] += 1
  4002. }
  4003.  
  4004. if (players[i]['age'] <= 21) {
  4005. li_t['U21'][li_t["U21"].length - 1] += 1
  4006. }
  4007. if (players[i]['age'] <= 18) {
  4008. li_t['U18'][li_t["U18"].length - 1] += 1
  4009. }
  4010. li_t['Team'][li_t["Team"].length - 1] += 1
  4011. }
  4012. }
  4013.  
  4014. const container = document.getElementById("divMenu")
  4015. 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>";
  4016. contenidoNuevo += '<th style="padding:4px; margin: 0 auto; text-align:center;">Line</th>'
  4017. for (let q = 0; q < skills_names.length; q++) {
  4018. contenidoNuevo += '<th style="padding:4px; margin: 0 auto; text-align:center;">' + skills_names[q] + '</th>'
  4019. }
  4020. contenidoNuevo += '</tr></thead>';
  4021. let l_aux = lines
  4022. l_aux = l_aux.filter(item => item !== gk_line);
  4023. l_aux.sort((a, b) => {
  4024. let numA = parseInt(a.substring(1), 10);
  4025. let numB = parseInt(b.substring(1), 10);
  4026. return numA - numB;
  4027. });
  4028.  
  4029. l_aux.unshift(gk_line);
  4030. l_aux.push("Tactic");
  4031. l_aux.push(no_gk_line);
  4032.  
  4033. if (window.sport === "hockey") {
  4034. if (li_t["L4"][10] === 0) {
  4035. let index = l_aux.indexOf('L4');
  4036. if (index !== -1) {
  4037. l_aux.splice(index, 1);
  4038. }
  4039. }
  4040. }
  4041.  
  4042. if (t === "All Team") {
  4043. l_aux = ["Team", "U23", "U21", "U18"]
  4044. }
  4045. l_aux = l_aux.filter(item => !item.includes(su_line));
  4046.  
  4047. for (let w = 0; w < l_aux.length; w++) {
  4048. let key = l_aux[w]
  4049. if (li_t.hasOwnProperty(key)) {
  4050. contenidoNuevo += "<tr>";
  4051. contenidoNuevo += "<td style='padding:2px; margin: 0 auto; text-align:center;'><strong>" + key + "</strong></td>";
  4052. for (let x = 0; x < li_t[key].length - 1; x++) {
  4053. 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>";
  4054. }
  4055. contenidoNuevo += "</tr>";
  4056. }
  4057. }
  4058. container.innerHTML += contenidoNuevo;
  4059. }
  4060.  
  4061. //Players links to stats
  4062. async function playersPageStats() {
  4063. let element = document.getElementById('thePlayers_0');
  4064. let elementos_ = element.getElementsByClassName('p_sublinks');
  4065. let subheaders = element.getElementsByClassName('subheader clearfix');
  4066. let enlace = subheaders[0].querySelector('.subheader a');
  4067. let urlObj = new URL("https://www.managerzone.com/" + enlace.getAttribute('href'));
  4068. let params = new URLSearchParams(urlObj.search);
  4069. let tid = params.get('tid');
  4070. let playerName = enlace.querySelector('.player_name').textContent
  4071. let ids = element.getElementsByClassName('player_id_span');
  4072. let txt = '<span id=but' + ids[0].textContent + ' class="player_icon_placeholder"><a href="#" onclick="return false"'
  4073. txt += 'title="Stats Xente" class="player_icon"><span class="player_icon_wrapper">'
  4074. 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;'
  4075. txt += 'z-index: 0;"></span><span class="player_icon_text"></span></span></a></span>'
  4076.  
  4077. let index=0
  4078. if(window.stx_device!=="computer"){
  4079. index=1
  4080. }
  4081. elementos_[index].innerHTML += txt;
  4082. (function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
  4083. document.getElementById("but" + currentId).addEventListener('click', function () {
  4084. let link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
  4085. + "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
  4086. "&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
  4087. openWindow(link, 0.95, 1.25);
  4088. });
  4089. })(ids[0].textContent, tid, window.sport, window.lang, "[undefined]", playerName);
  4090. }
  4091. //Country ranking page
  4092. function countryRank() {
  4093. let table_values = ["players", "age", "value", "top11", "salary", "elo", "elo21", "lm", "lmu21"]
  4094. let newContent = "<div style='margin: 0 auto; text-align:center;'>";
  4095. newContent += '<label><input class="statsxente" type="checkbox" checked id="value" value="Value">Value</label>';
  4096. if (window.sport === "soccer") {
  4097. newContent += '<label><input class="statsxente" type="checkbox" id="top11" value="TOP 11">TOP 11</label>';
  4098. } else {
  4099. newContent += '<label><input class="statsxente" type="checkbox" id="top11" value="TOP 21">TOP 21</label>';
  4100. }
  4101.  
  4102. newContent += '<label><input class="statsxente" type="checkbox" id="players" value="Players">Players</label>';
  4103. newContent += '<label><input class="statsxente" type="checkbox" id="salary" value="Salary">Salary</label>';
  4104. newContent += '<label><input class="statsxente" type="checkbox" id="age" value="Age">Age</label>';
  4105. newContent += '<label><input class="statsxente" type="checkbox" checked id="elo" value="Elo">ELO</label>';
  4106. newContent += '<label><input class="statsxente" type="checkbox" checked id="elo21" value="U21 ELO">U21 ELO</label>';
  4107. newContent += '<label><input class="statsxente" type="checkbox" checked id="lm" value="LM">LM</label>';
  4108. newContent += '<label><input class="statsxente" type="checkbox" checked id="lmu21" value="U21 LM">U21 LM</label>';
  4109.  
  4110. let contenedor = document.getElementById('countryRankTable');
  4111. contenedor.insertAdjacentHTML('beforebegin', newContent);
  4112.  
  4113. GM_xmlhttpRequest({
  4114. method: "GET",
  4115. url: "https://statsxente.com/MZ1/Functions/tamper_national_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport,
  4116. headers: {
  4117. "Content-Type": "application/json"
  4118. },
  4119. onload: function (response) {
  4120. let data = JSON.parse(response.responseText);
  4121.  
  4122. let type = 1;
  4123. if (window.sport === "soccer") {
  4124. type = 2
  4125. }
  4126. let table = document.getElementById('countryRankTable');
  4127. for (let i = 0; i < table.rows.length; i++) {
  4128. let row = table.rows[i];
  4129. let insertIndex = row.cells.length - 1;
  4130. let raw_str = row.cells[3].innerHTML
  4131. row.deleteCell(3);
  4132. let cell_name = row.cells[2]
  4133. if (i > 0) {
  4134. cell_name.innerHTML = raw_str + " " + cell_name.innerHTML
  4135. }
  4136. let index = 0;
  4137. let cell0 = row.insertCell(insertIndex + index);
  4138. index++;
  4139. let cell1 = row.insertCell(insertIndex + index);
  4140. index++;
  4141. let cell2 = row.insertCell(insertIndex + index);
  4142. index++;
  4143. let cell3 = row.insertCell(insertIndex + index);
  4144. index++;
  4145. let cell4 = row.insertCell(insertIndex + index);
  4146. index++;
  4147. let cell5 = row.insertCell(insertIndex + index);
  4148. index++;
  4149. let cell6 = row.insertCell(insertIndex + index);
  4150. index++;
  4151. let cell7 = row.insertCell(insertIndex + index);
  4152. index++;
  4153. let cell8 = row.insertCell(insertIndex + index);
  4154. index++;
  4155. let cell9 = row.insertCell(insertIndex + index);
  4156.  
  4157.  
  4158.  
  4159. if (i === 0) {
  4160. cell0.outerHTML = "<th id='players_th' style='display:none;' class='header'><a href='#'>Players</a></th>";
  4161. cell1.outerHTML = "<th id='age_th' class='header' style='display:none;'><a href='#'>Age</a></th>";
  4162. cell2.outerHTML = "<th id='value_th' class='header' style='display:table-cell;'><a href='#'>Value</a></th>";
  4163. cell3.outerHTML = "<th id='top11_th' class='header' style='display:none;'><a href='#'>Top11</a></th>";
  4164. cell4.outerHTML = "<th id='salary_th' class='header' style='display:none;'><a href='#'>Salary</a></th>";
  4165. cell5.outerHTML = "<th id='elo_th' class='header' style='display:table-cell;'><a href='#'>ELO</a></th>";
  4166. cell6.outerHTML = "<th id='elo21_th' class='header' style='display:table-cell;'><a href='#'>U21 ELO</a></th>";
  4167. cell7.outerHTML = "<th id='lm_th' class='header' style='display:table-cell;'><a href='#'>LM</a></th>";
  4168. cell8.outerHTML = "<th id='lmu21_th' class='header' style='display:table-cell;'><a href='#'>U21 LM</a></th>";
  4169. cell9.outerHTML = "<th id='image' class='header' style='display:table-cell;'><a href='#'></a></th>";
  4170. } else {
  4171. let ini = raw_str.indexOf("s_");
  4172. let fin = raw_str.indexOf(".", ini + 1);
  4173. let c_code = raw_str.substring(ini + 2, fin)
  4174. cell0.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["numJugadores"]))
  4175. cell0.className = "players"
  4176. cell0.style.display = "none"
  4177.  
  4178. cell1.innerHTML = new Intl.NumberFormat(window.userLocal, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(data[c_code]["edad"])
  4179. cell1.className = "age"
  4180. cell1.style.display = "none"
  4181.  
  4182. cell2.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valor"]))
  4183. cell2.className = "value"
  4184. cell2.style.display = "table-cell"
  4185.  
  4186. cell3.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valor11"]))
  4187. cell3.className = "top11"
  4188. cell3.style.display = "none"
  4189.  
  4190. cell4.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["salario"]))
  4191. cell4.className = "salary"
  4192. cell4.style.display = "none"
  4193.  
  4194. cell5.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["elo"]))
  4195. cell5.className = "elo"
  4196. cell5.style.display = "table-cell"
  4197.  
  4198. cell6.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["elo21"]))
  4199. cell6.className = "elo21"
  4200. cell6.style.display = "table-cell"
  4201.  
  4202. cell7.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valorLM"]))
  4203. cell7.className = "lm"
  4204. cell7.style.display = "table-cell"
  4205.  
  4206. cell8.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valorLM21"]))
  4207. cell8.className = "lmu21"
  4208. cell8.style.display = "table-cell"
  4209.  
  4210. cell9.innerHTML = '<img alt="" style="cursor:pointer;" src="https://statsxente.com/MZ1/View/Images/calendar.png" width="20" height="20">'
  4211. let actual_id = "image" + i
  4212. cell9.id = actual_id
  4213. cell9.style.display = "table-cell";
  4214.  
  4215.  
  4216. (function (id, code, type_) {
  4217. document.getElementById(id).addEventListener('click', function () {
  4218. let link = "https://www.statsxente.com/MZ1/Graficos/graficoRachaEquipoELONT.php?tamper=yes&team_id=" + data[code]["idSenior"] +
  4219. "&team_id_u21=" + data[code]["idSub21"] + "&idioma=" + window.lang + "&type=" + type_ + "&cat=SENIOR&sport=" + window.sport;
  4220. openWindow(link, 0.95, 1.25);
  4221. });
  4222. })(actual_id, c_code, type);
  4223. }
  4224. }
  4225.  
  4226. setTimeout(function () {
  4227. for (let f = 0; f < table_values.length; f++) {
  4228.  
  4229. (function (actual_value, f) {
  4230.  
  4231. document.getElementById(actual_value + "_th").addEventListener('click', function () {
  4232. if (document.getElementById(actual_value + "_th").className === "header") {
  4233. document.getElementById(actual_value + "_th").className = "header headerSortDown";
  4234. } else {
  4235.  
  4236. if (document.getElementById(actual_value + "_th").className === "header headerSortDown") {
  4237. document.getElementById(actual_value + "_th").className = "header headerSortUp";
  4238. } else {
  4239. document.getElementById(actual_value + "_th").className = "header headerSortDown";
  4240. }
  4241.  
  4242. }
  4243. let index_ = 3 + f
  4244. ordenarTabla(index_, false, "countryRankTable",false)
  4245. });
  4246. document.getElementById(actual_value).addEventListener('click', function () {
  4247. let display = "table-cell"
  4248. if (document.getElementById(actual_value + "_th").style.display === "table-cell") {
  4249. display = "none"
  4250. }
  4251. let elementos = document.getElementsByClassName(actual_value)
  4252. Array.prototype.forEach.call(elementos, function (elemento) {
  4253. let aux_display = "table-cell"
  4254. if (document.getElementById(actual_value + "_th").style.display === "table-cell") {
  4255. aux_display = "none"
  4256. }
  4257. elemento.style.display = aux_display;
  4258. });
  4259. document.getElementById(actual_value + "_th").style.display = display
  4260. });
  4261. })(table_values[f], f);
  4262. }
  4263. }, 1000);
  4264. }
  4265. });
  4266. }
  4267. //Stats Xente competitions matches
  4268. function StatsXenteNextMatchesClubhouse() {
  4269. let h1Elements = document.querySelectorAll('h1.box_dark');
  4270. let team_name = h1Elements[0].innerText
  4271. let team_id = document.getElementById("tid1").value;
  4272.  
  4273. GM_xmlhttpRequest({
  4274. method: "GET",
  4275. url: "https://statsxente.com/MZ1/Functions/tamper_user_next_matches.php?team_id=" + team_id,
  4276. headers: {
  4277. "Content-Type": "application/json"
  4278. },
  4279. onload: function (response) {
  4280. let data = JSON.parse(response.responseText);
  4281. if (data.length > 0) {
  4282.  
  4283.  
  4284. GM_xmlhttpRequest({
  4285. method: "GET",
  4286. url: "http://www.managerzone.com/xml/team_matchlist.php?sport_id=" + window.sport_id + "&team_id=" + team_id + "&match_status=2&limit=100",
  4287. headers: {
  4288. "Content-Type": "application/json"
  4289. },
  4290. onload: function (response) {
  4291.  
  4292. let matchesDate = []
  4293. let parser = new DOMParser();
  4294. let xmlDoc = parser.parseFromString(response.responseText, "text/xml");
  4295. let matches = xmlDoc.getElementsByTagName("Match");
  4296.  
  4297. let last_date = ""
  4298.  
  4299.  
  4300. for (let i = 0; i < matches.length; i++) {
  4301. let dateOnly = matches[i].getAttribute("date").split(" ")[0];
  4302. last_date = dateOnly
  4303. let teams = matches[i].getElementsByTagName("Team");
  4304.  
  4305. for (let j = 0; j < teams.length; j++) {
  4306. if (teams[j].getAttribute("teamId") !== team_id) {
  4307. matchesDate.push(teams[j].getAttribute("teamId") + "-" + dateOnly)
  4308.  
  4309. }
  4310. }
  4311.  
  4312.  
  4313. }
  4314.  
  4315.  
  4316.  
  4317.  
  4318. let newContent = `
  4319. <div id="tour-container" class="widgets-container">
  4320. <div class="flex-wrap hub-widget-container">
  4321. <div class="flex-grow-1 box_dark">
  4322. <div id="clubhouse-widget-tour" class="widget-content clearfix">
  4323. <i class="fa minimize-button fa-minus-square" aria-hidden="true" data-time="1722549599"></i>
  4324. <span class="fa fa-stack fa-2x floatRight">
  4325. <i class="fa fa-circle fa-stack-2x fa-inverse"></i>
  4326. <i class="fa fa-thumbs-up fa-stack-1x green" aria-hidden="true"></i>
  4327. </span>
  4328. <h3 style="background-image: url('https://www.statsxente.com/MZ1/View/Images/main_icon.png');">Stats Xente</h3>
  4329. <div class="widget-content-wrapper">
  4330. <div class="flex-wrap" style="margin-bottom: 35px;">
  4331. <div class="flex-grow-0" style="margin: 0 auto">
  4332. <img src="https://www.statsxente.com/MZ1/View/Images/main_icon.png" alt="" width="130" height="130">
  4333. </div>
  4334. <div class="flex-grow-1 textLeft">`
  4335.  
  4336. data.forEach(function (match_data) {
  4337.  
  4338. let dateObj1 = new Date(last_date);
  4339. let dateObj2 = new Date(match_data['fecha']);
  4340.  
  4341.  
  4342. let icon_ = "fa-check-square"
  4343. let style_ = ""
  4344. let flagFriendly = false;
  4345. if (dateObj1 < dateObj2) {
  4346. icon_ = "fa-calendar-minus-o"
  4347. style_ = "style='color:#e5ac00;'"
  4348. flagFriendly = true;
  4349. } else {
  4350.  
  4351. if (matchesDate.includes(match_data['rival_id'] + "-" + match_data['fecha'])) {
  4352. if (window.sport === "hockey") {
  4353. style_ = "style='color:#6d93fd;'"
  4354. }
  4355. } else {
  4356. icon_ = "fa-times-square"
  4357. style_ = "style='color:#AD4039;'"
  4358. flagFriendly = true;
  4359.  
  4360.  
  4361. }
  4362.  
  4363. }
  4364.  
  4365.  
  4366. let match = '<img alt="" src="https://www.managerzone.com/dynimg/badge.php?team_id=' + match_data['idEquipoLocal'] + '&sport="' + window.sport + ' width="15px" height="15px"/> '
  4367. + 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"/>'
  4368. if (match_data['field'] === "away") {
  4369. match = '<img alt="" src="https://www.managerzone.com/dynimg/badge.php?team_id=' + match_data['idEquipoLocal'] + '&sport="' + window.sport + ' width="15px" height="15px"/> '
  4370. + 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"/>'
  4371. }
  4372.  
  4373.  
  4374. newContent += '<fieldset class="grouping self box_light_on_dark flex-nowrap" style="max-width: 555px; margin-left: 10px;">'
  4375. newContent += '<legend>' + match_data['clash_name'] + '</legend>'
  4376. newContent += '<div class="flex-grow-0 mission-icon">'
  4377. newContent += '<i class="fa ' + icon_ + ' green fa-2x t-checked" aria-hidden="true" ' + style_ + '></i>'
  4378. newContent += '</div>'
  4379. newContent += '<div class="flex-grow-1 mission">'
  4380.  
  4381. let link = "CompAmis_CALENDAR_View.php?" + 'id=' + match_data['idComp']
  4382. if (match_data['comp'] === "cup") {
  4383. link = 'CompAmis_Cup_CALENDAR_View.php?grupo=' + match_data['grupo'] + '&id=' + match_data['idComp']
  4384. }
  4385.  
  4386.  
  4387. newContent += '<p><b><a href="https://www.statsxente.com/MZ1/View/' + link + '" target="_blank">' + match + '</a></b>'
  4388. newContent += "</br></p>"
  4389. newContent += 'Date: ' + match_data['fecha']
  4390. if (flagFriendly) {
  4391. 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>"
  4392. }
  4393.  
  4394.  
  4395. newContent += '</p>'
  4396. newContent += '</div>'
  4397. newContent += '</fieldset>'
  4398. });
  4399.  
  4400.  
  4401.  
  4402.  
  4403. newContent += `</div>
  4404. </div>
  4405. </div>
  4406. </div>
  4407. </div>
  4408. </div>
  4409. </div>`;
  4410.  
  4411.  
  4412.  
  4413.  
  4414. let contenedor = document.getElementById('tour-container');
  4415. if (data.length > 0) {
  4416. contenedor.insertAdjacentHTML('beforebegin', newContent);
  4417.  
  4418. }
  4419.  
  4420.  
  4421. }
  4422.  
  4423. });
  4424.  
  4425. }
  4426.  
  4427.  
  4428. }
  4429. });
  4430.  
  4431. }
  4432.  
  4433.  
  4434.  
  4435. //HANDLERS FUNCTIONS
  4436. function handleClick(event) {
  4437.  
  4438. if(document.getElementById("eloCompareCol")){
  4439. document.getElementById("trELOCompare").style.display="none";
  4440. let elems = document.getElementsByClassName("nice_table");
  4441. let table = elems[0]
  4442. let th = document.getElementById("eloCompareCol");
  4443. let columnIndex = th.cellIndex;
  4444. for (let i = 0; i < table.rows.length; i++) {
  4445. let row = table.rows[i];
  4446. if (row.cells.length > columnIndex) {
  4447. row.deleteCell(columnIndex);
  4448. }
  4449. }
  4450. }
  4451.  
  4452. if(document.getElementById("trTeamStats").style.display=="table-row"){
  4453. document.getElementById("trTeamStats").style.display="none";
  4454. }
  4455.  
  4456. let urlParams = new URLSearchParams(window.location.search);
  4457. let elems = document.getElementsByClassName("nice_table");
  4458. let tabla = elems[0]
  4459. let filas = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  4460. let thSegundo = tabla.querySelector("thead th:nth-child(2)");
  4461.  
  4462. if (urlParams.get('fsid')) {
  4463. thSegundo.style.width = "180px";
  4464. } else {
  4465. thSegundo.style.width = "250px";
  4466. }
  4467.  
  4468.  
  4469. for (let i = 0; i < filas.length; i++) {
  4470. if (checkClassNameExists(filas[i], searchClassName)) {
  4471. let celda = filas[i].cells[1];
  4472. let team_data=extractTeamData(celda.getElementsByTagName("a"));
  4473. let id=team_data[0]
  4474. let celdas = filas[i].getElementsByTagName("td");
  4475. let ultimaCelda = celdas[celdas.length - 2];
  4476. let selects = document.getElementsByTagName('select');
  4477. let index_select = 1;
  4478. if (selects[index_select] === undefined) {
  4479. index_select = 0;
  4480. }
  4481.  
  4482.  
  4483. let selectedIndex = selects[index_select].selectedIndex;
  4484. let selectedOption = selects[index_select].options[selectedIndex];
  4485. let selectedText = selectedOption.text;
  4486.  
  4487.  
  4488.  
  4489. let key_actual_league = "Top";
  4490. if (selectedText.includes(".")) {
  4491. key_actual_league = selectedText.substring(0, 4)
  4492. }
  4493.  
  4494. let valor = 0;
  4495.  
  4496. if (teams_data[id] === undefined) {
  4497. valor = 0
  4498. } else {
  4499.  
  4500. let table_key = "";
  4501. let agg_value = 0;
  4502. let cat
  4503.  
  4504. switch (event.target.id) {
  4505. case 'edad':
  4506. valor = new Intl.NumberFormat(window.userLocal, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(teams_data[id][event.target.id])
  4507. break;
  4508. case "leagues":
  4509. table_key = "league"
  4510. 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']
  4511. valor = "(" + teams_data[id]['league_' + key_actual_league] + '/' + agg_value + ")"
  4512. break;
  4513.  
  4514. case "world_leagues":
  4515. table_key = "world_league"
  4516. 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']
  4517. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  4518. break;
  4519.  
  4520. case "youth_leagues":
  4521. cat = GM_getValue("actual_league_cat").toLowerCase()
  4522. table_key = "league_" + cat
  4523. 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']
  4524. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  4525. break;
  4526.  
  4527. case "world_youth_leagues":
  4528. cat = GM_getValue("actual_league_cat").toLowerCase()
  4529. table_key = "world_league_" + cat
  4530. 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']
  4531. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  4532. break;
  4533.  
  4534. case "leagues_all":
  4535. table_key = "league"
  4536. 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']
  4537. break;
  4538.  
  4539.  
  4540. case "world_leagues_all":
  4541. table_key = "world_league"
  4542. 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']
  4543. break;
  4544.  
  4545. case "youth_leagues_all":
  4546. table_key = "league_u23"
  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. table_key = "league_u21"
  4549. 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']
  4550. table_key = "league_u18"
  4551. 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']
  4552. break;
  4553.  
  4554. case "world_youth_leagues_all":
  4555. table_key = "world_league_u23"
  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. table_key = "world_league_u21"
  4558. 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']
  4559. table_key = "world_league_u18"
  4560. 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']
  4561. break;
  4562.  
  4563. case "federation_leagues":
  4564. table_key = "federation_league"
  4565. 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']
  4566. valor = agg_value
  4567. break;
  4568.  
  4569.  
  4570. default:
  4571. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(teams_data[id][event.target.id]))
  4572. break;
  4573.  
  4574.  
  4575. }
  4576. }
  4577.  
  4578. ultimaCelda.innerHTML = valor;
  4579. }
  4580. }
  4581. let checkboxes = document.querySelectorAll('.statsxente');
  4582. let thead = tabla.querySelector('thead');
  4583. let tr = thead.querySelectorAll('tr');
  4584. let td = tr[0].querySelectorAll('th');
  4585. td[td.length - 2].textContent = event.target.value;
  4586. checkboxes.forEach(function (checkbox) {
  4587. if (checkbox.id !== event.target.id) {
  4588. checkbox.checked = false;
  4589. }
  4590. });
  4591. }
  4592. function handleClickClash(event) {
  4593. let elems = document.getElementsByClassName("nice_table");
  4594. let tabla = elems[0]
  4595. let filas = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  4596. let thSegundo = tabla.querySelector("thead th:nth-child(2)");
  4597. thSegundo.style.width = "250px";
  4598. for (let i = 0; i < filas.length; i++) {
  4599. let celda = tabla.rows[i + 1].cells[1];
  4600. let imagen = celda.querySelector('img');
  4601. let url = new URL(imagen.src);
  4602. let id = url.searchParams.get('fid');
  4603.  
  4604.  
  4605. let celdas = filas[i].getElementsByTagName("td");
  4606. let ultimaCelda = celdas[celdas.length - 2];
  4607.  
  4608. let valor = 0;
  4609.  
  4610. if (teams_data[id] === undefined) {
  4611. valor = 0
  4612. } else {
  4613. if (event.target.id === "edad") {
  4614. valor = new Intl.NumberFormat(window.userLocal, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(teams_data[id][event.target.id])
  4615. } else {
  4616. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(teams_data[id][event.target.id]))
  4617. }
  4618.  
  4619. }
  4620.  
  4621. ultimaCelda.innerHTML = valor;
  4622. }
  4623. let checkboxes = document.querySelectorAll('.statsxente');
  4624. let thead = tabla.querySelector('thead');
  4625. let tr = thead.querySelectorAll('tr');
  4626. let td = tr[0].querySelectorAll('th');
  4627. td[td.length - 2].textContent = event.target.value;
  4628. checkboxes.forEach(function (checkbox) {
  4629. if (checkbox.id !== event.target.id) {
  4630. checkbox.checked = false;
  4631. }
  4632. });
  4633. }
  4634. function handleClickUserRank(event) {
  4635. let tabla = document.getElementById("userRankTable");
  4636. let filas = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  4637.  
  4638. for (let i = 0; i < filas.length; i++) {
  4639. let celda = filas[i].cells[3];
  4640. let team_data=extractTeamData(celda.getElementsByTagName("a"));
  4641. let id=team_data[0]
  4642. let equipo=team_data[1]
  4643. let celdas = filas[i].getElementsByTagName("td");
  4644. let ultimaCelda = celdas[celdas.length - 1];
  4645. let selects = document.getElementsByTagName('select');
  4646. let index_select = 1;
  4647. if (selects[index_select] === undefined) {
  4648. index_select = 0;
  4649. }
  4650.  
  4651.  
  4652. let selectedIndex = selects[index_select].selectedIndex;
  4653. let selectedOption = selects[index_select].options[selectedIndex];
  4654. let selectedText = selectedOption.text;
  4655.  
  4656.  
  4657.  
  4658. let key_actual_league = "Top";
  4659. if (selectedText.includes(".")) {
  4660. key_actual_league = selectedText.substring(0, 4)
  4661. }
  4662.  
  4663. let valor = 0;
  4664.  
  4665. if (teams_data[id] === undefined) {
  4666. valor = 0
  4667. } else {
  4668.  
  4669. let table_key = "";
  4670. let agg_value = 0;
  4671. let cat
  4672.  
  4673. switch (event.target.id) {
  4674. case 'edad':
  4675. valor = new Intl.NumberFormat(window.userLocal, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(teams_data[id][event.target.id])
  4676. break;
  4677. case "leagues":
  4678. table_key = "league"
  4679. 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']
  4680. valor = "(" + teams_data[id]['league_' + key_actual_league] + '/' + agg_value + ")"
  4681. break;
  4682.  
  4683. case "world_leagues":
  4684. table_key = "world_league"
  4685. 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']
  4686. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  4687. break;
  4688.  
  4689. case "youth_leagues":
  4690. cat = GM_getValue("actual_league_cat").toLowerCase()
  4691. table_key = "league_" + cat
  4692. 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']
  4693. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  4694. break;
  4695.  
  4696. case "world_youth_leagues":
  4697. cat = GM_getValue("actual_league_cat").toLowerCase()
  4698. table_key = "world_league_" + cat
  4699. 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']
  4700. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  4701. break;
  4702.  
  4703. case "leagues_all":
  4704. table_key = "league"
  4705. 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']
  4706. break;
  4707.  
  4708.  
  4709. case "world_leagues_all":
  4710. table_key = "world_league"
  4711. 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']
  4712. break;
  4713.  
  4714. case "youth_leagues_all":
  4715. table_key = "league_u23"
  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. table_key = "league_u21"
  4718. 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']
  4719. table_key = "league_u18"
  4720. 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']
  4721. break;
  4722.  
  4723. case "world_youth_leagues_all":
  4724. table_key = "world_league_u23"
  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. table_key = "world_league_u21"
  4727. 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']
  4728. table_key = "world_league_u18"
  4729. 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']
  4730. break;
  4731.  
  4732. case "federation_leagues":
  4733. table_key = "federation_league"
  4734. 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']
  4735. valor = agg_value
  4736. break;
  4737.  
  4738.  
  4739. default:
  4740. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(teams_data[id][event.target.id]))
  4741. break;
  4742.  
  4743.  
  4744. }
  4745. }
  4746.  
  4747. ultimaCelda.innerHTML = valor;
  4748.  
  4749. }
  4750. let checkboxes = document.querySelectorAll('.statsxente');
  4751. let thead = tabla.querySelector('thead');
  4752. let tr = thead.querySelectorAll('tr');
  4753. let td = tr[0].querySelectorAll('th');
  4754. td[td.length - 1].innerHTML = '<a href="#">'+event.target.value+'</a>'
  4755. checkboxes.forEach(function (checkbox) {
  4756. if (checkbox.id !== event.target.id) {
  4757. checkbox.checked = false;
  4758. }
  4759. });
  4760. }
  4761.  
  4762. //FETCH FUNCTIONS
  4763. function fetchSelects() {
  4764. return new Promise((resolve, reject) => {
  4765. GM_xmlhttpRequest({
  4766. method: "GET",
  4767. url: "https://statsxente.com/MZ1/Functions/tamper_selects.php",
  4768. headers: {
  4769. "Content-Type": "application/json"
  4770. },
  4771. onload: function (response) {
  4772. let jsonResponse = JSON.parse(response.responseText);
  4773. GM_setValue("posSelect_soccer",jsonResponse['posSelect_soccer'])
  4774. GM_setValue("statsSelect_soccer",jsonResponse['statsSelect_soccer'])
  4775. GM_setValue("statsTeamsSelect_soccer",jsonResponse["statsTeamSelect_soccer"])
  4776. GM_setValue("posSelect_hockey",jsonResponse['posSelect_hockey'])
  4777. GM_setValue("statsSelect_hockey",jsonResponse['statsSelect_hockey'])
  4778. GM_setValue("statsTeamsSelect_hockey",jsonResponse["statsTeamSelect_hockey"])
  4779. GM_setValue("minValues",jsonResponse["minValues"])
  4780. resolve(jsonResponse)
  4781. },
  4782. onerror: function () {
  4783. reject("none");
  4784. }
  4785. });
  4786. });
  4787. }
  4788.  
  4789.  
  4790. function fetchExistsFL(id) {
  4791. return new Promise((resolve, reject) => {
  4792.  
  4793. GM_xmlhttpRequest({
  4794. method: "GET",
  4795. url: "https://statsxente.com/MZ1/Functions/tamper_check_fl.php?fl_id="+id,
  4796. headers: {
  4797. "Content-Type": "application/json"
  4798. },
  4799. onload: function (response) {
  4800.  
  4801. let jsonResponse = JSON.parse(response.responseText);
  4802. resolve(jsonResponse)
  4803. },
  4804. onerror: function () {
  4805. reject("none");
  4806. }
  4807. });
  4808. });
  4809. }
  4810. function fetchAgeRestriction(url) {
  4811. return new Promise((resolve, reject) => {
  4812.  
  4813. GM_xmlhttpRequest({
  4814. method: "GET",
  4815. url: url,
  4816. headers: {
  4817. "Content-Type": "application/json"
  4818. },
  4819. onload: function (response) {
  4820. let parser = new DOMParser();
  4821. let doc = parser.parseFromString(response.responseText, "text/html");
  4822. let strongElements = doc.getElementsByTagName("b");
  4823. let nextSibling = strongElements[1].nextSibling;
  4824. try {
  4825. while (nextSibling && nextSibling.nodeName === "BR") {
  4826. nextSibling = nextSibling.nextSibling;
  4827. }
  4828.  
  4829. if (nextSibling && nextSibling.nodeType === Node.TEXT_NODE) {
  4830. let age_restriction = nextSibling.textContent.trim();
  4831. resolve(age_restriction);
  4832. } else {
  4833. resolve("none");
  4834. }
  4835. } catch (error) {
  4836. reject("none");
  4837. }
  4838. },
  4839. onerror: function () {
  4840. reject("none");
  4841. }
  4842. });
  4843. });
  4844. }
  4845. function fetchCupAgeRestriction(url) {
  4846. return new Promise((resolve, reject) => {
  4847.  
  4848. GM_xmlhttpRequest({
  4849. method: "GET",
  4850. url: url,
  4851. headers: {
  4852. "Content-Type": "application/json"
  4853. },
  4854. onload: function (response) {
  4855. let parser = new DOMParser();
  4856. try {
  4857. let doc = parser.parseFromString(response.responseText, "text/html")
  4858. let tables = doc.getElementsByTagName("table");
  4859.  
  4860. Array.from(tables).forEach((table, index) => {
  4861. if(table.querySelector("#set_default_tactic")){
  4862. let tds = table.getElementsByTagName("td");
  4863. resolve(tds[5].innerHTML)
  4864. }
  4865. });
  4866. let table = tables[1]
  4867. let tds = table.getElementsByTagName("td");
  4868. resolve(tds[5].innerHTML)
  4869. } catch (error) {
  4870. reject("Error fetching age restriction");
  4871. }
  4872. },
  4873. onerror: function () {
  4874. reject("none");
  4875. }
  4876. });
  4877. });
  4878. }
  4879. function fetchExistTeam(url) {
  4880. return new Promise((resolve, reject) => {
  4881.  
  4882. GM_xmlhttpRequest({
  4883. method: "GET",
  4884. url: url,
  4885. headers: {
  4886. "Content-Type": "application/json"
  4887. },
  4888. onload: function (response) {
  4889. let jsonResponse = JSON.parse(response.responseText);
  4890. resolve(jsonResponse['inserted'])
  4891. },
  4892. onerror: function () {
  4893. reject("no");
  4894. }
  4895. });
  4896. });
  4897. }
  4898. function fetchExistPlayers(url) {
  4899. return new Promise((resolve, reject) => {
  4900.  
  4901. GM_xmlhttpRequest({
  4902. method: "GET",
  4903. url: url,
  4904. headers: {
  4905. "Content-Type": "application/json"
  4906. },
  4907. onload: function (response) {
  4908. let jsonResponse = JSON.parse(response.responseText);
  4909. resolve(jsonResponse)
  4910. },
  4911. onerror: function () {
  4912. reject("no");
  4913. }
  4914. });
  4915. });
  4916. }
  4917. function fetchAndProcessPlayerData(link,skill,toChange,device) {
  4918. return new Promise((resolve, reject) => {
  4919.  
  4920. GM_xmlhttpRequest({
  4921. method: 'GET',
  4922. url:link,
  4923. onload: function (response) {
  4924.  
  4925. let parser = new DOMParser();
  4926. let doc = parser.parseFromString(response.responseText, 'text/html');
  4927.  
  4928. let player_cointainer=doc.getElementById("thePlayers_0")
  4929.  
  4930. let elements = player_cointainer.querySelectorAll('.skillval');
  4931. elements.forEach(element => {
  4932.  
  4933. let previousTd = element.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling;
  4934. let maxs = element.getElementsByClassName("maxed")
  4935.  
  4936. let clips = previousTd.getElementsByClassName("clippable")
  4937. if((clips[0].innerText.trim()===skill.trim())&&(maxs.length>0)){
  4938.  
  4939. if(device!=="computer"){
  4940. toChange.style.padding="3px"
  4941. }
  4942. toChange.style.backgroundColor="#db5d5d"
  4943. toChange.style.fontWeight="bold"
  4944. toChange.style.borderRadius="5px"
  4945.  
  4946.  
  4947. }
  4948.  
  4949.  
  4950. });
  4951. resolve("Done")
  4952. },
  4953. onerror: function (error) {
  4954. reject(error);
  4955. }
  4956. });
  4957.  
  4958. }
  4959. );
  4960.  
  4961. }
  4962.  
  4963. //UTILS FUNCTIONS
  4964. function deleteCols(tabla,numColumnas) {
  4965. let filas = tabla.rows;
  4966.  
  4967. for (let i = 0; i < filas.length; i++) {
  4968. // Recorremos las celdas desde la última hasta la columna X+1
  4969. while (filas[i].cells.length > numColumnas) {
  4970. filas[i].deleteCell(numColumnas); // Elimina la columna después de las primeras X
  4971. }
  4972. }
  4973. }
  4974.  
  4975. function waitToDOMArgs(function_to_execute, classToSearch, elementIndex,miliseconds,...args) {
  4976. let interval = setInterval(function () {
  4977. let elements = document.querySelectorAll(classToSearch);
  4978. if (elements.length > 0 && elements[elementIndex]) {
  4979. clearInterval(interval);
  4980. clearTimeout(timeout);
  4981. function_to_execute(...args);
  4982. }
  4983. }, 100);
  4984.  
  4985.  
  4986. let timeout = setTimeout(function () {
  4987. clearInterval(interval);
  4988. }, miliseconds);
  4989. }
  4990.  
  4991.  
  4992. function waitToDOM(function_to_execute, classToSearch, elementIndex,miliseconds) {
  4993. let interval = setInterval(function () {
  4994. let elements = document.querySelectorAll(classToSearch);
  4995. if (elements.length > 0 && elements[elementIndex]) {
  4996. clearInterval(interval);
  4997. clearTimeout(timeout);
  4998. function_to_execute();
  4999. }
  5000. }, 100);
  5001.  
  5002.  
  5003. let timeout = setTimeout(function () {
  5004. clearInterval(interval);
  5005. }, miliseconds);
  5006. }
  5007.  
  5008. function waitToDOMByIdArgs(function_to_execute, idToSearch,miliseconds,...args) {
  5009. let interval = setInterval(function () {
  5010. let element = document.getElementById(idToSearch);
  5011. if (element) {
  5012. clearInterval(interval);
  5013. clearTimeout(timeout);
  5014. function_to_execute(...args);
  5015. }
  5016. }, 100);
  5017.  
  5018.  
  5019. let timeout = setTimeout(function () {
  5020. clearInterval(interval);
  5021. }, miliseconds);
  5022. }
  5023.  
  5024.  
  5025.  
  5026. function waitToDOMById(function_to_execute, idToSearch,miliseconds) {
  5027. let interval = setInterval(function () {
  5028. let element = document.getElementById(idToSearch);
  5029. if (element) {
  5030. clearInterval(interval);
  5031. clearTimeout(timeout);
  5032. function_to_execute();
  5033. }
  5034. }, 100);
  5035.  
  5036.  
  5037. let timeout = setTimeout(function () {
  5038. clearInterval(interval);
  5039. }, miliseconds);
  5040. }
  5041. function openWindow(link, porAncho, porAlto) {
  5042. let ventanaAncho = (window.innerWidth) * porAncho
  5043. let ventanaAlto = (window.innerHeight) * porAlto
  5044. let ventanaIzquierda = (window.innerWidth - ventanaAncho) / 2;
  5045. let ventanaArriba = (window.innerHeight - ventanaAlto) / 2;
  5046. let opcionesVentana = "width=" + ventanaAncho +
  5047. ",height=" + ventanaAlto +
  5048. ",left=" + ventanaIzquierda +
  5049. ",top=" + ventanaArriba;
  5050.  
  5051. if ((GM_getValue("tabsConfig") === false) && (GM_getValue("windowsConfig") === true)) {
  5052. window.open(link, "_blank", opcionesVentana);
  5053. }
  5054. if ((GM_getValue("tabsConfig") === true) && (GM_getValue("windowsConfig") === false)) {
  5055. window.open(link, "_blank");
  5056. }
  5057. }
  5058. function ordenarTabla(col, byClassName, param,putSortIconFlag) {
  5059. let table
  5060. if (byClassName) {
  5061. let elems = document.getElementsByClassName(param);
  5062. table = elems[0]
  5063. } else {
  5064. table = document.getElementById(param)
  5065. }
  5066. if(putSortIconFlag){putSortIcon(col, table)}
  5067. let rows = Array.from(table.tBodies[0].rows);
  5068. let isAsc = document.getElementById("ord_table").value === "ascendente";
  5069. rows.sort(function (a, b) {
  5070. /*let aNum = parseFloat(a.cells[col].textContent.trim().replace(/\./g, '').replace(/,/g, '')) || 0;
  5071. let bNum = parseFloat(b.cells[col].textContent.trim().replace(/\./g, '').replace(/,/g, '')) || 0;*/
  5072. let aNum=parseNumber(a.cells[col].textContent.trim())
  5073. let bNum=parseNumber(b.cells[col].textContent.trim())
  5074. return isAsc ? aNum - bNum : bNum - aNum;
  5075. });
  5076.  
  5077. rows.forEach(function (row) {
  5078. table.tBodies[0].appendChild(row);
  5079. });
  5080.  
  5081. if (isAsc) {
  5082. document.getElementById("ord_table").value = "descendente";
  5083. } else {
  5084. document.getElementById("ord_table").value = "ascendente";
  5085. }
  5086.  
  5087. let filas = table.getElementsByTagName("tr");
  5088. for (let i = 1; i < filas.length; i++) {
  5089. let primeraCelda = filas[i].getElementsByTagName("td")[0];
  5090. primeraCelda.textContent = i;
  5091. }
  5092.  
  5093.  
  5094. }
  5095.  
  5096.  
  5097. async function getSelects(){
  5098. const actual_date=getActualDate()
  5099. if(actual_date!==GM_getValue("date_checked_selects")){
  5100. GM_setValue("date_checked_selects", actual_date)
  5101. var selects_data=await fetchSelects()
  5102. }
  5103. }
  5104.  
  5105.  
  5106.  
  5107. function ordenarTablaText(col, byClassName, param,putSortIconFlag) {
  5108. let table = document.getElementById(param)
  5109. let rows = Array.from(table.tBodies[0].rows);
  5110. let isAsc = document.getElementById("ord_table").value === "ascendente";
  5111. if(putSortIconFlag){putSortIcon(col, table)}
  5112. rows.sort(function (a, b) {
  5113. let aText = a.cells[col].textContent.toLowerCase().trim();
  5114. let bText = b.cells[col].textContent.toLowerCase().trim();
  5115. if (aText < bText) {
  5116. return isAsc ? -1 : 1;
  5117. }
  5118. if (aText > bText) {
  5119. return isAsc ? 1 : -1;
  5120. }
  5121. return 0;
  5122. });
  5123.  
  5124. rows.forEach(function (row) {
  5125. table.tBodies[0].appendChild(row);
  5126. });
  5127.  
  5128. if (isAsc) {
  5129. document.getElementById("ord_table").value = "descendente";
  5130. } else {
  5131. document.getElementById("ord_table").value = "ascendente";
  5132. }
  5133.  
  5134.  
  5135. let filas = table.getElementsByTagName("tr");
  5136. for (let i = 1; i < filas.length; i++) {
  5137. let primeraCelda = filas[i].getElementsByTagName("td")[0];
  5138. primeraCelda.textContent = i;
  5139. }
  5140.  
  5141. }
  5142. function checkClassNameExists(element, className) {
  5143. if (className === "") {
  5144. return true;
  5145. } else {
  5146. return element.classList.contains(className);
  5147. }
  5148. }
  5149. function getCookie(nombre) {
  5150. let regex = new RegExp("(?:(?:^|.*;\\s*)" + nombre + "\\s*\\=\\s*([^;]*).*$)|^.*$");
  5151. let valorCookie = document.cookie.replace(regex, "$1");
  5152. return decodeURIComponent(valorCookie);
  5153. }
  5154. function generateValuesSelect(cat) {
  5155.  
  5156.  
  5157. let defaults = new Map();
  5158. defaults.set('senior', 'valor');
  5159. defaults.set('u23', 'valor23');
  5160. defaults.set('u21', 'valor21');
  5161. defaults.set('u18', 'valor18');
  5162.  
  5163. let values = new Map();
  5164. values.set('valor', 'Value');
  5165. values.set('valor23', 'U23 Value');
  5166. values.set('valor21', 'U21 Value');
  5167. values.set('valor18', 'U18 Value');
  5168. values.set('salario', 'Salary');
  5169. values.set('valorUPSenior', 'LM Value');
  5170. values.set('valorUPSUB23', 'U23 LM Value');
  5171. values.set('valorUPSUB21', 'U21 LM Value');
  5172. values.set('valorUPSUB18', 'U18 LM Value');
  5173. values.set('edad', 'Age');
  5174. values.set('valor11', 'TOP 11/21');
  5175. values.set('valor11_23', 'U23 TOP 11/21');
  5176. values.set('valor11_21', 'U21 TOP 11/21');
  5177. values.set('valor11_18', 'U18 TOP 11/21');
  5178. values.set('noNac', 'Foreigners');
  5179. values.set('elo', 'ELO Score');
  5180. values.set('elo23', 'U23 ELO Score');
  5181. values.set('elo21', 'U21 ELO Score');
  5182. values.set('elo18', 'U18 ELO Score');
  5183. values.set('numJugadores', 'Number of players');
  5184.  
  5185.  
  5186. let default_value = GM_getValue("league_default_" + cat, defaults.get(cat))
  5187. GM_setValue("league_default_" + cat, default_value)
  5188.  
  5189. let select = "<select id='league_default_select_" + cat + "' style='width:9em;'>";
  5190. values.forEach((valor, clave) => {
  5191. let checked = ""
  5192. if (clave === default_value) {
  5193. checked = "selected"
  5194. }
  5195. select += "<option " + checked + " value='" + clave + "'>" + valor + "</option>";
  5196. });
  5197. select += "</select>"
  5198. return select;
  5199.  
  5200. }
  5201. function createLeagueConfigOptionsListeners() {
  5202.  
  5203. let defaults = new Map();
  5204. defaults.set('senior', 'valor');
  5205. defaults.set('u23', 'valor23');
  5206. defaults.set('u21', 'valor21');
  5207. defaults.set('u18', 'valor18');
  5208.  
  5209.  
  5210.  
  5211. defaults.forEach((valor, clave) => {
  5212.  
  5213.  
  5214.  
  5215. document.getElementById("league_default_select_" + clave).addEventListener('change', function () {
  5216.  
  5217. let selectElement = document.getElementById("league_default_select_" + clave);
  5218. GM_setValue("league_default_" + clave, selectElement.value)
  5219. });
  5220.  
  5221. });
  5222. document.getElementById("league_graph_check").addEventListener('click', function () {
  5223.  
  5224. if (document.getElementById("league_graph_check").checked) {
  5225. GM_setValue("league_graph_button", "checked")
  5226. } else {
  5227. GM_setValue("league_graph_button", "")
  5228. }
  5229.  
  5230.  
  5231. });
  5232.  
  5233.  
  5234. document.getElementById("league_report_check").addEventListener('click', function () {
  5235.  
  5236. if (document.getElementById("league_report_check").checked) {
  5237. GM_setValue("league_report_button", "checked")
  5238. } else {
  5239. GM_setValue("league_report_button", "")
  5240. }
  5241.  
  5242.  
  5243. });
  5244.  
  5245. document.getElementById("league_calendar_check").addEventListener('click', function () {
  5246.  
  5247. if (document.getElementById("league_calendar_check").checked) {
  5248. GM_setValue("league_calendar_button", "checked")
  5249. } else {
  5250. GM_setValue("league_calendar_button", "")
  5251. }
  5252.  
  5253.  
  5254. });
  5255.  
  5256.  
  5257.  
  5258.  
  5259.  
  5260.  
  5261. }
  5262. function createModalMenu() {
  5263. let newElement = document.createElement("div");
  5264. newElement.id = "legendDiv";
  5265. newElement.className = "stx_legend";
  5266. let txtToInsert= '<div style="writing-mode: tb-rl;-webkit-writing-mode: vertical-rl; margin: 0 auto; text-align:center;">'
  5267. if(GM_getValue("available_new_version")==="yes"){
  5268. txtToInsert+='<img alt="" src="https://statsxente.com/MZ1/View/Images/alert.png" style="width:15px;height:15px;"/>'
  5269. }
  5270. txtToInsert+='<img alt="" src="https://statsxente.com/MZ1/View/Images/main_icon.png" style="width:25px;height:25px;"/>'
  5271. txtToInsert+='</div>';
  5272. newElement.innerHTML=txtToInsert;
  5273. let body = document.body;
  5274. body.appendChild(newElement);
  5275.  
  5276. let newModalElement = document.createElement('div');
  5277. 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>'
  5278. body.insertBefore(newModalElement, body.firstChild);
  5279.  
  5280. if (GM_getValue("leagueFlag") === undefined) {
  5281. GM_setValue("leagueFlag", true)
  5282. }
  5283.  
  5284. if (GM_getValue("matchFlag") === undefined) {
  5285. GM_setValue("matchFlag", true)
  5286. }
  5287.  
  5288. if (GM_getValue("federationFlag") === undefined) {
  5289. GM_setValue("federationFlag", true)
  5290. }
  5291.  
  5292. if (GM_getValue("playersFlag") === undefined) {
  5293. GM_setValue("playersFlag", true)
  5294. }
  5295.  
  5296. if (GM_getValue("countryRankFlag") === undefined) {
  5297. GM_setValue("countryRankFlag", true)
  5298. }
  5299.  
  5300.  
  5301. if (GM_getValue("league_graph_button") === undefined) {
  5302. GM_setValue("league_graph_button", "checked")
  5303. }
  5304.  
  5305. if (GM_getValue("league_report_button") === undefined) {
  5306. GM_setValue("league_report_button", "checked")
  5307. }
  5308.  
  5309. if (GM_getValue("league_calendar_button") === undefined) {
  5310. GM_setValue("league_calendar_button", "checked")
  5311. }
  5312.  
  5313. if (GM_getValue("windowsConfig") === undefined) {
  5314. GM_setValue("windowsConfig", true)
  5315. }
  5316.  
  5317. if (GM_getValue("tabsConfig") === undefined) {
  5318. GM_setValue("tabsConfig", false)
  5319. }
  5320.  
  5321. if (GM_getValue("show_league_selects") === undefined) {
  5322. GM_setValue("show_league_selects", true)
  5323. }
  5324.  
  5325. if (GM_getValue("league_image_size") === undefined) {
  5326. GM_setValue("league_image_size", 20)
  5327. }
  5328.  
  5329. if (GM_getValue("eloNextMatchesFlag") === undefined) {
  5330. GM_setValue("eloNextMatchesFlag", true)
  5331. }
  5332.  
  5333. if (GM_getValue("eloPlayedMatchesFlag") === undefined) {
  5334. GM_setValue("eloPlayedMatchesFlag", true)
  5335. }
  5336.  
  5337. if (GM_getValue("teamPageFlag") === undefined) {
  5338. GM_setValue("teamPageFlag", true)
  5339. }
  5340.  
  5341. if (GM_getValue("trainingReportFlag") === undefined) {
  5342. GM_setValue("trainingReportFlag", true)
  5343. }
  5344. if (GM_getValue("eloHiddenPlayedMatchesFlag") === undefined) {
  5345. GM_setValue("eloHiddenPlayedMatchesFlag", true)
  5346. }
  5347.  
  5348. if (GM_getValue("flFlag") === undefined) {
  5349. GM_setValue("flFlag", true)
  5350. }
  5351.  
  5352. if (GM_getValue("cupFlag") === undefined) {
  5353. GM_setValue("cupFlag", true)
  5354. }
  5355.  
  5356.  
  5357.  
  5358.  
  5359.  
  5360.  
  5361.  
  5362.  
  5363. let leagueFlag = "", matchFlag = "", federationFlag = "", playersFlag = "", countryRankFlag = "",eloNextMatchesFlag="",
  5364. eloPlayedMatchesFlag="",teamFlag="",trainingReportFlag="",eloHiddenPlayedMatchesFlag="",flFlag="",cupFlag=""
  5365.  
  5366. if (GM_getValue("federationFlag")) federationFlag = "checked"
  5367. if (GM_getValue("matchFlag")) matchFlag = "checked"
  5368. if (GM_getValue("leagueFlag")) leagueFlag = "checked"
  5369. if (GM_getValue("playersFlag")) playersFlag = "checked"
  5370. if (GM_getValue("countryRankFlag")) countryRankFlag = "checked"
  5371. if (GM_getValue("eloNextMatchesFlag")) eloNextMatchesFlag = "checked"
  5372. if (GM_getValue("eloPlayedMatchesFlag")) eloPlayedMatchesFlag = "checked"
  5373. if (GM_getValue("teamPageFlag")) teamFlag = "checked"
  5374. if (GM_getValue("trainingReportFlag")) trainingReportFlag = "checked"
  5375. if (GM_getValue("eloHiddenPlayedMatchesFlag")) eloHiddenPlayedMatchesFlag = "checked"
  5376. if (GM_getValue("flFlag")) flFlag = "checked"
  5377. if (GM_getValue("cupFlag")) cupFlag = "checked"
  5378.  
  5379.  
  5380.  
  5381.  
  5382.  
  5383. 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>'
  5384. 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%;">'
  5385. newContent +='</br><table style="width:75%; margin: 0 auto; text-align:left;"><tbody><tr>';
  5386. newContent += '<td><label class="containerPeqAmarillo">League<input type="checkbox" id="leagueSelect" ' + leagueFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  5387. newContent += '<td><label class="containerPeqAmarillo">Federation<input type="checkbox" id="federationSelect" ' + federationFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  5388. newContent += '<td><label class="containerPeqAmarillo">Match<input type="checkbox" id="matchSelect" ' + matchFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  5389. newContent += '<td><label class="containerPeqAmarillo">ELO Changes<input type="checkbox" id="eloPlayedSelect" ' + eloPlayedMatchesFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  5390. newContent += '<td><label class="containerPeqAmarillo">Training Report<input type="checkbox" id="trainingReportSelect" ' + trainingReportFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  5391. newContent += '</tr><tr>'
  5392. newContent += '<td><label class="containerPeqAmarillo">Players<input type="checkbox" id="playersSelect" ' + playersFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  5393. newContent += '<td><label class="containerPeqAmarillo">Country Rank<input type="checkbox" id="countryRankSelect" ' + countryRankFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  5394. newContent += '<td><label class="containerPeqAmarillo">Team<input type="checkbox" id="teamSelect" ' + teamFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  5395. newContent += '<td><label class="containerPeqAmarillo">ELO Teams Scores<input type="checkbox" id="eloScheduledSelect" ' + eloNextMatchesFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  5396. newContent += '</tr><tr>'
  5397. newContent += '<td><label class="containerPeqAmarillo">ELO Hidden Played Matches<input type="checkbox" id="eloHiddenPlayedMatchesSelect" ' + eloHiddenPlayedMatchesFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  5398.  
  5399. newContent += '<td><label class="containerPeqAmarillo">Friendly Leagues<input type="checkbox" id="flFlagSelect" ' + flFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  5400. newContent += '<td><label class="containerPeqAmarillo">Cups<input type="checkbox" id="cupFlagSelect" ' + cupFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  5401.  
  5402. newContent += "</tr></tbody></table>"
  5403.  
  5404. newContent += "<hr>"
  5405. newContent += "<h3 style='text-align: left; padding-left:7px;'>Leagues Config</h3>"
  5406.  
  5407. newContent += "<table style='margin: 0 auto; text-align:center;'><tr>"
  5408. newContent += "<td>Default Senior Param: <td>" + generateValuesSelect('senior') + "</td>";
  5409. newContent += "<td>Default U23 Param: <td>" + generateValuesSelect('u23') + "</td>";
  5410. newContent += "<td>Default U21 Param: <td>" + generateValuesSelect('u21') + "</td>";
  5411. newContent += "<td>Default U18 Param: <td>" + generateValuesSelect('u18') + "</td>";
  5412.  
  5413. newContent += "</tr><tr>"
  5414.  
  5415.  
  5416. let checked_graph = GM_getValue("league_graph_button")
  5417. let checked_report = GM_getValue("league_report_button")
  5418. let checked_calendar = GM_getValue("league_calendar_button")
  5419.  
  5420. 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>"
  5421. 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>"
  5422.  
  5423. 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>"
  5424.  
  5425. newContent += '</tr><tr>';
  5426.  
  5427. 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">'
  5428. newContent += '<img alt="" class="textMiddle" id="testImage" src="https://statsxente.com/MZ1/View/Images/calendar.png" width="20px" height="20px"/>'
  5429. newContent += '<span class="textMiddle" style="padding-left:10px;" id="sizeImageLeagueSpan"> (' + GM_getValue("league_image_size") + ')</span></label></center></td>'
  5430.  
  5431.  
  5432.  
  5433. let checkedLeagueSelects = ""
  5434. if (GM_getValue("show_league_selects")) {
  5435. checkedLeagueSelects = "checked"
  5436. }
  5437.  
  5438. 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>'
  5439. newContent += "</tr></table>"
  5440. newContent += "<hr>"
  5441. newContent += "<h3 style='text-align: left; padding-left:7px;'>Tabs Config</h3>"
  5442. newContent += "<table style='display:flex;'><tr><td>"
  5443.  
  5444. let checkedTab = ""
  5445. if (GM_getValue("tabsConfig")) {
  5446. checkedTab = "checked"
  5447. }
  5448.  
  5449. let checkedWin = ""
  5450. if (GM_getValue("windowsConfig")) {
  5451. checkedWin = "checked"
  5452. }
  5453.  
  5454.  
  5455. newContent += "<label><input type='checkbox' id='windowsConfig' " + checkedWin + ">Windows</label>";
  5456. newContent += "<label><input type='checkbox' id='tabsConfig' " + checkedTab + ">Tabs</label>";
  5457. newContent += "</td></tr></table></br>"
  5458.  
  5459. if(GM_getValue("available_new_version")==="yes"){
  5460. newContent += '<div style="padding-bottom:10px; margin: 0 auto; text-align:center;"><h2>New vesion available: '+GM_getValue("stx_latest_version")+'</h2></div>'
  5461. }
  5462.  
  5463.  
  5464.  
  5465.  
  5466.  
  5467. newContent += '<div style="padding-bottom:10px; margin: 0 auto; text-align:center;">'
  5468. if(GM_getValue("available_new_version")==="yes"){
  5469. newContent += '<button class="btn-update" id="updateButton"><i class="bi bi-arrow-down-circle-fill" style="font-style:normal;"> Update</i></button>'
  5470. }
  5471. 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>'
  5472. newContent+='</br></br>'
  5473. newContent +='<button class="btn-save" id="saveButton"><i class="bi bi-house-door-fill" style="font-style:normal;">Save</i></button>'
  5474. newContent+='<button id="deleteButton" class="btn-delete" style="margin-left:10px;"><i class="bi bi-trash-fill" style="font-style:normal;">Reset</i></button>'
  5475. newContent+='</div>';
  5476. newContent += '</div></center></br></br>';
  5477. document.getElementById("contenido_modal_cargando-stx").innerHTML = newContent
  5478. createLeagueConfigOptionsListeners();
  5479. document.getElementById("contenido_modal_cargando-stx").style.width = "75%";
  5480. document.getElementById("myModal_cargando-stx").style.display = "none"
  5481. getNativeTableStyles()
  5482.  
  5483. document.getElementById("alert_tittle").style.backgroundColor = GM_getValue("bg_native")
  5484.  
  5485. if(GM_getValue("available_new_version")==="yes"){
  5486.  
  5487. document.getElementById("updateButton").addEventListener('click', function () {
  5488. GM_setValue("date_checked_version","-")
  5489. window.open("https://update.greasyfork.org/scripts/491442/Stats%20Xente%20Script.user.js", "_blank");
  5490. });
  5491. }
  5492.  
  5493.  
  5494.  
  5495.  
  5496.  
  5497. document.getElementById("legendDiv").addEventListener('click', function () {
  5498.  
  5499. if (document.getElementById("myModal_cargando-stx").style.display === "none") {
  5500. document.getElementById("myModal_cargando-stx").style.display = "flex";
  5501. } else {
  5502. document.getElementById("myModal_cargando-stx").style.display = "none";
  5503. }
  5504.  
  5505. });
  5506.  
  5507.  
  5508. document.getElementById("closeButton").addEventListener('click', function () {
  5509. document.getElementById("myModal_cargando-stx").style.display = "none";
  5510. });
  5511.  
  5512.  
  5513. document.getElementById("saveButton").addEventListener('click', function () {
  5514. window.location.reload();
  5515. });
  5516.  
  5517.  
  5518.  
  5519.  
  5520. (function () {
  5521. document.getElementById("deleteButton").addEventListener('click', function () {
  5522. let keys = GM_listValues();
  5523. keys.forEach(function (key) {
  5524. GM_deleteValue(key);
  5525. });
  5526. window.location.reload();
  5527. });
  5528. })();
  5529.  
  5530. (function () {
  5531. document.getElementById("reloadSelects").addEventListener('click', function () {
  5532. GM_setValue("date_checked_selects","0")
  5533. getSelects()
  5534. window.location.reload();
  5535. });
  5536. })();
  5537.  
  5538.  
  5539.  
  5540.  
  5541.  
  5542. // }, 3000);
  5543.  
  5544. }
  5545. function getNativeTableStyles() {
  5546. let elemento = document.querySelector('.subheader.clearfix');
  5547. if (elemento) {
  5548. let estilo = getComputedStyle(elemento);
  5549. let bg = estilo.backgroundColor
  5550. let color = "white"
  5551. if (estilo.backgroundColor === "rgba(0, 0, 0, 0)") {
  5552. bg = "#a9b0b4"
  5553. }
  5554. GM_setValue("bg_native", bg)
  5555. GM_setValue("color_native", color)
  5556. }
  5557.  
  5558.  
  5559. }
  5560.  
  5561.  
  5562. function evaluarExpresion(expresion, datos) {
  5563. // Reemplazamos las claves en la expresión con sus valores reales
  5564. Object.keys(datos).forEach(clave => {
  5565. expresion = expresion.replace(new RegExp(`\\b${clave}\\b`, 'g'), datos[clave]);
  5566. });
  5567.  
  5568. // Evaluamos la expresión de manera segura usando Function
  5569. return new Function(`return ${expresion};`)();
  5570. }
  5571.  
  5572.  
  5573.  
  5574.  
  5575. function getDeviceFormat(){
  5576. if(!document.getElementById("deviceFormatStx")){
  5577. var script = document.createElement('script');
  5578. script.textContent = `
  5579. var newElemenDeviceSTX = document.createElement("input");
  5580. newElemenDeviceSTX.id= "deviceFormatStx";
  5581. newElemenDeviceSTX.type = "hidden";
  5582. newElemenDeviceSTX.value=window.device;
  5583. document.body.appendChild(newElemenDeviceSTX);
  5584.  
  5585. `;
  5586. document.documentElement.appendChild(script);
  5587. script.remove();
  5588.  
  5589. window.stx_device=document.getElementById("deviceFormatStx").value
  5590. }
  5591. }
  5592. function extractTeamData(as){
  5593. let main_a=""
  5594. Array.from(as).forEach(a => {
  5595. if (a.href.includes('tid')) {
  5596. main_a=a
  5597. }
  5598. })
  5599. let href = main_a.getAttribute('href');
  5600. let urlParams = new URLSearchParams(href.split('?')[1]);
  5601. return [urlParams.get('tid'),main_a.textContent]
  5602.  
  5603. }
  5604. function createModalEventListeners() {
  5605. document.getElementById('leagueSelect').addEventListener('click', function () {
  5606. GM_setValue("leagueFlag", !GM_getValue("leagueFlag"))
  5607. });
  5608.  
  5609.  
  5610. document.getElementById('federationSelect').addEventListener('click', function () {
  5611. GM_setValue("federationFlag", !GM_getValue("federationFlag"))
  5612. });
  5613.  
  5614. document.getElementById('matchSelect').addEventListener('click', function () {
  5615. GM_setValue("matchFlag", !GM_getValue("matchFlag"))
  5616. });
  5617.  
  5618. document.getElementById('playersSelect').addEventListener('click', function () {
  5619. GM_setValue("playersFlag", !GM_getValue("playersFlag"))
  5620. });
  5621.  
  5622. document.getElementById('countryRankSelect').addEventListener('click', function () {
  5623. GM_setValue("countryRankFlag", !GM_getValue("countryRankFlag"))
  5624. });
  5625.  
  5626. document.getElementById('eloPlayedSelect').addEventListener('click', function () {
  5627.  
  5628. GM_setValue("eloPlayedMatchesFlag", !GM_getValue("eloPlayedMatchesFlag"))
  5629. });
  5630.  
  5631. document.getElementById('eloScheduledSelect').addEventListener('click', function () {
  5632. GM_setValue("eloNextMatchesFlag", !GM_getValue("eloNextMatchesFlag"))
  5633. });
  5634.  
  5635. document.getElementById('eloHiddenPlayedMatchesSelect').addEventListener('click', function () {
  5636. GM_setValue("eloHiddenPlayedMatchesFlag", !GM_getValue("eloHiddenPlayedMatchesFlag"))
  5637. });
  5638.  
  5639.  
  5640. document.getElementById('teamSelect').addEventListener('click', function () {
  5641. GM_setValue("teamPageFlag", !GM_getValue("teamPageFlag"))
  5642. });
  5643.  
  5644. document.getElementById('trainingReportSelect').addEventListener('click', function () {
  5645. GM_setValue("trainingReportFlag", !GM_getValue("trainingReportFlag"))
  5646. });
  5647.  
  5648. document.getElementById('flFlagSelect').addEventListener('click', function () {
  5649. GM_setValue("flFlag", !GM_getValue("flFlag"))
  5650. });
  5651.  
  5652. document.getElementById('cupFlagSelect').addEventListener('click', function () {
  5653. GM_setValue("cupFlag", !GM_getValue("cupFlag"))
  5654. });
  5655.  
  5656.  
  5657. document.getElementById('show_league_checkbox').addEventListener('click', function () {
  5658. GM_setValue("show_league_selects", !GM_getValue("show_league_selects"))
  5659. });
  5660.  
  5661.  
  5662.  
  5663. document.getElementById('windowsConfig').addEventListener('click', function () {
  5664.  
  5665. document.getElementById('tabsConfig').checked = !document.getElementById('windowsConfig').checked;
  5666.  
  5667. GM_setValue("windowsConfig", !GM_getValue("windowsConfig"))
  5668. GM_setValue("tabsConfig", !GM_getValue("tabsConfig"))
  5669.  
  5670.  
  5671. });
  5672.  
  5673.  
  5674. document.getElementById('tabsConfig').addEventListener('click', function () {
  5675. document.getElementById('windowsConfig').checked = !document.getElementById('tabsConfig').checked;
  5676. GM_setValue("windowsConfig", !GM_getValue("windowsConfig"))
  5677. GM_setValue("tabsConfig", !GM_getValue("tabsConfig"))
  5678.  
  5679.  
  5680. });
  5681.  
  5682.  
  5683.  
  5684.  
  5685.  
  5686. (function () {
  5687. document.getElementById("slider_input").addEventListener('input', function () {
  5688. document.getElementById("testImage").style.width = document.getElementById("slider_input").value + "px";
  5689. document.getElementById("testImage").style.height = document.getElementById("slider_input").value + "px";
  5690.  
  5691. document.getElementById("sizeImageLeagueSpan").innerText = "(" + document.getElementById("slider_input").value + ")"
  5692.  
  5693.  
  5694. GM_setValue("league_image_size", document.getElementById("slider_input").value)
  5695.  
  5696.  
  5697. });
  5698. })();
  5699.  
  5700. }
  5701. function setLangSportCats() {
  5702.  
  5703.  
  5704. langs.set('es', 'SPANISH');
  5705. langs.set('ar', 'SPANISH')
  5706. langs.set('en', 'ENGLISH');
  5707. langs.set('br', 'PORTUGUES');
  5708. langs.set('pt', 'PORTUGUES');
  5709. langs.set('pl', 'POLISH');
  5710. langs.set('ro', 'ROMANIAN');
  5711. langs.set('tr', 'TURKISH');
  5712.  
  5713. let lanCookie = getCookie("MZLANG");
  5714. if (langs.has(lanCookie)) {
  5715. window.lang = langs.get(lanCookie);
  5716. } else {
  5717. window.lang = "ENGLISH";
  5718. }
  5719. let sportCookie=getSportByMessenger()
  5720. if(sportCookie===""){
  5721. sportCookie = getCookie("MZSPORT");
  5722. }
  5723. if(sportCookie===""){
  5724. sportCookie=getSportByLink()
  5725. }
  5726. if(sportCookie===""){
  5727. sportCookie=getSportByScript()
  5728. }
  5729.  
  5730. let lsport = "F"
  5731. let sport_id = 1;
  5732. if (sportCookie === "hockey") {
  5733. lsport = "H";
  5734. sport_id = 2;
  5735. }
  5736.  
  5737. cats["senior"] = "senior";
  5738. cats["world"] = "seniorw";
  5739. cats["u23"] = "SUB23";
  5740. cats["u21"] = "SUB21";
  5741. cats["u18"] = "SUB18";
  5742. cats["u23_world"] = "SUB23w";
  5743. cats["u21_world"] = "SUB21w";
  5744. cats["u18_world"] = "SUB18w";
  5745.  
  5746.  
  5747. cats_stats["senior"] = "senior";
  5748. cats_stats["world"] = "senior";
  5749. cats_stats["u23"] = "SUB23";
  5750. cats_stats["u21"] = "SUB21";
  5751. cats_stats["u18"] = "SUB18";
  5752. cats_stats["u23_world"] = "SUB23";
  5753. cats_stats["u21_world"] = "SUB21";
  5754. cats_stats["u18_world"] = "SUB18";
  5755. cats_stats["friendlyseries"] = "senior";
  5756.  
  5757.  
  5758. statsKeys["senior_soccer"] = 1
  5759. statsKeys["world_soccer"] = 5
  5760. statsKeys["u23_soccer"] = 3
  5761. statsKeys["u21_soccer"] = 3
  5762. statsKeys["u18_soccer"] = 3
  5763. statsKeys["u23_world_soccer"] = 7
  5764. statsKeys["u21_world_soccer"] = 7
  5765. statsKeys["u18_world_soccer"] = 7
  5766. statsKeys["friendlyseries_soccer"] = 9;
  5767. statsKeys["senior_hockey"] = 2
  5768. statsKeys["world_hockey"] = 6
  5769. statsKeys["u23_hockey"] = 4
  5770. statsKeys["u21_hockey"] = 4
  5771. statsKeys["u18_hockey"] = 4
  5772. statsKeys["u23_world_hockey"] = 8
  5773. statsKeys["u21_world_hockey"] = 8
  5774. statsKeys["u18_world_hockey"] = 8
  5775. statsKeys["friendlyseries_hockey"] = 10;
  5776.  
  5777.  
  5778. window.cats = cats;
  5779. window.sport = sportCookie;
  5780. window.lsport = lsport;
  5781. window.sport_id = sport_id;
  5782. window.userLocal = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.language;
  5783.  
  5784. }
  5785. function getSportByLink(){
  5786. let element = document.getElementById("settings-wrapper");
  5787. if (element) {
  5788. var firstLink = element.getElementsByTagName("a")[0];
  5789. if (firstLink) {
  5790. if(firstLink.href.includes("soccer")){
  5791. return "hockey"
  5792. }else{
  5793. return "soccer"
  5794. }
  5795. }
  5796. }
  5797. }
  5798. function getSportByScript(){
  5799. const script = document.createElement('script');
  5800. script.textContent = `
  5801. let newElement = document.createElement("input");
  5802. newElement.id= "stx_sport";
  5803. newElement.type = "hidden";
  5804. newElement.value=window.ajaxSport;
  5805. let body = document.body;
  5806. body.appendChild(newElement);
  5807.  
  5808. `;
  5809. document.documentElement.appendChild(script);
  5810. script.remove();
  5811. return document.getElementById("stx_sport").value
  5812. }
  5813. function getSportByMessenger() {
  5814. if (document.getElementById("messenger")) {
  5815.  
  5816. if ((document.getElementById("messenger").className === "soccer") || (document.getElementById("messenger").className === "hockey")) {
  5817. return document.getElementById("messenger").className
  5818. }
  5819. }
  5820. return ""
  5821. }
  5822. function getUsernameData() {
  5823. if ((GM_getValue("currency") === undefined) || (GM_getValue("currency") === "")
  5824. ||(GM_getValue("soccer_team_id") === undefined) || (GM_getValue("soccer_team_id") === "")
  5825. ||(GM_getValue("hockey_team_id") === undefined) || (GM_getValue("hockey_team_id") === "")) {
  5826. let username = document.getElementById("header-username").innerText
  5827. GM_xmlhttpRequest({
  5828. method: "GET",
  5829. url: "http://www.managerzone.com/xml/manager_data.php?sport_id=" + window.sport_id + "&username=" + username,
  5830. headers: {
  5831. "Content-Type": "application/json"
  5832. },
  5833. onload: function (response) {
  5834.  
  5835. let parser = new DOMParser();
  5836. let xmlDoc = parser.parseFromString(response.responseText, "text/xml");
  5837. let userTeamsData = xmlDoc.getElementsByTagName("Team");
  5838. let index = 1;
  5839.  
  5840. if (userTeamsData[0].getAttribute("sport")==="soccer"){
  5841. GM_setValue("soccer_team_id", userTeamsData[0].getAttribute("teamId"))
  5842. }
  5843. if (userTeamsData[0].getAttribute("sport")==="hockey"){
  5844. GM_setValue("hockey_team_id", userTeamsData[0].getAttribute("teamId"))
  5845. }
  5846.  
  5847.  
  5848. if (userTeamsData[1].getAttribute("sport")==="soccer"){
  5849. GM_setValue("soccer_team_id", userTeamsData[1].getAttribute("teamId"))
  5850. }
  5851. if (userTeamsData[1].getAttribute("sport")==="hockey"){
  5852. GM_setValue("hockey_team_id", userTeamsData[1].getAttribute("teamId"))
  5853. }
  5854.  
  5855.  
  5856.  
  5857. if (userTeamsData[0].getAttribute("sport") === window.sport) {
  5858. index = 0;
  5859. }
  5860. GM_xmlhttpRequest({
  5861. method: "GET",
  5862. url: "http://www.managerzone.com/xml/team_playerlist.php?sport_id=" + window.sport_id + "&team_id=" + userTeamsData[index].getAttribute("teamId"),
  5863. headers: {
  5864. "Content-Type": "application/json"
  5865. },
  5866. onload: function (response) {
  5867. let parser = new DOMParser();
  5868. let xmlDoc = parser.parseFromString(response.responseText, "text/xml");
  5869. let team_data = xmlDoc.getElementsByTagName("TeamPlayers");
  5870. GM_setValue("currency", team_data[0].getAttribute("teamCurrency"))
  5871. }
  5872. });
  5873. }
  5874. });
  5875.  
  5876. }
  5877.  
  5878.  
  5879. }
  5880. function getActualDate(){
  5881. const fechaActual = new Date();
  5882. const year = fechaActual.getFullYear();
  5883. const month = String(fechaActual.getMonth() + 1).padStart(2, '0');
  5884. const day = String(fechaActual.getDate()).padStart(2, '0');
  5885. return `${year}-${month}-${day}`;
  5886. }
  5887. function compareVersions(installedVersion, latestVersion) {
  5888. const installedParts = installedVersion.split('.').map(Number);
  5889. const latestParts = latestVersion.split('.').map(Number);
  5890. for (let i = 0; i < Math.max(installedParts.length, latestParts.length); i++) {
  5891. const installed = installedParts[i] || 0;
  5892. const latest = latestParts[i] || 0;
  5893. if (installed < latest) {
  5894. GM_setValue("available_new_version","yes")
  5895. notifySnackBarNewVersion()
  5896. }else{
  5897. GM_setValue("available_new_version","no")
  5898. }
  5899. }
  5900.  
  5901. }
  5902. function getParsedValidDateText(text){
  5903. let initialDate="undefined"
  5904. let fecha=text
  5905. if(fecha.includes("-")){
  5906.  
  5907. let [day, month, year] = fecha.split("-");
  5908. initialDate = `${year}-${month}-${day}`;
  5909. }
  5910. if(fecha.includes("/")){
  5911. let [day, month, year] = fecha.split("/");
  5912. initialDate = `${year}-${month}-${day}`;
  5913.  
  5914. }
  5915.  
  5916. return initialDate
  5917.  
  5918.  
  5919.  
  5920. }
  5921. function notifySnackBarNewVersion(){
  5922. if(GM_getValue("stx_notified_version")!==GM_getValue("stx_latest_version")){
  5923. GM_setValue("stx_notified_version",GM_getValue("stx_latest_version"))
  5924. let x = document.getElementById("snackbar_stx");
  5925. 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>"
  5926. txt+="<button type='button' id='button-snackbar-update'>UPDATE</button>"
  5927. x.innerHTML = txt;
  5928. x.className = "showSnackBar_stx";
  5929. document.getElementById("button-snackbar-update").addEventListener('click', function () {
  5930. GM_setValue("date_checked_version","-")
  5931. window.open("https://update.greasyfork.org/scripts/491442/Stats%20Xente%20Script.user.js", "_blank");
  5932. });
  5933. setTimeout(function () { x.className = x.className.replace("showSnackBar_stx", ""); }, 8000);
  5934. }
  5935. }
  5936. async function checkScriptVersion(){
  5937. const actual_date=getActualDate()
  5938. if(actual_date!==GM_getValue("date_checked_version")){
  5939. GM_setValue("date_checked_version", actual_date)
  5940. const greasyForkURL = 'https://greasyfork.org/es/scripts/491442-stats-xente-script';
  5941. fetch(greasyForkURL)
  5942. .then(response => response.text())
  5943. .then(data => {
  5944. const parser = new DOMParser();
  5945. const doc = parser.parseFromString(data, 'text/html');
  5946. const versionElement = doc.querySelector('dd.script-show-version');
  5947. const latestVersion = versionElement ? versionElement.textContent.trim() : 'No se encontró versión';
  5948. const installedVersion = GM_info.script.version;
  5949. GM_setValue("stx_latest_version",latestVersion)
  5950. compareVersions(installedVersion, latestVersion);
  5951. })
  5952. .catch(error => {
  5953. console.error('Error al obtener la versión del script:', error);
  5954. });
  5955.  
  5956.  
  5957.  
  5958. }
  5959.  
  5960. }
  5961. function putSortIcon(a, tabla_) {
  5962. let filaEncabezado = tabla_.querySelector('thead tr');
  5963. let celdas = filaEncabezado.getElementsByTagName('th');
  5964. if (celdas.length === 0) {
  5965. celdas = filaEncabezado.getElementsByTagName('td');
  5966. }
  5967. let elementos = tabla_.querySelectorAll('.bi.bi-arrow-down-short');
  5968. elementos.forEach(function (elemento) {
  5969. elemento.remove();
  5970. })
  5971.  
  5972. elementos = tabla_.querySelectorAll('.bi.bi-arrow-up-short');
  5973. elementos.forEach(function (elemento) {
  5974. elemento.remove();
  5975. })
  5976.  
  5977.  
  5978.  
  5979. 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>'
  5980. 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>'
  5981.  
  5982. let icon = iconAsc;
  5983. if (document.getElementById("ord_table").value === "descendente") {
  5984. icon = iconDesc;
  5985. }
  5986.  
  5987.  
  5988. celdas[a].innerHTML = icon + celdas[a].innerHTML;
  5989. }
  5990. function darkenColor(rgb, percent) {
  5991. let result = rgb.match(/\d+/g);
  5992.  
  5993. // Convertir los valores RGB a enteros
  5994. let r = parseInt(result[0]);
  5995. let g = parseInt(result[1]);
  5996. let b = parseInt(result[2]);
  5997. // Reducir cada componente en un porcentaje
  5998. r = Math.floor(r * (1 - percent / 100));
  5999. g = Math.floor(g * (1 - percent / 100));
  6000. b = Math.floor(b * (1 - percent / 100));
  6001.  
  6002. // Asegurarse de que los valores estén dentro del rango válido (0-255)
  6003. r = Math.max(0, Math.min(255, r));
  6004. g = Math.max(0, Math.min(255, g));
  6005. b = Math.max(0, Math.min(255, b));
  6006.  
  6007. // Convertir de vuelta a hexadecimal y retornar el valor oscuro
  6008. return "#" + [r, g, b].map(x => {
  6009. const hex = x.toString(16);
  6010. return hex.length === 1 ? "0" + hex : hex;
  6011. }).join("");
  6012. }
  6013. function setCSSStyles(){
  6014. let link = document.createElement('link');
  6015. link.href = 'https://fonts.googleapis.com/css?family=Roboto&display=swap';
  6016. link.rel = 'stylesheet';
  6017.  
  6018. let link1 = document.createElement('link');
  6019. link1.href = 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css';
  6020. link1.rel = 'stylesheet';
  6021. document.head.appendChild(link)
  6022. document.head.appendChild(link1)
  6023.  
  6024. let inputHidden = document.createElement('input');
  6025. inputHidden.type = 'hidden';
  6026. inputHidden.id = 'ord_table';
  6027. inputHidden.value = 'ascendente';
  6028. document.body.appendChild(inputHidden);
  6029. GM_addStyle(`#snackbar_stx {
  6030. visibility: hidden;
  6031. position: fixed;
  6032. /*display: flex;*/
  6033. align-items: center;
  6034. left: 50%;
  6035. transform: translate(-50%, -50%);
  6036. min-width: 350px;
  6037. background-color: #323232;
  6038. color: #ffffffb3;
  6039. text-align: center;
  6040. border-radius: 2px;
  6041. padding: 16px;
  6042. z-index: 1;
  6043. bottom: 30px;
  6044. font-size: 17px;
  6045. border-radius: 5px;
  6046. box-shadow: 0 3px 5px -1px #0003, 0 6px 10px #00000024, 0 1px 18px #0000001f;
  6047. }
  6048.  
  6049. #snackbar_stx.showSnackBar_stx {
  6050. visibility: visible;
  6051. -webkit-animation: fadein 0.5s, fadeout 0.5s 8s forwards;
  6052. animation: fadein 0.5s, fadeout 0.5s 8s forwards;
  6053. }
  6054.  
  6055. @-webkit-keyframes fadein {
  6056. from {bottom: 0; opacity: 0;}
  6057. to {bottom: 30px; opacity: 1;}
  6058. }
  6059.  
  6060. @keyframes fadein {
  6061. from {bottom: 0; opacity: 0;}
  6062. to {bottom: 30px; opacity: 1;}
  6063. }
  6064.  
  6065. @-webkit-keyframes fadeout {
  6066. from {bottom: 30px; opacity: 1;}
  6067. to {bottom: 0; opacity: 0;}
  6068. }
  6069.  
  6070. @keyframes fadeout {
  6071. from {bottom: 30px; opacity: 1;}
  6072. to {bottom: 0; opacity: 0;}
  6073. }
  6074.  
  6075.  
  6076. .divAlert {
  6077. width: 75%;
  6078. padding: 4px 3px;
  6079. border-radius: 4px;
  6080. border-style: solid;
  6081. border-width: 1px;
  6082. font-size: 13px;
  6083. background-color: #ffc107;
  6084. color: #161515;
  6085. border-color: #ffffff;
  6086. font-weight: bold;
  6087. text-shadow: 1px 1px #ffffff;
  6088. }.modal_cargando-stx {
  6089. display: none;
  6090. /* Hidden by default */
  6091. position: fixed;
  6092. /* Stay in place */
  6093. z-index: 150;
  6094. /* Sit on top */
  6095. padding-top: 25px;
  6096. /* Location of the box */
  6097. left: 0;
  6098. top: 0;
  6099. width: 100%;
  6100. /* Full width */
  6101. height: 100%;
  6102. /* Full height */
  6103. overflow: auto;
  6104. /* Enable scroll if needed */
  6105. background-color: rgb(0, 0, 0);
  6106. /* Fallback color */
  6107. background-color: rgba(0, 0, 0, 0.75);
  6108. /* Black w/ opacity */
  6109. justify-content: center;
  6110. align-items: center;
  6111. }
  6112.  
  6113. .modal-content_cargando-stx {
  6114. position:relative;
  6115. border-radius:7px;
  6116. background-color: #fefefe00;
  6117. width: 90%;
  6118. height: 40%;
  6119. display: flex;
  6120. justify-content: center;
  6121. align-items: center;
  6122. }
  6123.  
  6124.  
  6125. .btn-save{
  6126. width:8em;
  6127. border-color:transparent;
  6128. border-radius: 3px;
  6129. display: inline-block;
  6130. padding: 10px 5px;
  6131. text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  6132. box-shadow: 0 1px 1px rgba(0,0,0,0.3);
  6133. cursor:pointer;
  6134. color: white;
  6135. font-family: 'Roboto', sans-serif;
  6136. background-color: #3CC93F;/*Color de fondo*/
  6137. }
  6138. .btn-save:hover{
  6139. background-color: #37B839;/*Color de fondo*/
  6140. }
  6141. .btn-save:active{
  6142. background-color: #29962A;/*Color de fondo*/
  6143. }
  6144.  
  6145.  
  6146. .btn-update{
  6147. width:8em;
  6148. border-color:transparent;
  6149. border-radius: 3px;
  6150. display: inline-block;
  6151. padding: 10px 5px;
  6152. text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  6153. box-shadow: 0 1px 1px rgba(0,0,0,0.3);
  6154. cursor:pointer;
  6155. color: white;
  6156. font-family: 'Roboto', sans-serif;
  6157. background-color: #2da8ef;/*Color de fondo*/
  6158. }
  6159. .btn-update:hover{
  6160. background-color: #2187c2;/*Color de fondo*/
  6161. }
  6162. .btn-update:active{
  6163. background-color: #2187c2;/*Color de fondo*/
  6164. }
  6165.  
  6166.  
  6167. .btn-comp-fed{
  6168. width:17em;
  6169. font-family: 'Roboto', sans-serif;
  6170. border:1px solid black;
  6171. border-radius: 5px;
  6172. display: inline-block;
  6173. padding: 7px 3px;
  6174. cursor:pointer;
  6175. color: white;
  6176. background-color: #2da8ef;/*Color de fondo*/
  6177. }
  6178. .btn-comp-fed:hover{
  6179. background-color: #2187c2;/*Color de fondo*/
  6180. }
  6181. .btn-comp-fed:active{
  6182. background-color: #2187c2;/*Color de fondo*/
  6183. }
  6184.  
  6185. .btn-delete{
  6186. width:8em;
  6187. border-color:transparent;
  6188. border-radius: 3px;
  6189. display: inline-block;
  6190. padding: 10px 5px;
  6191. text-decoration: none;
  6192. text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  6193. box-shadow: 0 1px 1px rgba(0,0,0,0.3);
  6194. cursor:pointer;
  6195. color: white;
  6196. font-family: 'Roboto', sans-serif;
  6197. background-color: #e6413e;/*Color de fondo*/
  6198. }
  6199. .btn-delete:hover{
  6200. background-color: #C93832;/*Color de fondo*/
  6201. }
  6202. .btn-delete:active{
  6203. background-color: #ad2a24;/*Color de fondo*/
  6204. }
  6205.  
  6206. .cerrar {
  6207. position: absolute;
  6208. top: 0;
  6209. right: 0;
  6210. padding: 5px;
  6211. cursor: pointer;
  6212. color: #fff;
  6213. }
  6214.  
  6215. .close_cargando-stx {
  6216. color: #aaaaaa;
  6217. float: right;
  6218. font-size: 28px;
  6219. font-weight: bold;
  6220. }
  6221.  
  6222. .close_cargando-stx:hover,
  6223. .close_cargando-stx:focus {
  6224. color: #000;
  6225. text-decoration: none;
  6226. cursor: pointer;
  6227. }.stx_legend {
  6228. z-index:300;
  6229. position: fixed;
  6230. bottom: 60%;
  6231. right: 1px;
  6232. border: 1px solid #2bacf5;
  6233. padding-right: 13px;
  6234. padding-left: 3px;
  6235. padding-top: 3px;
  6236. padding-bottom: 3px;
  6237. width: 14px;
  6238. font-size: 13px;
  6239. border-radius: 4px;
  6240. text-shadow: 1px 1px 3px #676767;
  6241. background-color: #246355;
  6242. color: #246355;
  6243. cursor: default;
  6244. cursor: pointer;
  6245. }.loader {
  6246. width: 100%;
  6247. height: 15px;
  6248. border-radius: 40px;
  6249. color: #ffc107;
  6250. border: 2px solid;
  6251. position: relative;
  6252. overflow: hidden;
  6253. }
  6254. .loader::before {
  6255. content: "";
  6256. position: absolute;
  6257. margin: 2px;
  6258. width: 14px;
  6259. top: 0;
  6260. bottom: 0;
  6261. left: -20px;
  6262. border-radius: inherit;
  6263. background: currentColor;
  6264. box-shadow: -10px 0 12px 3px currentColor;
  6265. clip-path: polygon(0 5%, 100% 0,100% 100%,0 95%,-30px 50%);
  6266. animation: l14 1s infinite linear;
  6267. }
  6268. @keyframes l14 {
  6269. 100% {left: calc(100% + 20px)}
  6270. }
  6271. .containerPeqAmarillo {
  6272. display: block;
  6273. position: relative;
  6274. padding-left: 35px;
  6275. margin-bottom: 12px;
  6276. font-size:medium;
  6277. padding-top:5px;
  6278. cursor: pointer;
  6279. -webkit-user-select: none;
  6280. -moz-user-select: none;
  6281. -ms-user-select: none;
  6282. user-select: none;
  6283. }
  6284.  
  6285. /* Hide the browser's default checkbox */
  6286. .containerPeqAmarillo input {
  6287. position: absolute;
  6288. opacity: 0;
  6289. cursor: pointer;
  6290. height: 0;
  6291. width: 0;
  6292. }
  6293.  
  6294. /* Create a custom checkbox */
  6295. .checkmarkPeqAmarillo {
  6296. position: absolute;
  6297. top: 0;
  6298. left: 0;
  6299. height: 25px;
  6300. width: 25px;
  6301. background-color: #a1a1a1;
  6302. }
  6303.  
  6304. /* On mouse-over, add a grey background color */
  6305. .containerPeqAmarillo:hover input ~ .checkmarkPeqAmarillo {
  6306. background-color: #5c5151;
  6307. }
  6308.  
  6309. /* When the checkbox is checked, add a blue background */
  6310. .containerPeqAmarillo input:checked ~ .checkmarkPeqAmarillo {
  6311. background-color: #FFCC00;
  6312. }
  6313.  
  6314. /* Create the checkmark/indicator (hidden when not checked) */
  6315. .checkmarkPeqAmarillo:after {
  6316. content: "";
  6317. position: absolute;
  6318. display: none;
  6319. }
  6320.  
  6321. /* Show the checkmark when checked */
  6322. .containerPeqAmarillo input:checked ~ .checkmarkPeqAmarillo:after {
  6323. display: block;
  6324. }
  6325.  
  6326. /* Style the checkmark/indicator */
  6327. .containerPeqAmarillo .checkmarkPeqAmarillo:after {
  6328. left: 9px;
  6329. top: 5px;
  6330. width: 5px;
  6331. height: 10px;
  6332. border: solid white;
  6333. border-width: 0 3px 3px 0;
  6334. -webkit-transform: rotate(45deg);
  6335. -ms-transform: rotate(45deg);
  6336. transform: rotate(45deg);
  6337. }
  6338. #showMenu {
  6339. text-align: left;
  6340. border-collapse: collapse;
  6341. width: 75%;
  6342. font-size: 14px;
  6343. font-family: 'Roboto', sans-serif
  6344. }
  6345.  
  6346. /* #showMenu th,td {
  6347. padding: 4px;
  6348. }*/
  6349.  
  6350. #showMenu td {
  6351. background-color: white;
  6352. }
  6353.  
  6354. #showMenu thead {
  6355. background-color: #246355;
  6356. border-bottom: solid 2px #0F362D;
  6357. color: white;
  6358. }
  6359.  
  6360. #showMenu tfoot {
  6361. font-family: 'Righteous', cursive;
  6362. background-color: #246355;
  6363. border-bottom: solid 5px #0F362D;
  6364. font-size: 13px;
  6365. color: white;
  6366. }
  6367.  
  6368.  
  6369.  
  6370. #showMenu tr td,
  6371. th {
  6372. border-top-right-radius: 0;
  6373. border-top-left-radius: 0;
  6374. border-bottom-left-radius: 0;
  6375. border-bottom-right-radius: 0;
  6376. }
  6377.  
  6378. #showMenu th:first-child {
  6379. border-top-left-radius: 5px;
  6380. }
  6381.  
  6382. #showMenu th:last-child {
  6383. border-top-right-radius: 5px;
  6384. }
  6385.  
  6386. #showMenu tr {
  6387. background-color: transparent;
  6388. border-color: transparent;
  6389. font-family: 'Roboto';
  6390. }
  6391.  
  6392. #show3{
  6393.  
  6394. width: 75%;
  6395. background-color: transparent;
  6396. border-collapse: separate;
  6397. border-spacing: 0;
  6398. }
  6399.  
  6400.  
  6401.  
  6402. #show3 td {
  6403. background-color: white;
  6404. }
  6405.  
  6406. #show3 tr:last-child td:last-child {
  6407. border-bottom-right-radius: 5px;
  6408. }
  6409.  
  6410.  
  6411. #show3 tr:last-child td:first-child {
  6412. border-bottom-left-radius: 5px;
  6413. }
  6414.  
  6415. .caja_mensaje_50 {
  6416. font-family: 'Roboto', sans-serif;
  6417. background: #98D398;
  6418. color: #FFFFFF;
  6419. font-weight: bold;
  6420. padding: 4px;
  6421. text-align: center;
  6422. width: 50%;
  6423. font-size: 2.0em;
  6424. border-radius: 5px;
  6425. }
  6426.  
  6427. .modal_div_content_main{
  6428. width: 100%;
  6429. background-color: #f2f2f2;
  6430. min-height: 115px;
  6431. border-radius: 5px;
  6432. }
  6433.  
  6434.  
  6435.  
  6436.  
  6437. .expandable-icon {
  6438. right: 0px;
  6439. top: 0px;
  6440. transform: rotateZ(45deg);
  6441. border-radius: 5px;
  6442. width: 20px;
  6443. height: 20px;
  6444. background: rgb(12, 47, 94);
  6445. transition: all .3s;
  6446. }
  6447.  
  6448. .expandable-item.active .expandable-icon{
  6449. transform: rotateZ(0);
  6450. }
  6451.  
  6452. .expandable-icon .line {
  6453. width: 15px;
  6454. height: 2px;
  6455. background: white;
  6456. position: absolute;
  6457. top: 0;
  6458. left: 0;
  6459. right: 0;
  6460. bottom: 0;
  6461. margin: auto;
  6462. transition: all .4s;
  6463. }
  6464.  
  6465. .expandable-icon .line:nth-child(1) {
  6466. transform: rotateZ(45deg);
  6467. }
  6468.  
  6469. .expandable-icon .line:nth-child(2) {
  6470. transform: rotateZ(-45deg);
  6471. }
  6472.  
  6473.  
  6474. .imgMiddle {
  6475. display: inline-block;
  6476. vertical-align: middle;
  6477. }
  6478.  
  6479. .textMiddle {
  6480. display: inline-block;
  6481. vertical-align: middle;
  6482. }
  6483.  
  6484.  
  6485. table.matchValuesTable {
  6486. border-collapse: collapse;
  6487. width: 80%;
  6488. margin: 5px 0;
  6489. z-index:15;
  6490.  
  6491. }
  6492. table.matchValuesTable th, table.matchValuesTable td {
  6493. border: 1px solid #ddd;
  6494. text-align: center;
  6495. padding: 6px;
  6496. border: 0px;
  6497. }
  6498. table.matchValuesTable th {
  6499. background-color: #e4c800;
  6500. color: white;
  6501. border: 0px;
  6502. }
  6503.  
  6504. table.matchValuesTable th:first-child {
  6505. border-top: none; /* Quita el borde superior de la primera celda del encabezado */
  6506. }
  6507.  
  6508.  
  6509. #button-snackbar-update{
  6510. color: #2da8ef;
  6511. background-color: transparent;
  6512. border: 1px solid #2da8ef;
  6513. padding: .15rem .50rem;
  6514. font-size: 0.90rem;
  6515. line-height: 1.5;
  6516. border-radius: .25rem;
  6517. cursor:pointer;
  6518. }
  6519.  
  6520. #button-snackbar-update:hover{
  6521. color: white;
  6522. background-color: #2da8ef;
  6523. border: 1px solid #2da8ef;
  6524. padding: .15rem .50rem;
  6525. font-size: 0.90rem;
  6526. line-height: 1.5;
  6527. border-radius: .25rem;
  6528. cursor:pointer;
  6529. }.loader-soccer {
  6530. width: 100%;
  6531. height: 15px;
  6532. border-radius: 40px;
  6533. color: #5d7f13;
  6534. border: 2px solid;
  6535. position: relative;
  6536. overflow: hidden;
  6537. }
  6538. .loader-soccer::before {
  6539. content: "";
  6540. position: absolute;
  6541. margin: 2px;
  6542. width: 14px;
  6543. top: 0;
  6544. bottom: 0;
  6545. left: -20px;
  6546. border-radius: inherit;
  6547. background: currentColor;
  6548. box-shadow: -10px 0 12px 3px currentColor;
  6549. clip-path: polygon(0 5%, 100% 0,100% 100%,0 95%,-30px 50%);
  6550. animation: l14 1s infinite linear;
  6551. }
  6552.  
  6553. .loader-hockey {
  6554. width: 100%;
  6555. height: 15px;
  6556. border-radius: 40px;
  6557. color: #148cac;
  6558. border: 2px solid;
  6559. position: relative;
  6560. overflow: hidden;
  6561. }
  6562. .loader-hockey::before {
  6563. content: "";
  6564. position: absolute;
  6565. margin: 2px;
  6566. width: 14px;
  6567. top: 0;
  6568. bottom: 0;
  6569. left: -20px;
  6570. border-radius: inherit;
  6571. background: currentColor;
  6572. box-shadow: -10px 0 12px 3px currentColor;
  6573. clip-path: polygon(0 5%, 100% 0,100% 100%,0 95%,-30px 50%);
  6574. animation: l14 1s infinite linear;
  6575. }
  6576. @keyframes l14 {
  6577. 100% {left: calc(100% + 20px)}
  6578. }
  6579. `)
  6580.  
  6581. }
  6582.  
  6583.  
  6584. async function playersPage1() {
  6585. setTimeout(function () {
  6586. let player_images
  6587. let elementos = document.getElementsByClassName('playerContainer');
  6588.  
  6589. let player_values = {}
  6590. let tactics_list = []
  6591.  
  6592. let urlParams = new URLSearchParams(window.location.search);
  6593. let flagStats = true
  6594. if (urlParams.has('tid')) {
  6595. flagStats = false
  6596. }
  6597.  
  6598. if (flagStats) {
  6599. let habil_container = elementos[0].getElementsByClassName("player_skills")
  6600. let habil = habil_container[0].getElementsByClassName("clippable")
  6601.  
  6602. if (window.sport === "hockey") {
  6603. for (let q = 1; q < habil.length; q++) {
  6604. skills_names.push(habil[q].textContent)
  6605. }
  6606. } else {
  6607.  
  6608. for (let q = 0; q < habil.length - 1; q++) {
  6609. skills_names.push(habil[q].textContent)
  6610. }
  6611. player_images = document.getElementsByClassName("player-image soccer")
  6612. }
  6613. }
  6614.  
  6615. let ids_ = []
  6616.  
  6617. for (let i = 0; i < elementos.length; i++) {
  6618. let ids = elementos[i].getElementsByClassName('player_id_span');
  6619.  
  6620. let elementos_ = elementos[i].getElementsByClassName('p_sublinks');
  6621.  
  6622. let subheaders = elementos[i].getElementsByClassName('subheader clearfix');
  6623.  
  6624.  
  6625. let enlace = subheaders[0].querySelector('.subheader a');
  6626. let playerName = enlace.querySelector('.player_name').textContent
  6627.  
  6628. ids_.push({ "id": ids[0].textContent, "name": playerName });
  6629.  
  6630.  
  6631. let txt = '<span id=but' + ids[0].textContent + ' class="player_icon_placeholder"><a href="#" onclick="return false"'
  6632. txt += 'title="Stats Xente" class="player_icon"><span class="player_icon_wrapper">'
  6633. 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;'
  6634. txt += 'z-index: 0;"></span><span class="player_icon_text"></span></span></a></span>'
  6635.  
  6636. let index=0
  6637. if(window.stx_device!=="computer"){index=1}
  6638. elementos_[index].innerHTML += txt;
  6639.  
  6640. if (flagStats) {
  6641. let flag_gk = false;
  6642. let age_div = elementos[i].getElementsByClassName('dg_playerview_info');
  6643. let age_table = age_div[0].getElementsByTagName('table')[0];
  6644.  
  6645. let ini_age = age_table.getElementsByTagName('td')[0].textContent.indexOf(":")
  6646. let age = age_table.getElementsByTagName('td')[0].textContent.substring(ini_age + 2, ini_age + 4);
  6647.  
  6648.  
  6649. if ((window.sport === "soccer") && (player_images[i].innerHTML.includes("gk=1"))) {
  6650. flag_gk = true
  6651. }
  6652.  
  6653. let tactics = elementos[i].getElementsByClassName('player_tactic gradientSunriseIcon');
  6654.  
  6655. player_values = {
  6656. "id": ids[0].textContent,
  6657. "skills": [],
  6658. "lines": [],
  6659. "tactics-position": {},
  6660. "tactics": [],
  6661. "age": parseInt(age)
  6662. }
  6663.  
  6664. for (let j = 0; j < tactics.length; j++) {
  6665. let fin = 0;
  6666. let line = ""
  6667. let ini = tactics[j].textContent.indexOf('(');
  6668. let tactic = tactics[j].textContent.substring(0, ini - 1);
  6669.  
  6670. if (window.sport === "hockey") {
  6671.  
  6672. if (!tactics[j].textContent.includes(":")) {
  6673. ini = tactics[j].textContent.indexOf('(');
  6674. fin = tactics[j].textContent.indexOf(')');
  6675. line = tactics[j].textContent.substring(ini + 2, fin - 1);
  6676. gk_line = line;
  6677. } else {
  6678. ini = tactics[j].textContent.indexOf('(');
  6679. fin = tactics[j].textContent.indexOf(':');
  6680. line = tactics[j].textContent.substring(ini + 2, fin);
  6681. }
  6682.  
  6683. } else {
  6684. ini = tactics[j].textContent.indexOf('(');
  6685. fin = tactics[j].textContent.indexOf(')');
  6686. line = tactics[j].textContent.substring(ini + 2, fin - 1);
  6687. if (flag_gk) {
  6688. gk_line = line;
  6689. }
  6690. if (tactics[j].textContent.includes(",")) {
  6691. ini = tactics[j].textContent.indexOf('(');
  6692. fin = tactics[j].textContent.indexOf(',');
  6693. su_line = tactics[j].textContent.substring(ini + 2, fin);
  6694. }
  6695. }
  6696.  
  6697. if (!player_values['lines'].includes(line)) {
  6698. player_values['lines'].push(line);
  6699. }
  6700. if (!player_values['tactics'].includes(tactic)) {
  6701. player_values['tactics'].push(tactic);
  6702. }
  6703.  
  6704. player_values['tactics-position'][tactic] = line
  6705.  
  6706. if ((!lines.includes(line))) {
  6707. lines.push(line);
  6708. }
  6709.  
  6710. if (!tactics_list.includes(tactic)) {
  6711. tactics_list.push(tactic);
  6712. }
  6713.  
  6714.  
  6715. }
  6716. let skills_container=elementos[i].getElementsByClassName('skills-container floatLeft clearfix')
  6717. let skills = skills_container[0].getElementsByClassName('skillval');
  6718.  
  6719. if (window.sport === "hockey") {
  6720.  
  6721. for (let j = 1; j < skills.length; j++) {
  6722. let cleanedText = skills[j].textContent.replace(')', '');
  6723. cleanedText = cleanedText.replace('(', '');
  6724. let number = parseInt(cleanedText, 10);
  6725. player_values['skills'].push(number);
  6726. }
  6727.  
  6728. } else {
  6729. for (let j = 0; j < skills.length - 1; j++) {
  6730.  
  6731. let cleanedText = skills[j].textContent.replace(')', '');
  6732. cleanedText = cleanedText.replace('(', '');
  6733. let number = parseInt(cleanedText, 10);
  6734. player_values['skills'].push(number);
  6735. }
  6736. }
  6737. players.push(player_values)
  6738. }
  6739. }
  6740. if (flagStats) {
  6741. const container = document.getElementById("squad-search-toggle")
  6742. let contenidoNuevo = "<div id='containerTactics' style='background-color: #e3e3e3; margin: 0 auto; text-align:center;'></br>"
  6743. contenidoNuevo += "<div id=selectDiv>Choose Tactic: <select id=tactics_select>"
  6744. contenidoNuevo += "<option value='All Team'>All Team</option>"
  6745. for (let x = 0; x < tactics_list.length; x++) {
  6746. let selected = ""
  6747. if (x === 0) {
  6748. selected = "selected=''";
  6749. }
  6750. contenidoNuevo += "<option " + selected + " value='" + tactics_list[x] + "'>" + tactics_list[x] + "</option>"
  6751. }
  6752. contenidoNuevo += "</select></div></br><div id=divMenu></div></center></div>"
  6753. container.innerHTML = contenidoNuevo + container.innerHTML;
  6754. skillDistrib(tactics_list[0]);
  6755. document.getElementById("tactics_select").addEventListener('change', function () {
  6756. let select = document.getElementById('tactics_select');
  6757. let valorSeleccionado = select.value;
  6758. document.getElementById("divMenu").innerHTML = ""
  6759. skillDistrib(valorSeleccionado)
  6760. });
  6761. }
  6762.  
  6763. let team_id
  6764. if(window.sport==="soccer"){
  6765. team_id=GM_getValue("soccer_team_id")
  6766. }else{
  6767. team_id=GM_getValue("hockey_team_id")
  6768. }
  6769.  
  6770.  
  6771. for (let i = 0; i < ids_.length; i++) {
  6772. (function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
  6773. document.getElementById("but" + currentId).addEventListener('click', function () {
  6774. let link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
  6775. + "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
  6776. "&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
  6777. openWindow(link, 0.95, 1.25);
  6778. });
  6779. })(ids_[i]['id'], team_id, window.sport, window.lang, "[undefined]", ids_[i]['name']);
  6780. }
  6781.  
  6782. }, 1000);
  6783. }
  6784. function skillDistrib1(tactic) {
  6785. let t = tactic
  6786. let l=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  6787. if (window.sport === "hockey") {
  6788. l = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  6789. }
  6790.  
  6791. let li_t = {}
  6792. for (let i = 0; i < lines.length; i++) {
  6793. li_t[lines[i]] = [...l];
  6794. }
  6795.  
  6796. let no_gk_line = "Tactic -(" + gk_line + ")"
  6797. li_t["Team"] = [...l];
  6798. li_t["U23"] = [...l];
  6799. li_t["U21"] = [...l];
  6800. li_t["U18"] = [...l];
  6801. li_t["Tactic"] = [...l];
  6802. li_t[no_gk_line] = [...l];
  6803.  
  6804. let i,j
  6805. for (i = 0; i < players.length; i++) {
  6806. if (players[i]['tactics'].includes(t)) {
  6807. for (j = 0; j < players[i]['skills'].length; j++) {
  6808. li_t[players[i]['tactics-position'][t]][j] += players[i]['skills'][j]
  6809. li_t['Tactic'][j] += players[i]['skills'][j]
  6810. if (players[i]['tactics-position'][t] !== "Po") {
  6811. li_t[no_gk_line][j] += players[i]['skills'][j]
  6812. }
  6813. }
  6814. li_t[players[i]['tactics-position'][t]][j] += 1
  6815. li_t['Tactic'][j] += 1
  6816. if (players[i]['tactics-position'][t] !== "Po") {
  6817. li_t[no_gk_line][j] += 1
  6818. }
  6819. } else {
  6820.  
  6821. for (let j = 0; j < players[i]['skills'].length; j++) {
  6822. if (players[i]['age'] <= 23) {
  6823. li_t['U23'][j] += players[i]['skills'][j]
  6824. }
  6825. if (players[i]['age'] <= 23) {
  6826. li_t['U21'][j] += players[i]['skills'][j]
  6827. }
  6828. if (players[i]['age'] <= 23) {
  6829. li_t['U18'][j] += players[i]['skills'][j]
  6830. }
  6831. li_t['Team'][j] += players[i]['skills'][j]
  6832. }
  6833.  
  6834. if (players[i]['age'] <= 23) {
  6835. li_t['U23'][li_t["U23"].length - 1] += 1
  6836. }
  6837.  
  6838. if (players[i]['age'] <= 21) {
  6839. li_t['U21'][li_t["U21"].length - 1] += 1
  6840. }
  6841. if (players[i]['age'] <= 18) {
  6842. li_t['U18'][li_t["U18"].length - 1] += 1
  6843. }
  6844. li_t['Team'][li_t["Team"].length - 1] += 1
  6845. }
  6846. }
  6847.  
  6848. const container = document.getElementById("divMenu")
  6849. 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>";
  6850. contenidoNuevo += '<th style="padding:4px; margin: 0 auto; text-align:center;">Line</th>'
  6851. for (let q = 0; q < skills_names.length; q++) {
  6852. contenidoNuevo += '<th style="padding:4px; margin: 0 auto; text-align:center;">' + skills_names[q] + '</th>'
  6853. }
  6854. contenidoNuevo += '</tr></thead>';
  6855. let l_aux = lines
  6856. l_aux = l_aux.filter(item => item !== gk_line);
  6857. l_aux.sort((a, b) => {
  6858. let numA = parseInt(a.substring(1), 10);
  6859. let numB = parseInt(b.substring(1), 10);
  6860. return numA - numB;
  6861. });
  6862.  
  6863. l_aux.unshift(gk_line);
  6864. l_aux.push("Tactic");
  6865. l_aux.push(no_gk_line);
  6866.  
  6867. if (window.sport === "hockey") {
  6868. if (li_t["L4"][10] === 0) {
  6869. let index = l_aux.indexOf('L4');
  6870. if (index !== -1) {
  6871. l_aux.splice(index, 1);
  6872. }
  6873. }
  6874. }
  6875.  
  6876. if (t === "All Team") {
  6877. l_aux = ["Team", "U23", "U21", "U18"]
  6878. }
  6879.  
  6880. l_aux = l_aux.filter(item => !item.includes(su_line));
  6881.  
  6882. for (let w = 0; w < l_aux.length; w++) {
  6883. let key = l_aux[w]
  6884. if (li_t.hasOwnProperty(key)) {
  6885. contenidoNuevo += "<tr>";
  6886. contenidoNuevo += "<td style='padding:2px; margin: 0 auto; text-align:center;'><strong>" + key + "</strong></td>";
  6887. for (let x = 0; x < li_t[key].length - 1; x++) {
  6888. 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>";
  6889. }
  6890. contenidoNuevo += "</tr>";
  6891.  
  6892. }
  6893. }
  6894. container.innerHTML += contenidoNuevo;
  6895. }
  6896. function getParsedValidDate(texto) {
  6897. let fecha = new Date(texto);
  6898. if (!isNaN(fecha.getTime())) {
  6899. return fecha.toISOString().split('T')[0];
  6900. } else {
  6901. let hoy = new Date();
  6902. hoy.setDate(hoy.getDate() - 5);
  6903. return hoy.toISOString().split('T')[0];
  6904. }
  6905. }
  6906. function ordenarTablaq(columna, byClassName, param) {
  6907. let tabla
  6908. if (byClassName) {
  6909. let elems = document.getElementsByClassName(param);
  6910. tabla = elems[0]
  6911. } else {
  6912. tabla = document.getElementById(param)
  6913. }
  6914. let filas, switching, i, x, y, debeCambiar, direccion, cambioRealizado;
  6915. switching = true;
  6916. direccion = document.getElementById("ord_table").value
  6917. while (switching) {
  6918. switching = false;
  6919. filas = tabla.rows;
  6920. for (i = 1; i < (filas.length - 1); i++) {
  6921. debeCambiar = false;
  6922. x = filas[i].getElementsByTagName("td")[columna];
  6923. y = filas[i + 1].getElementsByTagName("td")[columna];
  6924. let xValue = parseFloat(x.innerHTML.replace(/\./g, "").replace(/[^0-9,-]+/g, "").replace(",", "."));
  6925. let yValue = parseFloat(y.innerHTML.replace(/\./g, "").replace(/[^0-9,-]+/g, "").replace(",", "."));
  6926. if (direccion === "ascendente") {
  6927. if (isNaN(xValue)) {
  6928. if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
  6929. debeCambiar = true;
  6930. break;
  6931. }
  6932. } else {
  6933. if (xValue > yValue) {
  6934. debeCambiar = true;
  6935. break;
  6936. }
  6937. }
  6938. } else if (direccion === "descendente") {
  6939. if (isNaN(xValue)) {
  6940. if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) {
  6941. debeCambiar = true;
  6942. break;
  6943. }
  6944. } else {
  6945. if (xValue < yValue) {
  6946. debeCambiar = true;
  6947. break;
  6948. }
  6949. }
  6950. }
  6951. }
  6952.  
  6953.  
  6954.  
  6955. if (debeCambiar) {
  6956. filas[i].parentNode.insertBefore(filas[i + 1], filas[i]);
  6957. switching = true;
  6958. cambioRealizado = true;
  6959. } else {
  6960. if (!cambioRealizado && direccion === "descendente") {
  6961. //direccion = "ascendente";
  6962. switching = true;
  6963. }
  6964. }
  6965. }
  6966.  
  6967. if (document.getElementById("ord_table").value === "descendente") {
  6968. document.getElementById("ord_table").value = "ascendente";
  6969. } else {
  6970. document.getElementById("ord_table").value = "descendente";
  6971. }
  6972.  
  6973.  
  6974. filas = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  6975. for (i = 0; i < filas.length; i++) {
  6976. let primerTd = filas[i].querySelector("td");
  6977. primerTd.innerHTML = (i + 1);
  6978. }
  6979. }
  6980.  
  6981. function playersPageStatsAll(){
  6982. let params = new URLSearchParams(window.location.search);;
  6983. let tid = params.get('tid');
  6984. let elementos1 = document.getElementsByClassName('playerContainer');
  6985. for (let i = 0; i < elementos1.length; i++) {
  6986. let playerName = elementos1[i].querySelector('.player_name').textContent
  6987. let ids = elementos1[i].getElementsByClassName('player_id_span');
  6988. let elementos_ = elementos1[i].getElementsByClassName('p_sublinks');
  6989. let txt = '<span id=but' + ids[0].textContent + ' class="player_icon_placeholder"><a href="#" onclick="return false"'
  6990. txt += 'title="Stats Xente" class="player_icon"><span class="player_icon_wrapper">'
  6991. 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;'
  6992. txt += 'z-index: 0;"></span><span class="player_icon_text"></span></span></a></span>'
  6993.  
  6994. let index=0
  6995. if(window.stx_device!=="computer"){index=1}
  6996. elementos_[index].innerHTML += txt;
  6997.  
  6998.  
  6999. (function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
  7000. document.getElementById("but" + currentId).addEventListener('click', function () {
  7001. let link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
  7002. + "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
  7003. "&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
  7004. openWindow(link, 0.95, 1.25);
  7005. });
  7006. })(ids[0].textContent, tid, window.sport, window.lang, "[undefined]", playerName);
  7007.  
  7008. }
  7009.  
  7010. }
  7011.  
  7012.  
  7013. function parseNumber(numStr) {
  7014. if (/^\d{1,3}(,\d{3})*\.\d+$/.test(numStr)) {
  7015. return parseFloat(numStr.replace(/,/g, ''));
  7016. }
  7017.  
  7018.  
  7019. if (/^\d{1,3}(\.\d{3})*,\d+$/.test(numStr)) {
  7020. return parseFloat(numStr.replace(/\./g, '').replace(',', '.'));
  7021. }
  7022.  
  7023. if (/^\d{1,3}(,\d{3})+$/.test(numStr)) {
  7024. return parseFloat(numStr.replace(/,/g, ''));
  7025. }
  7026.  
  7027. if (/^\d{1,3}(\.\d{3})+$/.test(numStr)) {
  7028. return parseFloat(numStr.replace(/\./g, ''));
  7029. }
  7030. return parseFloat(numStr.replace(',', '.'));
  7031. }
  7032.  
  7033.  
  7034.  
  7035. })();