Stats Xente Script

Stats Xente script for inject own data on Managerzone site

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

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