Stats Xente Script

Stats Xente script for inject own data on Managerzone site

当前为 2025-01-23 提交的版本,查看 最新版本

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