Stats Xente Script

Stats Xente script for inject own data on Managerzone site

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

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