Stats Xente Script

Stats Xente script for inject own data on Managerzone site

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

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