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