Stats Xente Script

Stats Xente script for inject own data on Managerzone site

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

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