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