Stats Xente Script

Stats Xente script for inject own data on Managerzone site

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