Stats Xente Script

Stats Xente script for inject own data on Managerzone site

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

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