Stats Xente Script

Stats Xente script for inject own data on Managerzone site

目前為 2024-10-21 提交的版本,檢視 最新版本

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