Stats Xente Script

Stats Xente script for inject own data on Managerzone site

当前为 2024-11-06 提交的版本,查看 最新版本

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