Stats Xente Script

Stats Xente script for inject own data on Managerzone site

当前为 2025-06-02 提交的版本,查看 最新版本

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