Stats Xente Script

Stats Xente script for inject own data on Managerzone site

当前为 2024-10-23 提交的版本,查看 最新版本

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