Stats Xente Script

Stats Xente script for inject own data on Managerzone site

当前为 2025-03-17 提交的版本,查看 最新版本

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