Stats Xente Script

Stats Xente script for inject own data on Managerzone site

目前為 2025-05-30 提交的版本,檢視 最新版本

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