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