Stats Xente Script

Stats Xente script for inject own data on Managerzone site

当前为 2024-09-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Stats Xente Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.91
  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.  
  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.  
  436.  
  437. `)
  438.  
  439. /*var keys = GM_listValues();
  440. keys.forEach(function(key) {
  441. console.log(key+" "+GM_getValue(key))
  442. });*/
  443.  
  444.  
  445. var link = document.createElement('link');
  446. link.href = 'https://fonts.googleapis.com/css?family=Roboto&display=swap';
  447. link.rel = 'stylesheet';
  448.  
  449. var link1 = document.createElement('link');
  450. link1.href = 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css';
  451. link1.rel = 'stylesheet';
  452. document.head.appendChild(link)
  453. document.head.appendChild(link1)
  454.  
  455. var inputHidden = document.createElement('input');
  456. inputHidden.type = 'hidden';
  457. inputHidden.id = 'ord_table';
  458. inputHidden.value = 'ascendente';
  459. document.body.appendChild(inputHidden);
  460.  
  461.  
  462.  
  463.  
  464. createModalMenu()
  465. createModalEventListeners()
  466. setLangSportCats()
  467. getUsernameData()
  468.  
  469.  
  470.  
  471.  
  472. function waitToDOM(function_to_execute, classToSearch, elementIndex) {
  473. var interval = setInterval(function () {
  474. var elements = document.querySelectorAll('.' + classToSearch);
  475. if (elements.length > 0 && elements[elementIndex]) {
  476. clearInterval(interval);
  477. clearTimeout(timeout);
  478. function_to_execute();
  479. }
  480. }, 100);
  481.  
  482.  
  483. var timeout = setTimeout(function () {
  484. clearInterval(interval); // Detiene la comprobación
  485. }, 10000); // 10,000 ms = 10 segundos
  486. }
  487.  
  488.  
  489.  
  490. /// FUNCTIONS MENU
  491.  
  492. setTimeout(function () {
  493.  
  494.  
  495.  
  496. const elementos = document.querySelectorAll('.player_link');
  497. elementos.forEach(function (elemento) {
  498. elemento.addEventListener('click', function () {
  499.  
  500. setTimeout(function () {
  501. playersPageStats()
  502.  
  503. }, 1000);
  504.  
  505.  
  506.  
  507. });
  508. });
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515. var urlParams = new URLSearchParams(window.location.search);
  516.  
  517. if ((urlParams.has('p')) && (urlParams.get('p') === 'league') && (GM_getValue("leagueFlag"))) {
  518. waitToDOM(leagues, "nice_table", 0)
  519. }
  520.  
  521. if ((urlParams.has('p')) && (urlParams.get('p') === 'federations')
  522. && (urlParams.get('sub') === 'league') && (GM_getValue("federationFlag"))) {
  523. waitToDOM(clashLeagues, "nice_table", 0)
  524. }
  525.  
  526. if ((urlParams.has('p')) && (urlParams.get('p') === 'federations')
  527. && (urlParams.get('sub') === 'clash') && (GM_getValue("federationFlag"))) {
  528. waitToDOM(clash, "fed_badge", 0)
  529. }
  530.  
  531. if ((urlParams.has('p')) && (urlParams.get('p') === 'match')
  532. && (urlParams.get('sub') === 'result') && (GM_getValue("matchFlag"))) {
  533. waitToDOM(match, "flex-grow-0 textCenter team-table block", 0)
  534. }
  535.  
  536. if ((urlParams.has('p')) && (urlParams.get('p') === 'players') && (!urlParams.has('pid'))
  537. && (GM_getValue("playersFlag"))) {
  538. playersPage()
  539. }
  540.  
  541. if ((urlParams.has('p')) && (urlParams.get('p') === 'players') && (urlParams.has('pid'))) {
  542. playersPageStats()
  543. }
  544.  
  545.  
  546. if ((urlParams.has('p')) && (urlParams.get('p') === 'rank') && (urlParams.get('sub') === 'countryrank')
  547. && (GM_getValue("countryRankFlag"))) {
  548. countryRank();
  549. }
  550.  
  551. if ((urlParams.has('p')) && (urlParams.get('p') === 'clubhouse')) {
  552. nextMatchesClubhouse()
  553. }
  554.  
  555.  
  556. if ((urlParams.has('p')) && (urlParams.get('p') === 'friendlyseries')
  557. && (urlParams.get('sub') === 'standings')) {
  558. friendlyCupsAndLeagues()
  559. }
  560.  
  561.  
  562. if ((urlParams.has('p')) && (urlParams.get('p') === 'cup') && (urlParams.get('sub') === 'groupplay')) {
  563. friendlyCupsAndLeagues()
  564. }
  565.  
  566.  
  567. if ((urlParams.has('p')) && (urlParams.get('p') === 'private_cup') && (urlParams.get('sub') === 'groupplay')) {
  568. friendlyCupsAndLeagues()
  569. }
  570.  
  571.  
  572. }, 2000);
  573.  
  574.  
  575. (function () {
  576.  
  577. if (document.getElementById("league_tab_table") !== null) {
  578. document.getElementById("league_tab_table").addEventListener('click', function () {
  579. if (document.getElementById("showMenu") === null) {
  580. leagues()
  581. }
  582. });
  583.  
  584. }
  585.  
  586.  
  587. })();
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600. setTimeout(function () {
  601.  
  602.  
  603.  
  604.  
  605. (function () {
  606.  
  607. if (document.getElementById("ui-id-2") !== null) {
  608. document.getElementById("ui-id-2").parentNode.addEventListener('click', function () {
  609. if (document.getElementById("showMenu") === null) {
  610.  
  611. var urlParams = new URLSearchParams(window.location.search);
  612.  
  613. if (urlParams.get('fsid')) {
  614. friendlyCupsAndLeagues()
  615. } else {
  616. clashLeagues()
  617. }
  618.  
  619.  
  620. }
  621. });
  622.  
  623. }
  624. })();
  625.  
  626.  
  627.  
  628. (function () {
  629.  
  630. if (document.getElementById("ui-id-4") !== null) {
  631. document.getElementById("ui-id-4").parentNode.addEventListener('click', function () {
  632. if (document.getElementById("showMenu") === null) {
  633. friendlyCupsAndLeagues()
  634. }
  635. });
  636.  
  637. }
  638. })();
  639.  
  640.  
  641.  
  642.  
  643.  
  644. }, 2000);
  645.  
  646.  
  647. function fetchExistTeam(url) {
  648. return new Promise((resolve, reject) => {
  649.  
  650. GM_xmlhttpRequest({
  651. method: "GET",
  652. url: url,
  653. headers: {
  654. "Content-Type": "application/json"
  655. },
  656. onload: function (response) {
  657. var jsonResponse = JSON.parse(response.responseText);
  658. resolve(jsonResponse['inserted'])
  659. },
  660. onerror: function (error) {
  661. reject("no");
  662. }
  663. });
  664. });
  665. }
  666.  
  667. function fetchExistPlayers(url) {
  668. return new Promise((resolve, reject) => {
  669.  
  670. GM_xmlhttpRequest({
  671. method: "GET",
  672. url: url,
  673. headers: {
  674. "Content-Type": "application/json"
  675. },
  676. onload: function (response) {
  677. var jsonResponse = JSON.parse(response.responseText);
  678. console.log(jsonResponse)
  679. resolve(jsonResponse)
  680. },
  681. onerror: function (error) {
  682. reject("no");
  683. }
  684. });
  685. });
  686. }
  687.  
  688. async function match() {
  689.  
  690.  
  691.  
  692. var team_div = document.getElementsByClassName("flex-grow-0 textCenter team-table block")
  693. var teams_ = []
  694.  
  695.  
  696. for (x = 0; x < 2; x++) {
  697. var as = team_div[x].getElementsByTagName("a")
  698. var urlObj = new URL("https://www.managerzone.com/" + as[0].getAttribute('href'));
  699. var params = new URLSearchParams(urlObj.search);
  700. var tidValue = params.get('tid');
  701. teams_[x] = { "team_name": as[0].innerHTML, "team_id": tidValue, "inserted": "" }
  702.  
  703. }
  704.  
  705.  
  706. var elems = document.getElementsByClassName("hitlist " + window.sport + " statsLite marker tablesorter");
  707. for (var x = 0; x < 2; x++) {
  708. var linkIds = ""
  709. var contIds = 0;
  710. var tabla = elems[x]
  711. var filas = tabla.getElementsByTagName("tr");
  712. var fila = filas[1];
  713.  
  714. for (var i = 2; i < filas.length - 1; i++) {
  715.  
  716. fila = filas[i];
  717. var tds = fila.getElementsByTagName("td");
  718. var as_ = tds[2].getElementsByTagName("a");
  719. urlObj = new URL("https://www.managerzone.com/" + as_[0].getAttribute("href"));
  720. params = new URLSearchParams(urlObj.search);
  721. var pid = params.get('pid');
  722.  
  723. linkIds += "&id" + contIds + "=" + pid
  724. contIds++;
  725.  
  726.  
  727.  
  728. }
  729.  
  730. link = "http://statsxente.com/MZ1/Functions/tamper_check_stats_player.php?sport=" + window.sport + linkIds
  731. var inserted = await fetchExistPlayers(link);
  732. teams_[x] = { "team_name": as[0].innerHTML, "team_id": tidValue, "inserted": inserted }
  733.  
  734. }
  735. elems = document.getElementsByClassName("hitlist " + window.sport + " statsLite marker tablesorter");
  736. for (x = 0; x < 2; x++) {
  737. if (teams_[x]['inserted']['total'] > 0) {
  738. tabla = elems[x]
  739. var firstTrThead = tabla.querySelector('thead td');
  740. var currentColspan = firstTrThead.getAttribute('colspan');
  741. currentColspan = parseInt(currentColspan, 10) + 1;
  742. firstTrThead.setAttribute('colspan', currentColspan);
  743. var secondTrThead = tabla.querySelector('thead tr:nth-of-type(2)')
  744. var newTd = document.createElement('td');
  745. newTd.textContent = '';
  746. secondTrThead.appendChild(newTd);
  747. filas = tabla.getElementsByTagName("tr");
  748. fila = filas[1];
  749. var dato = document.createElement("td");
  750. var tfoot = tabla.querySelector("tfoot");
  751. var primeraFilaTfoot = tfoot.querySelector("tr");
  752. var primerTDTfoot = primeraFilaTfoot.querySelector("td");
  753. primerTDTfoot.setAttribute("colspan", "9");
  754.  
  755. var elems2 = document.getElementsByClassName("listHeadColor");
  756. var lista = elems2[0]
  757.  
  758. var nuevoElementoDD = document.createElement("dd");
  759. nuevoElementoDD.textContent = "Nuevo elemento";
  760. nuevoElementoDD.className = "c6"
  761. lista.appendChild(nuevoElementoDD);
  762.  
  763. var id = 1516;
  764. for (i = 2; i < filas.length - 1; i++) {
  765. fila = filas[i];
  766.  
  767. tds = fila.getElementsByTagName("td");
  768. as_ = tds[2].getElementsByTagName("a");
  769. urlObj = new URL("https://www.managerzone.com/" + as_[0].getAttribute("href"));
  770. params = new URLSearchParams(urlObj.search);
  771. pid = params.get('pid');
  772. if (teams_[x]['inserted'][pid] == "yes") {
  773. dato = document.createElement("td");
  774. var iner = "<img src='https://statsxente.com/MZ1/View/Images/etiqueta_bota.png' width='20px' height='20px' id='but" + pid + "' style='cursor:pointer;'/>";
  775. dato.innerHTML = iner
  776. fila.appendChild(dato);
  777.  
  778.  
  779.  
  780. (function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
  781. document.getElementById("but" + currentId).addEventListener('click', function () {
  782.  
  783. var link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
  784. + "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
  785. "&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
  786. openWindow(link, 0.95, 1.25);
  787. });
  788. })(pid, teams_[x]['team_id'], window.sport, window.lang, teams_[x]['team_name'], as_[0].innerHTML);
  789.  
  790.  
  791. }
  792. }
  793. }
  794. }
  795. }
  796.  
  797. function clash() {
  798.  
  799. var badges = document.getElementsByClassName("fed_badge");
  800. var regex = /fid=(\d+)/;
  801. var srcLocal = badges[0].getAttribute('src');
  802. var local_id = srcLocal.match(regex);
  803. var src_away = badges[1].getAttribute('src');
  804. var away_id = src_away.match(regex);
  805. var names = document.getElementsByClassName("name-score text-ellipsis")
  806. var elems = document.getElementsByClassName("top-pane__deadline");
  807. var tabla = elems[0]
  808.  
  809. 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>";
  810. tabla.insertAdjacentHTML('beforeend', contenidoNuevo)
  811.  
  812. document.getElementById("clashCompare").addEventListener('click', function () {
  813. var link = "https://statsxente.com/MZ1/Functions/loadClashFederationData.php?tamper=yes&fid=" + local_id[1] + "&fid1=" + away_id[1] + "&fede=" + encodeURIComponent(names[0].innerText) + "&fede1=" + encodeURIComponent(names[1].innerText) + "&idioma=" + window.lang + "&divisa=" + GM_getValue("currency") + "&sport=" + window.sport;
  814. openWindow(link, 0.95, 1.25);
  815. });
  816.  
  817. }
  818.  
  819.  
  820. var teams_data = "";
  821. var searchClassName = ""
  822.  
  823. function leagues() {
  824. var urlParams = new URLSearchParams(window.location.search);
  825. var initialValues = {};
  826. initialValues["senior"] = GM_getValue("league_default_senior");
  827. initialValues["world"] = GM_getValue("league_default_senior");
  828. initialValues["u23"] = GM_getValue("league_default_u23");
  829. initialValues["u21"] = GM_getValue("league_default_u21");
  830. initialValues["u18"] = GM_getValue("league_default_u18");
  831. initialValues["u23_world"] = GM_getValue("league_default_u23");
  832. initialValues["u21_world"] = GM_getValue("league_default_u21");
  833. initialValues["u18_world"] = GM_getValue("league_default_u18");;
  834.  
  835. var linkIds = ""
  836. var elems = document.getElementsByClassName("nice_table");
  837. var tabla = elems[0]
  838. var thSegundo = tabla.querySelector("thead th:nth-child(2)");
  839. thSegundo.style.width = "250px";
  840.  
  841.  
  842. var values = new Map();
  843. values.set('valor23', 'U23 Value');
  844. values.set('valor21', 'U21 Value');
  845. values.set('valor18', 'U18 Value');
  846. values.set('salario', 'Salary');
  847. values.set('valorUPSenior', 'LM Value');
  848. values.set('valorUPSUB23', 'U23 LM Value');
  849. values.set('valorUPSUB21', 'U21 LM Value');
  850. values.set('valorUPSUB18', 'U18 LM Value');
  851. values.set('edad', 'Age');
  852. if (window.sport == "soccer") {
  853. values.set('valor11', 'TOP 11');
  854. values.set('valor11_23', 'U23 TOP 11');
  855. values.set('valor11_21', 'U21 TOP 11');
  856. values.set('valor11_18', 'U18 TOP 11');
  857. } else {
  858. values.set('valor11', 'TOP 21');
  859. values.set('valor11_23', 'U23 TOP 21');
  860. values.set('valor11_21', 'U21 TOP 21');
  861. values.set('valor11_18', 'U18 TOP 21');
  862. }
  863.  
  864. values.set('noNac', 'Foreigners');
  865. values.set('elo', 'ELO Score');
  866. values.set('elo23', 'U23 ELO Score');
  867. values.set('elo21', 'U21 ELO Score');
  868. values.set('elo18', 'U18 ELO Score');
  869. values.set('numJugadores', 'Number of players');
  870.  
  871. if (urlParams.get('type') == "senior") {
  872. values.set('leagues', 'Leagues');
  873. values.set('world_leagues_all', 'World Leagues');
  874. values.set('youth_leagues_all', 'Youth Leagues');
  875. values.set('world_youth_leagues_all', 'Youth World Leagues');
  876. values.set('federation_leagues', 'Federation Leagues');
  877. }
  878.  
  879.  
  880. if (urlParams.get('type') == "world") {
  881. values.set('leagues_all', 'Leagues');
  882. values.set('world_leagues', 'World Leagues');
  883. values.set('youth_leagues_all', 'Youth Leagues');
  884. values.set('world_youth_leagues_all', 'Youth World Leagues');
  885. values.set('federation_leagues', 'Federation Leagues');
  886. }
  887.  
  888.  
  889. if ((urlParams.get('type').includes("u")) && (!urlParams.get('type').includes("_"))) {
  890. var actual_cat = urlParams.get('type').toUpperCase();
  891. GM_setValue("actual_league_cat", actual_cat)
  892. values.set('leagues_all', 'Leagues');
  893. values.set('world_leagues_all', 'World Leagues');
  894. values.set('youth_leagues', actual_cat + ' Youth Leagues');
  895. values.set('world_youth_leagues_all', 'Youth World Leagues');
  896. values.set('federation_leagues', 'Federation Leagues');
  897. }
  898.  
  899.  
  900. if ((urlParams.get('type').includes("u")) && (urlParams.get('type').includes("_"))) {
  901. actual_cat = urlParams.get('type').substring(0, 3).toUpperCase();
  902. GM_setValue("actual_league_cat", actual_cat)
  903. values.set('leagues_all', 'Leagues');
  904. values.set('world_leagues_all', 'World Leagues');
  905. values.set('youth_leagues_all', 'Youth Leagues');
  906. values.set('world_youth_leagues', actual_cat + ' Youth World Leagues');
  907. values.set('federation_leagues', 'Federation Leagues');
  908. }
  909. values.set('cup', 'Cups');
  910. values.set('cup_u23', 'U23 Cups');
  911. values.set('cup_u21', 'U21 Cups');
  912. values.set('cup_u18', 'U18 Cups');
  913. values.set('special_cup', 'Special Cups');
  914.  
  915. var contenidoNuevo = '<div id=testClick><center>'
  916.  
  917.  
  918. getNativeTableStyles();
  919.  
  920. var idProgress = "noProgress";
  921. if (urlParams.get('type') == "senior") {
  922. idProgress = "divProgress"
  923. }
  924.  
  925.  
  926. var widthTable = "1.5em"
  927. ///MENU TABLE
  928. contenidoNuevo += "<center><table id=showMenu border=0><thead style='background-color:" + GM_getValue("bg_native") + "; color:" + GM_getValue("color_native") + ";'><tr>";
  929. contenidoNuevo += '<th align=center style="padding:4px;">Stats</th><th align=center style="padding:4px;">Graph</th>';
  930. contenidoNuevo += "<th align=center style='padding:4px;'>History</th>";
  931. contenidoNuevo += "<th align=center style='padding:4px;'>Top Players</th></tr></thead>";
  932. contenidoNuevo += "<tr>";
  933. 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>";
  934. 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>";
  935. if (idProgress == "noProgress") {
  936. 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>";
  937. } else {
  938. 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>";
  939. }
  940. 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>";
  941. contenidoNuevo += "</tr>";
  942.  
  943. var styleTable = " style='display:none;'";
  944. var styleIcon = ""
  945. var styleSep = "style='padding-top:5px;'";
  946.  
  947. if (GM_getValue("show_league_selects") == true) {
  948. styleTable = "";
  949. styleIcon = " active"
  950. styleSep = " style='display:none;'";
  951. }
  952.  
  953.  
  954. contenidoNuevo += "<tr><td></td><td colspan='2'>";
  955. 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>';
  956. contenidoNuevo += "</td><td></td></tr>";
  957. contenidoNuevo += "<tr><td colspan='5' id='separatorTd'" + styleSep + "></td></tr>";
  958. contenidoNuevo += "</table></center>";
  959. contenidoNuevo += '<table id=show3 border="0"' + styleTable + '><tr><td><label>';
  960.  
  961. if ((urlParams.get('type') == 'senior') || (urlParams.get('type') == 'world')) {
  962. if ("valor" == initialValues[urlParams.get('type')]) {
  963. contenidoNuevo += '<input class="statsxente" type="checkbox" checked id="valor" value="Value">Value</label></td>';
  964. } else {
  965. contenidoNuevo += '<input class="statsxente" type="checkbox" id="valor" value="Value">Value</label></td>';
  966. }
  967. } else {
  968. contenidoNuevo += '<input class="statsxente" type="checkbox" id="valor" value="Value">Value</label></td>';
  969. }
  970.  
  971. values.forEach(function (valor, clave) {
  972.  
  973. if (clave == "valorUPSenior") {
  974. contenidoNuevo += "</tr><tr>";
  975. }
  976.  
  977. if (clave == "valor11") {
  978. contenidoNuevo += "</tr><tr>";
  979. }
  980. if (clave == "elo") {
  981. contenidoNuevo += "</tr><tr>";
  982. }
  983.  
  984. if (clave == "leagues") {
  985. contenidoNuevo += "</tr><tr>";
  986. }
  987.  
  988. if (clave == "leagues_all") {
  989. contenidoNuevo += "</tr><tr>";
  990. }
  991.  
  992. if (clave == "cup") {
  993. contenidoNuevo += "</tr><tr>";
  994. }
  995.  
  996. if (clave == initialValues[urlParams.get('type')]) {
  997. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" checked value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  998. } else {
  999. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  1000. }
  1001. });
  1002. contenidoNuevo += "</tr></table></center>"
  1003. contenidoNuevo += "</div></br>";
  1004. values.set('valor', 'Value');
  1005.  
  1006. elems = document.getElementsByClassName("nice_table");
  1007. tabla = elems[0]
  1008. tabla.insertAdjacentHTML('beforebegin', contenidoNuevo);
  1009.  
  1010. if (GM_getValue("show_league_selects") == true) {
  1011. document.getElementById("line2").style.transform = 'rotateZ(0deg)';
  1012. document.getElementById("line1").style.transform = 'rotateZ(180deg)';
  1013. document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
  1014. }
  1015.  
  1016.  
  1017. values.forEach(function (valor, clave) {
  1018. var elemento = document.getElementById(clave);
  1019. elemento.addEventListener('click', handleClick);
  1020. });
  1021.  
  1022. var nuevaCeldaEncabezado = document.createElement("th");
  1023. nuevaCeldaEncabezado.textContent = values.get(initialValues[urlParams.get('type')]);
  1024. nuevaCeldaEncabezado.style.textAlign = 'center';
  1025. nuevaCeldaEncabezado.style.maxWidth = '6.5em';
  1026. nuevaCeldaEncabezado.style.width = '6.5em';
  1027. nuevaCeldaEncabezado.style.whiteSpace = 'nowrap';
  1028. nuevaCeldaEncabezado.style.overflow = 'hidden';
  1029. nuevaCeldaEncabezado.style.textOverflow = 'ellipsis';
  1030.  
  1031. var ser = document.getElementsByClassName("seriesHeader")
  1032. document.getElementsByClassName("seriesHeader")[0].appendChild(nuevaCeldaEncabezado);
  1033.  
  1034. nuevaCeldaEncabezado = document.createElement("th");
  1035. nuevaCeldaEncabezado.textContent = "Stats Xente";
  1036. nuevaCeldaEncabezado.style.textAlign = 'center';
  1037. document.getElementsByClassName("seriesHeader")[0].appendChild(nuevaCeldaEncabezado);
  1038.  
  1039.  
  1040. if (tabla.getElementsByTagName("tbody")[0].innerHTML.includes("mazyar")) {
  1041. searchClassName = "responsive-hide"
  1042. }
  1043.  
  1044. var contIds = 0
  1045. var filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  1046. for (var i = 0; i < filasDatos.length; i++) {
  1047. if (checkClassNameExists(tabla.rows[i + 1], searchClassName)) {
  1048. var celda = tabla.rows[i + 1].cells[1];
  1049. var equipo = celda.textContent.trim()
  1050. var iniIndex = celda.innerHTML.indexOf("tid=");
  1051. var lastIndex = celda.innerHTML.indexOf("\">", iniIndex + 4);
  1052. var data = String(celda.innerHTML)
  1053. var id = data.substring(iniIndex + 4, lastIndex)
  1054. linkIds += "&idEquipo" + contIds + "=" + id
  1055. contIds++
  1056. celda.innerHTML += "<input type='hidden' id='team_" + id + "' value='" + equipo + "'/>"
  1057. }
  1058.  
  1059. }
  1060. var cat = cats[urlParams.get('type')]
  1061. var enlace = document.getElementById('league_tab_schedule');
  1062. var href = enlace.href;
  1063. var url = new URL(href);
  1064. var league_id = url.searchParams.get('sid');
  1065.  
  1066.  
  1067.  
  1068. ///DIV PROGRESS
  1069. setTimeout(function () {
  1070.  
  1071.  
  1072. if (idProgress != "noProgress") {
  1073. (function (currentId, currentLSport, lang) {
  1074. document.getElementById("divProgress").addEventListener('click', function () {
  1075.  
  1076. var link = "https://statsxente.com/MZ1/Graficos/graficoProgresoDivision.php?idLiga=" + currentId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") + "&deporte=" + currentLSport;
  1077. openWindow(link, 0.95, 1.25);
  1078. });
  1079. })(league_id, window.lsport, window.lang);
  1080.  
  1081. }
  1082.  
  1083.  
  1084. (function () {
  1085. document.getElementById("moreInfo").addEventListener('click', function () {
  1086. document.getElementById("moreInfo").classList.toggle('active');
  1087.  
  1088. if (document.getElementById("moreInfo").classList.contains("active")) {
  1089. document.getElementById("line2").style.transform = 'rotateZ(0deg)';
  1090. document.getElementById("line1").style.transform = 'rotateZ(180deg)';
  1091. document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
  1092. $('#separatorTd').fadeOut(1);
  1093. document.getElementById("separatorTd").style.paddingTop = "5px";
  1094. $('#show3').fadeIn('slow');
  1095. } else {
  1096. document.getElementById("line2").style.transform = 'rotateZ(45deg)';
  1097. document.getElementById("line1").style.transform = 'rotateZ(-45deg)';
  1098. document.getElementById("moreInfo").style.transform = 'rotateZ(45deg)';
  1099. $('#separatorTd').fadeIn(1);
  1100. $('#show3').fadeOut('slow');
  1101. }
  1102.  
  1103.  
  1104.  
  1105. });
  1106. })();
  1107.  
  1108. (function (currentId, currentLSport, lang, currentCat) {
  1109. document.getElementById("detailDivision").addEventListener('click', function () {
  1110. var url_ = "https://statsxente.com/MZ1/Functions/lecturaStatsDivisionesHistorico2.0.php"
  1111. if (window.sport == "hockey") {
  1112. url_ = "https://statsxente.com/MZ1/Functions/lecturaStatsDivisionesHockeyHistorico.php"
  1113. }
  1114.  
  1115. var link = url_ + "?tamper=yes&modal=yes&idLiga=" + currentId + "&idioma=" + lang + "&categoria=" + currentCat + "&season=75&season_actual=75";
  1116. openWindow(link, 0.95, 1.25);
  1117. });
  1118. })(league_id, window.lsport, window.lang, cat);
  1119.  
  1120. (function (currentId, sport, lang, currentCat) {
  1121. document.getElementById("topPlayersDivision").addEventListener('click', function () {
  1122. var url_ = "https://statsxente.com/MZ1/Functions/tamper_top_players_division.php"
  1123. if (window.sport == "hockey") {
  1124. url_ = "https://statsxente.com/MZ1/Functions/tamper_top_players_division_hockey.php"
  1125. }
  1126. var link = url_ + "?league_id=" + currentId + "&sport=" + sport + "&category=" + cat + "&idioma=" + lang;
  1127. openWindow(link, 0.95, 1.25);
  1128. });
  1129. })(league_id, window.sport, window.lang, cat);
  1130.  
  1131. (function (currentId, currentLSport, lang, currentCat) {
  1132. document.getElementById("graphDivision").addEventListener('click', function () {
  1133. var url_sport = ""
  1134. if (window.sport == "hockey") {
  1135. url_sport = "Hockey"
  1136. }
  1137. 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";
  1138. openWindow(link, 0.95, 1.25);
  1139. });
  1140. })(league_id, window.lsport, window.lang, cat);
  1141.  
  1142.  
  1143. }, 200);
  1144.  
  1145. GM_xmlhttpRequest({
  1146. method: "GET",
  1147. url: "https://statsxente.com/MZ1/Functions/tamper_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + linkIds,
  1148. headers: {
  1149. "Content-Type": "application/json"
  1150. },
  1151. onload: function (response) {
  1152. var cat = window.cats[urlParams.get('type')]
  1153. var jsonResponse = JSON.parse(response.responseText);
  1154. teams_data = jsonResponse;
  1155. var filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  1156. for (var i = 0; i < filasDatos.length; i++) {
  1157. if (checkClassNameExists(filasDatos[i], searchClassName)) {
  1158. var celda = filasDatos[i].cells[1];
  1159. var equipo = celda.textContent.trim()
  1160. var iniIndex = celda.innerHTML.indexOf("tid=");
  1161. var lastIndex = celda.innerHTML.indexOf("\">", iniIndex + 4);
  1162. var data = String(celda.innerHTML)
  1163. var id = data.substring(iniIndex + 4, lastIndex)
  1164. var nuevaColumna = document.createElement("td");
  1165. var valor = 0;
  1166.  
  1167. if (jsonResponse[id] && jsonResponse[id][initialValues[urlParams.get('type')]] !== undefined) {
  1168. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[id][initialValues[urlParams.get('type')]]))
  1169. }
  1170. nuevaColumna.innerHTML = valor
  1171. nuevaColumna.style.textAlign = 'center';
  1172. filasDatos[i].appendChild(nuevaColumna);
  1173.  
  1174. var eloType = 1
  1175.  
  1176. if (window.sport == "soccer") { eloType = 2 }
  1177. if (cat.includes("SUB")) { eloType = 3 }
  1178. var cats_elo = {}
  1179. cats_elo["senior"] = "SENIOR";
  1180. cats_elo["seniorw"] = "SENIOR";
  1181. cats_elo["SUB23"] = "U23";
  1182. cats_elo["SUB21"] = "U21";
  1183. cats_elo["SUB18"] = "U18";
  1184. cats_elo["SUB23w"] = "U23";
  1185. cats_elo["SUB21w"] = "U21";
  1186. cats_elo["SUB18w"] = "U18";
  1187.  
  1188. var flagSenior = 0, flagSub23 = 0, flagSub21 = 0, flagSub18 = 0;
  1189. if (jsonResponse[id]["elo"] > 0) { flagSenior = 1 }
  1190. if (jsonResponse[id]["elo23"] > 0) { flagSub23 = 1 }
  1191. if (jsonResponse[id]["elo21"] > 0) { flagSub21 = 1 }
  1192. if (jsonResponse[id]["elo18"] > 0) { flagSub18 = 1 }
  1193.  
  1194. var buttonDisplay = "display:block;";
  1195. nuevaColumna = document.createElement("td");
  1196. 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;'/>";
  1197. if (GM_getValue("league_graph_button") == "checked") {
  1198. buttonDisplay = ""
  1199. } else {
  1200. buttonDisplay = "display:none;";
  1201. }
  1202. 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 + "'/>";
  1203.  
  1204. if (GM_getValue("league_report_button") == "checked") {
  1205. buttonDisplay = ""
  1206. } else {
  1207. buttonDisplay = "display:none;";
  1208. }
  1209. 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 + "'/>";
  1210.  
  1211. if (GM_getValue("league_calendar_button") == "checked") {
  1212. buttonDisplay = ""
  1213. } else {
  1214. buttonDisplay = "display:none;";
  1215. }
  1216. 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 + "'/>";
  1217. iner += "</center>";
  1218. cat = cats[urlParams.get('type')]
  1219. nuevaColumna.innerHTML = iner
  1220. filasDatos[i].appendChild(nuevaColumna);
  1221. nuevaColumna = document.createElement("td");
  1222.  
  1223.  
  1224. (function (currentId, currentLSport, lang) {
  1225. document.getElementById("but1" + currentId).addEventListener('click', function () {
  1226. var link = "https://statsxente.com/MZ1/Graficos/graficoProgresoEquipo.php?idEquipo=" + currentId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") + "&deporte=" + currentLSport;
  1227. openWindow(link, 0.95, 1.25);
  1228. });
  1229. })(id, window.lsport, window.lang);
  1230.  
  1231. (function (currentId, currentLSport, lang, currentCat) {
  1232. document.getElementById("but2" + currentId).addEventListener('click', function () {
  1233. var src = "filtroGraficoEquiposHistoricoHockey";
  1234. if (currentLSport == "F") {
  1235. src = "filtroGraficoLinealEquiposHistorico";
  1236. }
  1237. 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=-"
  1238. openWindow(link, 0.95, 1.25);
  1239. });
  1240. })(id, window.lsport, window.lang, cat);
  1241.  
  1242. (function (currentId, currentEquipo, currentCat, currentSport, lang) {
  1243. document.getElementById("but" + currentId).addEventListener('click', function () {
  1244.  
  1245. 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";
  1246. openWindow(link, 0.95, 1.25);
  1247. });
  1248. })(id, equipo, cat, window.sport, window.lang);
  1249.  
  1250. (function (currentId, type, currentCat, currentSport, lang, flagS, flagS23, flagS21, flagS18) {
  1251. document.getElementById("but3" + currentId).addEventListener('click', function () {
  1252. var link = "https://statsxente.com/MZ1/Graficos/graficoRachaEquipoELO.php?tamper=yes&team_id=" + currentId + "&idioma=" + lang + "&deporte=" + currentSport + "&type=" + type + "&cat=" + currentCat + "&flagSenior=" +
  1253. flagS + "&flagSub23=" + flagS23 + "&flagSub21=" + flagS21 + "&flagSub18=" + flagS18;
  1254. openWindow(link, 0.95, 1.25);
  1255. });
  1256. })(id, eloType, cats_elo[cat], window.sport, window.lang, flagSenior, flagSub23, flagSub21, flagSub18);
  1257.  
  1258. }
  1259.  
  1260. }
  1261.  
  1262. var thead = document.getElementsByClassName("seriesHeader")[0]
  1263. var ths = thead.querySelectorAll("th");
  1264. ths.forEach(function (th, index) {
  1265. th.addEventListener("click", function () {
  1266. if (index == 1) {
  1267. ordenarTablaText(index, true, "nice_table");
  1268. } else {
  1269. ordenarTabla(index, true, "nice_table");
  1270. }
  1271.  
  1272. });
  1273. });
  1274. }
  1275. });
  1276. }
  1277.  
  1278.  
  1279. function openWindow(link, porAncho, porAlto) {
  1280. var ventanaAncho = (window.innerWidth) * porAncho
  1281. var ventanaAlto = (window.innerHeight) * porAlto
  1282. var ventanaIzquierda = (window.innerWidth - ventanaAncho) / 2;
  1283. var ventanaArriba = (window.innerHeight - ventanaAlto) / 2;
  1284. var opcionesVentana = "width=" + ventanaAncho +
  1285. ",height=" + ventanaAlto +
  1286. ",left=" + ventanaIzquierda +
  1287. ",top=" + ventanaArriba;
  1288.  
  1289. if ((GM_getValue("tabsConfig") == false) && (GM_getValue("windowsConfig") == true)) {
  1290. window.open(link, "_blank", opcionesVentana);
  1291. }
  1292. if ((GM_getValue("tabsConfig") == true) && (GM_getValue("windowsConfig") == false)) {
  1293. window.open(link, "_blank");
  1294. }
  1295. }
  1296. function handleClick(event) {
  1297. var urlParams = new URLSearchParams(window.location.search);
  1298. var elems = document.getElementsByClassName("nice_table");
  1299. var tabla = elems[0]
  1300. var filas = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  1301. var thSegundo = tabla.querySelector("thead th:nth-child(2)");
  1302.  
  1303. if (urlParams.get('fsid')) {
  1304. thSegundo.style.width = "180px";
  1305. } else {
  1306. thSegundo.style.width = "250px";
  1307. }
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314. for (var i = 0; i < filas.length; i++) {
  1315. if (checkClassNameExists(filas[i], searchClassName)) {
  1316. var celda = filas[i].cells[1];
  1317. var equipo = celda.textContent.trim()
  1318. var iniIndex = celda.innerHTML.indexOf("tid=");
  1319. var lastIndex = celda.innerHTML.indexOf("\">", iniIndex + 4);
  1320. var data = String(celda.innerHTML)
  1321. var id = data.substring(iniIndex + 4, lastIndex)
  1322. var celdas = filas[i].getElementsByTagName("td");
  1323. var ultimaCelda = celdas[celdas.length - 2];
  1324. var selects = document.getElementsByTagName('select');
  1325. var index_select = 1;
  1326. if (selects[index_select] === undefined) {
  1327. index_select = 0;
  1328. }
  1329.  
  1330.  
  1331. var selectedIndex = selects[index_select].selectedIndex;
  1332. var selectedOption = selects[index_select].options[selectedIndex];
  1333. var selectedText = selectedOption.text;
  1334.  
  1335.  
  1336.  
  1337. var key_actual_league = "Top";
  1338. if (selectedText.includes(".")) {
  1339. key_actual_league = selectedText.substring(0, 4)
  1340. }
  1341.  
  1342. var valor = 0;
  1343.  
  1344. if (teams_data[id] === undefined) {
  1345. valor = 0
  1346. } else {
  1347.  
  1348. var table_key = "";
  1349. var agg_value = 0;
  1350.  
  1351. switch (event.target.id) {
  1352. case 'edad':
  1353. valor = new Intl.NumberFormat(window.userLocal, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(teams_data[id][event.target.id])
  1354. break;
  1355. case "leagues":
  1356. table_key = "league"
  1357. 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']
  1358. valor = "(" + teams_data[id]['league_' + key_actual_league] + '/' + agg_value + ")"
  1359. break;
  1360.  
  1361. case "world_leagues":
  1362. table_key = "world_league"
  1363. 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']
  1364. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  1365. break;
  1366.  
  1367. case "youth_leagues":
  1368. var cat = GM_getValue("actual_league_cat").toLowerCase()
  1369. table_key = "league_" + cat
  1370. 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']
  1371. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  1372. break;
  1373.  
  1374. case "world_youth_leagues":
  1375. cat = GM_getValue("actual_league_cat").toLowerCase()
  1376. table_key = "world_league_" + cat
  1377. 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']
  1378. valor = "(" + teams_data[id][table_key + '_' + key_actual_league] + '/' + agg_value + ")"
  1379. break;
  1380.  
  1381. case "leagues_all":
  1382. table_key = "league"
  1383. 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']
  1384. break;
  1385.  
  1386.  
  1387. case "world_leagues_all":
  1388. table_key = "world_league"
  1389. 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']
  1390. break;
  1391.  
  1392. case "youth_leagues_all":
  1393. table_key = "league_u23"
  1394. 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']
  1395. table_key = "league_u21"
  1396. 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']
  1397. table_key = "league_u18"
  1398. 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']
  1399. break;
  1400.  
  1401. case "world_youth_leagues_all":
  1402. table_key = "world_league_u23"
  1403. 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']
  1404. table_key = "world_league_u21"
  1405. 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']
  1406. table_key = "world_league_u18"
  1407. 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']
  1408. break;
  1409.  
  1410. case "federation_leagues":
  1411. table_key = "federation_league"
  1412. 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']
  1413. valor = agg_value
  1414. break;
  1415.  
  1416.  
  1417. default:
  1418. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(teams_data[id][event.target.id]))
  1419. break;
  1420.  
  1421.  
  1422. }
  1423. }
  1424.  
  1425. ultimaCelda.innerHTML = valor;
  1426. }
  1427. }
  1428. var checkboxes = document.querySelectorAll('.statsxente');
  1429. var thead = tabla.querySelector('thead');
  1430. var tr = thead.querySelectorAll('tr');
  1431. var td = tr[0].querySelectorAll('th');
  1432. var ultimaCeldaEncabezado = td[td.length - 2];
  1433. td[td.length - 2].textContent = event.target.value;
  1434. checkboxes.forEach(function (checkbox) {
  1435. if (checkbox.id !== event.target.id) {
  1436. checkbox.checked = false;
  1437. }
  1438. });
  1439. }
  1440.  
  1441.  
  1442. function putSortIcon(a, tabla_) {
  1443. var filaEncabezado = tabla_.querySelector('thead tr');
  1444. var celdas = filaEncabezado.getElementsByTagName('th');
  1445. if (celdas.length == 0) {
  1446. celdas = filaEncabezado.getElementsByTagName('td');
  1447. }
  1448. var elementos = tabla_.querySelectorAll('.bi.bi-arrow-down-short');
  1449. elementos.forEach(function (elemento) {
  1450. elemento.remove();
  1451. })
  1452.  
  1453. elementos = tabla_.querySelectorAll('.bi.bi-arrow-up-short');
  1454. elementos.forEach(function (elemento) {
  1455. elemento.remove();
  1456. })
  1457.  
  1458.  
  1459. 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>'
  1460. 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>'
  1461.  
  1462.  
  1463. 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>'
  1464. 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>'
  1465.  
  1466. var icon = iconAsc;
  1467. if (document.getElementById("ord_table").value == "descendente") {
  1468. icon = iconDesc;
  1469. }
  1470.  
  1471.  
  1472. celdas[a].innerHTML = icon + celdas[a].innerHTML;
  1473. }
  1474.  
  1475.  
  1476.  
  1477. function ordenarTabla(col, byClassName, param) {
  1478. if (byClassName) {
  1479. var elems = document.getElementsByClassName(param);
  1480. var table = elems[0]
  1481. } else {
  1482. table = document.getElementById(param)
  1483. }
  1484. putSortIcon(col, table)
  1485. var rows = Array.from(table.tBodies[0].rows);
  1486. var isAsc = document.getElementById("ord_table").value === "ascendente";
  1487. rows.sort(function (a, b) {
  1488. var aNum = parseFloat(a.cells[col].textContent.trim().replace(/\./g, '').replace(/\,/g, '')) || 0;
  1489. var bNum = parseFloat(b.cells[col].textContent.trim().replace(/\./g, '').replace(/\,/g, '')) || 0;
  1490. return isAsc ? aNum - bNum : bNum - aNum;
  1491. });
  1492.  
  1493. rows.forEach(function (row) {
  1494. table.tBodies[0].appendChild(row);
  1495. });
  1496.  
  1497. if (isAsc) {
  1498. document.getElementById("ord_table").value = "descendente";
  1499. } else {
  1500. document.getElementById("ord_table").value = "ascendente";
  1501. }
  1502.  
  1503. var filas = table.getElementsByTagName("tr");
  1504. for (var i = 1; i < filas.length; i++) {
  1505. var primeraCelda = filas[i].getElementsByTagName("td")[0];
  1506. primeraCelda.textContent = i;
  1507. }
  1508.  
  1509.  
  1510. }
  1511.  
  1512.  
  1513. function ordenarTablaText(col, byClassName, param) {
  1514. if (byClassName) {
  1515. var elems = document.getElementsByClassName(param);
  1516. var table = elems[0]
  1517. } else {
  1518. table = document.getElementById(param)
  1519. }
  1520. var rows = Array.from(table.tBodies[0].rows);
  1521. var isAsc = document.getElementById("ord_table").value === "ascendente";
  1522. putSortIcon(col, table)
  1523. rows.sort(function (a, b) {
  1524. var aText = a.cells[col].textContent.toLowerCase().trim();
  1525. var bText = b.cells[col].textContent.toLowerCase().trim();
  1526. console.log(aText + " " + bText);
  1527. if (aText < bText) {
  1528. return isAsc ? -1 : 1;
  1529. }
  1530. if (aText > bText) {
  1531. return isAsc ? 1 : -1;
  1532. }
  1533. return 0;
  1534. });
  1535.  
  1536. rows.forEach(function (row) {
  1537. table.tBodies[0].appendChild(row);
  1538. });
  1539.  
  1540. if (isAsc) {
  1541. document.getElementById("ord_table").value = "descendente";
  1542. } else {
  1543. document.getElementById("ord_table").value = "ascendente";
  1544. }
  1545.  
  1546.  
  1547. var filas = table.getElementsByTagName("tr");
  1548. for (var i = 1; i < filas.length; i++) {
  1549. var primeraCelda = filas[i].getElementsByTagName("td")[0];
  1550. primeraCelda.textContent = i;
  1551. }
  1552.  
  1553. }
  1554.  
  1555.  
  1556. function ordenarTablaq(columna, byClassName, param) {
  1557. if (byClassName) {
  1558. var elems = document.getElementsByClassName(param);
  1559. var tabla = elems[0]
  1560. } else {
  1561. tabla = document.getElementById(param)
  1562. }
  1563. var filas, switching, i, x, y, debeCambiar, direccion, cambioRealizado;
  1564. switching = true;
  1565. direccion = document.getElementById("ord_table").value
  1566. while (switching) {
  1567. switching = false;
  1568. filas = tabla.rows;
  1569. for (i = 1; i < (filas.length - 1); i++) {
  1570. debeCambiar = false;
  1571. x = filas[i].getElementsByTagName("td")[columna];
  1572. y = filas[i + 1].getElementsByTagName("td")[columna];
  1573. var xValue = parseFloat(x.innerHTML.replace(/\./g, "").replace(/[^0-9,-]+/g, "").replace(",", "."));
  1574. var yValue = parseFloat(y.innerHTML.replace(/\./g, "").replace(/[^0-9,-]+/g, "").replace(",", "."));
  1575. if (direccion == "ascendente") {
  1576. if (isNaN(xValue)) {
  1577. if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
  1578. debeCambiar = true;
  1579. break;
  1580. }
  1581. } else {
  1582. if (xValue > yValue) {
  1583. debeCambiar = true;
  1584. break;
  1585. }
  1586. }
  1587. } else if (direccion == "descendente") {
  1588. if (isNaN(xValue)) {
  1589. if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) {
  1590. debeCambiar = true;
  1591. break;
  1592. }
  1593. } else {
  1594. if (xValue < yValue) {
  1595. debeCambiar = true;
  1596. break;
  1597. }
  1598. }
  1599. }
  1600. }
  1601.  
  1602.  
  1603.  
  1604. if (debeCambiar) {
  1605. filas[i].parentNode.insertBefore(filas[i + 1], filas[i]);
  1606. switching = true;
  1607. cambioRealizado = true;
  1608. } else {
  1609. if (!cambioRealizado && direccion == "descendente") {
  1610. //direccion = "ascendente";
  1611. switching = true;
  1612. }
  1613. }
  1614. }
  1615.  
  1616. if (document.getElementById("ord_table").value == "descendente") {
  1617. document.getElementById("ord_table").value = "ascendente";
  1618. } else {
  1619. document.getElementById("ord_table").value = "descendente";
  1620. }
  1621.  
  1622.  
  1623. filas = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  1624. for (i = 0; i < filas.length; i++) {
  1625. var primerTd = filas[i].querySelector("td");
  1626. primerTd.innerHTML = (i + 1);
  1627. }
  1628. }
  1629. function getCookie(nombre) {
  1630. var regex = new RegExp("(?:(?:^|.*;\\s*)" + nombre + "\\s*\\=\\s*([^;]*).*$)|^.*$");
  1631. var valorCookie = document.cookie.replace(regex, "$1");
  1632. return decodeURIComponent(valorCookie);
  1633. }
  1634. function generateValuesSelect(cat) {
  1635.  
  1636.  
  1637. var defaults = new Map();
  1638. defaults.set('senior', 'valor');
  1639. defaults.set('u23', 'valor23');
  1640. defaults.set('u21', 'valor21');
  1641. defaults.set('u18', 'valor18');
  1642.  
  1643. var values = new Map();
  1644. values.set('valor', 'Value');
  1645. values.set('valor23', 'U23 Value');
  1646. values.set('valor21', 'U21 Value');
  1647. values.set('valor18', 'U18 Value');
  1648. values.set('salario', 'Salary');
  1649. values.set('valorUPSenior', 'LM Value');
  1650. values.set('valorUPSUB23', 'U23 LM Value');
  1651. values.set('valorUPSUB21', 'U21 LM Value');
  1652. values.set('valorUPSUB18', 'U18 LM Value');
  1653. values.set('edad', 'Age');
  1654. values.set('valor11', 'TOP 11/21');
  1655. values.set('valor11_23', 'U23 TOP 11/21');
  1656. values.set('valor11_21', 'U21 TOP 11/21');
  1657. values.set('valor11_18', 'U18 TOP 11/21');
  1658. values.set('noNac', 'Foreigners');
  1659. values.set('elo', 'ELO Score');
  1660. values.set('elo23', 'U23 ELO Score');
  1661. values.set('elo21', 'U21 ELO Score');
  1662. values.set('elo18', 'U18 ELO Score');
  1663. values.set('numJugadores', 'Number of players');
  1664.  
  1665.  
  1666. var default_value = GM_getValue("league_default_" + cat, defaults.get(cat))
  1667. GM_setValue("league_default_" + cat, default_value)
  1668.  
  1669. var select = "<select id='league_default_select_" + cat + "' style='width:115px;'>";
  1670. values.forEach((valor, clave, mapa) => {
  1671. var checked = ""
  1672. if (clave == default_value) {
  1673. checked = "selected"
  1674. }
  1675. select += "<option " + checked + " value='" + clave + "'>" + valor + "</option>";
  1676. });
  1677. select += "</select>"
  1678. return select;
  1679.  
  1680. }
  1681. function createLeagueConfigOptionsListeners() {
  1682.  
  1683. var defaults = new Map();
  1684. defaults.set('senior', 'valor');
  1685. defaults.set('u23', 'valor23');
  1686. defaults.set('u21', 'valor21');
  1687. defaults.set('u18', 'valor18');
  1688.  
  1689.  
  1690.  
  1691. defaults.forEach((valor, clave, mapa) => {
  1692.  
  1693.  
  1694.  
  1695. document.getElementById("league_default_select_" + clave).addEventListener('change', function () {
  1696.  
  1697. var selectElement = document.getElementById("league_default_select_" + clave);
  1698. GM_setValue("league_default_" + clave, selectElement.value)
  1699. });
  1700.  
  1701. });
  1702. document.getElementById("league_graph_check").addEventListener('click', function () {
  1703.  
  1704. if (document.getElementById("league_graph_check").checked) {
  1705. GM_setValue("league_graph_button", "checked")
  1706. } else {
  1707. GM_setValue("league_graph_button", "")
  1708. }
  1709.  
  1710.  
  1711. });
  1712.  
  1713.  
  1714. document.getElementById("league_report_check").addEventListener('click', function () {
  1715.  
  1716. if (document.getElementById("league_report_check").checked) {
  1717. GM_setValue("league_report_button", "checked")
  1718. } else {
  1719. GM_setValue("league_report_button", "")
  1720. }
  1721.  
  1722.  
  1723. });
  1724.  
  1725. document.getElementById("league_calendar_check").addEventListener('click', function () {
  1726.  
  1727. if (document.getElementById("league_calendar_check").checked) {
  1728. GM_setValue("league_calendar_button", "checked")
  1729. } else {
  1730. GM_setValue("league_calendar_button", "")
  1731. }
  1732.  
  1733.  
  1734. });
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741. }
  1742. function createModalMenu() {
  1743. //setTimeout(function () {
  1744. var newElement = document.createElement("div");
  1745. newElement.id = "legendDiv";
  1746. newElement.className = "stx_legend";
  1747. 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>';
  1748. var body = document.body;
  1749. body.appendChild(newElement);
  1750.  
  1751. var newModalElement = document.createElement('div');
  1752. 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>'
  1753. body.insertBefore(newModalElement, body.firstChild);
  1754.  
  1755. if (GM_getValue("leagueFlag") === undefined) {
  1756. GM_setValue("leagueFlag", true)
  1757. }
  1758.  
  1759. if (GM_getValue("matchFlag") === undefined) {
  1760. GM_setValue("matchFlag", true)
  1761. }
  1762.  
  1763. if (GM_getValue("federationFlag") === undefined) {
  1764. GM_setValue("federationFlag", true)
  1765. }
  1766.  
  1767. if (GM_getValue("playersFlag") === undefined) {
  1768. GM_setValue("playersFlag", true)
  1769. }
  1770.  
  1771. if (GM_getValue("countryRankFlag") === undefined) {
  1772. GM_setValue("countryRankFlag", true)
  1773. }
  1774.  
  1775.  
  1776. if (GM_getValue("league_graph_button") === undefined) {
  1777. GM_setValue("league_graph_button", "checked")
  1778. }
  1779.  
  1780. if (GM_getValue("league_report_button") === undefined) {
  1781. GM_setValue("league_report_button", "checked")
  1782. }
  1783.  
  1784. if (GM_getValue("league_calendar_button") === undefined) {
  1785. GM_setValue("league_calendar_button", "checked")
  1786. }
  1787.  
  1788. if (GM_getValue("windowsConfig") === undefined) {
  1789. GM_setValue("windowsConfig", true)
  1790. }
  1791.  
  1792. if (GM_getValue("tabsConfig") === undefined) {
  1793. GM_setValue("tabsConfig", false)
  1794. }
  1795.  
  1796. if (GM_getValue("show_league_selects") === undefined) {
  1797. GM_setValue("show_league_selects", true)
  1798. }
  1799.  
  1800. if (GM_getValue("league_image_size") === undefined) {
  1801. GM_setValue("league_image_size", 20)
  1802. }
  1803.  
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810. var leagueFlag = "", matchFlag = "", federationFlag = "", playersFlag = "", countryRankFlag = ""
  1811.  
  1812. if (GM_getValue("federationFlag")) federationFlag = "checked"
  1813. if (GM_getValue("matchFlag")) matchFlag = "checked"
  1814. if (GM_getValue("leagueFlag")) leagueFlag = "checked"
  1815. if (GM_getValue("playersFlag")) playersFlag = "checked"
  1816. if (GM_getValue("countryRankFlag")) countryRankFlag = "checked"
  1817. 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"></br><table border=0><tbody><tr>';
  1818. newContent += '<td><label class="containerPeqAmarillo">League<input type="checkbox" id="leagueSelect" ' + leagueFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  1819. newContent += '<td><label class="containerPeqAmarillo">Federation<input type="checkbox" id="federationSelect" ' + federationFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  1820. newContent += '<td><label class="containerPeqAmarillo">Match<input type="checkbox" id="matchSelect" ' + matchFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  1821. newContent += '<td><label class="containerPeqAmarillo">Players<input type="checkbox" id="playersSelect" ' + playersFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  1822. newContent += '<td><label class="containerPeqAmarillo">Country Rank<input type="checkbox" id="countryRankSelect" ' + countryRankFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  1823. newContent += "</tr></tbody></table>"
  1824.  
  1825. newContent += "<hr>"
  1826. newContent += "<h3 style='text-align: left; padding-left:7px;'>Leagues Config</h3>"
  1827.  
  1828. newContent += "<table border='0'><tr>"
  1829. newContent += "<td>Default Senior Param: <td>" + generateValuesSelect('senior') + "</td>";
  1830. newContent += "<td>Default U23 Param: <td>" + generateValuesSelect('u23') + "</td>";
  1831. newContent += "<td>Default U21 Param: <td>" + generateValuesSelect('u21') + "</td>";
  1832. newContent += "<td>Default U18 Param: <td>" + generateValuesSelect('u18') + "</td>";
  1833.  
  1834. newContent += "</tr><tr>"
  1835.  
  1836.  
  1837. var checked_graph = GM_getValue("league_graph_button")
  1838. var checked_report = GM_getValue("league_report_button")
  1839. var checked_calendar = GM_getValue("league_calendar_button")
  1840.  
  1841. 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>"
  1842. 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>"
  1843.  
  1844. 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>"
  1845.  
  1846. newContent += '</tr><tr>';
  1847.  
  1848. 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">'
  1849. newContent += '<img class="textMiddle" id="testImage" src="https://statsxente.com/MZ1/View/Images/calendar.png" width="20px" height="20px"/>'
  1850. newContent += '<span class="textMiddle" style="padding-left:10px;" id="sizeImageLeagueSpan"> (' + GM_getValue("league_image_size") + ')</span></label></center></td>'
  1851.  
  1852.  
  1853.  
  1854. var checkedLeagueSelects = ""
  1855. if (GM_getValue("show_league_selects")) {
  1856. checkedLeagueSelects = "checked"
  1857. }
  1858.  
  1859. 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>'
  1860. newContent += "</tr></table>"
  1861. newContent += "<hr>"
  1862. newContent += "<h3 style='text-align: left; padding-left:7px;'>Tabs Config</h3>"
  1863. newContent += "<table style='display:flex;'><tr><td>"
  1864.  
  1865. var checkedTab = ""
  1866. if (GM_getValue("tabsConfig")) {
  1867. checkedTab = "checked"
  1868. }
  1869.  
  1870. var checkedWin = ""
  1871. if (GM_getValue("windowsConfig")) {
  1872. checkedWin = "checked"
  1873. }
  1874.  
  1875.  
  1876. newContent += "<label><input type='checkbox' id='windowsConfig' " + checkedWin + ">Windows</label>";
  1877. newContent += "<label><input type='checkbox' id='tabsConfig' " + checkedTab + ">Tabs</label>";
  1878. newContent += "</td></tr></table></br></br>"
  1879.  
  1880.  
  1881.  
  1882.  
  1883. 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>'
  1884. newContent += '</div></center></br></br>';
  1885. document.getElementById("contenido_modal_cargando").innerHTML = newContent
  1886. createLeagueConfigOptionsListeners();
  1887. document.getElementById("contenido_modal_cargando").style.width = "75%";
  1888. document.getElementById("myModal_cargando").style.display = "none"
  1889. getNativeTableStyles()
  1890.  
  1891. document.getElementById("alert_tittle").style.backgroundColor = GM_getValue("bg_native")
  1892.  
  1893. document.getElementById("legendDiv").addEventListener('click', function () {
  1894.  
  1895. if (document.getElementById("myModal_cargando").style.display == "none") {
  1896. document.getElementById("myModal_cargando").style.display = "flex";
  1897. } else {
  1898. document.getElementById("myModal_cargando").style.display = "none";
  1899. }
  1900.  
  1901. });
  1902.  
  1903.  
  1904. document.getElementById("closeButton").addEventListener('click', function () {
  1905. document.getElementById("myModal_cargando").style.display = "none";
  1906. });
  1907.  
  1908.  
  1909. document.getElementById("saveButton").addEventListener('click', function () {
  1910. window.location.reload();
  1911. });
  1912.  
  1913.  
  1914.  
  1915.  
  1916. (function () {
  1917. document.getElementById("deleteButton").addEventListener('click', function () {
  1918. var keys = GM_listValues();
  1919. keys.forEach(function (key) {
  1920. GM_deleteValue(key);
  1921. });
  1922. window.location.reload();
  1923. });
  1924. })();
  1925.  
  1926.  
  1927.  
  1928.  
  1929.  
  1930. // }, 3000);
  1931.  
  1932. }
  1933. function getNativeTableStyles() {
  1934. var elemento = document.querySelector('.subheader.clearfix');
  1935. if (elemento) {
  1936. var estilo = getComputedStyle(elemento);
  1937. var bg = estilo.backgroundColor
  1938. var color = "white"
  1939. if (estilo.backgroundColor == "rgba(0, 0, 0, 0)") {
  1940. bg = "#a9b0b4"
  1941. }
  1942. GM_setValue("bg_native", bg)
  1943. GM_setValue("color_native", color)
  1944. }
  1945.  
  1946.  
  1947. }
  1948. function createModalEventListeners() {
  1949. setTimeout(function () {
  1950.  
  1951.  
  1952. document.getElementById('leagueSelect').addEventListener('click', function () {
  1953. GM_setValue("leagueFlag", !GM_getValue("leagueFlag"))
  1954. });
  1955.  
  1956.  
  1957. document.getElementById('federationSelect').addEventListener('click', function () {
  1958. GM_setValue("federationFlag", !GM_getValue("federationFlag"))
  1959. });
  1960.  
  1961. document.getElementById('matchSelect').addEventListener('click', function () {
  1962. GM_setValue("matchFlag", !GM_getValue("matchFlag"))
  1963. });
  1964.  
  1965. document.getElementById('playersSelect').addEventListener('click', function () {
  1966. GM_setValue("playersFlag", !GM_getValue("playersFlag"))
  1967. });
  1968.  
  1969. document.getElementById('countryRankSelect').addEventListener('click', function () {
  1970. GM_setValue("countryRankFlag", !GM_getValue("countryRankFlag"))
  1971. });
  1972.  
  1973.  
  1974.  
  1975.  
  1976. document.getElementById('show_league_checkbox').addEventListener('click', function () {
  1977. GM_setValue("show_league_selects", !GM_getValue("show_league_selects"))
  1978. });
  1979.  
  1980.  
  1981.  
  1982. document.getElementById('windowsConfig').addEventListener('click', function () {
  1983.  
  1984. if (document.getElementById('windowsConfig').checked) {
  1985. document.getElementById('tabsConfig').checked = false;
  1986. } else {
  1987. document.getElementById('tabsConfig').checked = true;
  1988. }
  1989.  
  1990. GM_setValue("windowsConfig", !GM_getValue("windowsConfig"))
  1991. GM_setValue("tabsConfig", !GM_getValue("tabsConfig"))
  1992.  
  1993.  
  1994. });
  1995.  
  1996.  
  1997. document.getElementById('tabsConfig').addEventListener('click', function () {
  1998. if (document.getElementById('tabsConfig').checked) {
  1999. document.getElementById('windowsConfig').checked = false;
  2000. } else {
  2001. document.getElementById('windowsConfig').checked = true;
  2002. }
  2003. GM_setValue("windowsConfig", !GM_getValue("windowsConfig"))
  2004. GM_setValue("tabsConfig", !GM_getValue("tabsConfig"))
  2005.  
  2006.  
  2007. });
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013. (function () {
  2014. document.getElementById("slider_input").addEventListener('input', function () {
  2015. document.getElementById("testImage").style.width = document.getElementById("slider_input").value + "px";
  2016. document.getElementById("testImage").style.height = document.getElementById("slider_input").value + "px";
  2017.  
  2018. document.getElementById("sizeImageLeagueSpan").innerText = "(" + document.getElementById("slider_input").value + ")"
  2019.  
  2020.  
  2021. GM_setValue("league_image_size", document.getElementById("slider_input").value)
  2022.  
  2023.  
  2024. });
  2025. })();
  2026.  
  2027.  
  2028.  
  2029.  
  2030. }, 5000);
  2031.  
  2032. }
  2033.  
  2034. function setLangSportCats() {
  2035.  
  2036. var langs = new Map();
  2037. langs.set('es', 'SPANISH');
  2038. langs.set('ar', 'SPANISH')
  2039. langs.set('en', 'ENGLISH');
  2040. langs.set('br', 'PORTUGUES');
  2041. langs.set('pt', 'PORTUGUES');
  2042. langs.set('pl', 'POLISH');
  2043. langs.set('ro', 'ROMANIAN');
  2044. langs.set('tr', 'TURKISH');
  2045.  
  2046. var lanCookie = getCookie("MZLANG");
  2047. if (langs.has(lanCookie)) {
  2048. window.lang = langs.get(lanCookie);
  2049. } else {
  2050. window.lang = "ENGLISH";
  2051. }
  2052.  
  2053. var sportCookie = getCookie("MZSPORT");
  2054. var lsport = "F"
  2055. var sport_id = 1;
  2056. if (sportCookie == "hockey") {
  2057. lsport = "H";
  2058. sport_id = 2;
  2059. }
  2060.  
  2061. var cats = {};
  2062. cats["senior"] = "senior";
  2063. cats["world"] = "seniorw";
  2064. cats["u23"] = "SUB23";
  2065. cats["u21"] = "SUB21";
  2066. cats["u18"] = "SUB18";
  2067. cats["u23_world"] = "SUB23w";
  2068. cats["u21_world"] = "SUB21w";
  2069. cats["u18_world"] = "SUB18w";
  2070.  
  2071.  
  2072. window.cats = cats;
  2073. window.sport = sportCookie;
  2074. window.lsport = lsport;
  2075. window.sport_id = sport_id;
  2076. window.userLocal = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.language;
  2077.  
  2078. }
  2079.  
  2080. function getUsernameData() {
  2081. if ((GM_getValue("currency") === undefined) || (GM_getValue("currency") == "")) {
  2082. var username = document.getElementById("header-username").innerText
  2083. GM_xmlhttpRequest({
  2084. method: "GET",
  2085. url: "http://www.managerzone.com/xml/manager_data.php?sport_id=" + window.sport_id + "&username=" + username,
  2086. headers: {
  2087. "Content-Type": "application/json"
  2088. },
  2089. onload: function (response) {
  2090.  
  2091. var parser = new DOMParser();
  2092. var xmlDoc = parser.parseFromString(response.responseText, "text/xml");
  2093. var userTeamsData = xmlDoc.getElementsByTagName("Team");
  2094. var index = 1;
  2095. if (userTeamsData[0].getAttribute("sport") == window.sport) {
  2096. index = 0;
  2097. }
  2098. GM_xmlhttpRequest({
  2099. method: "GET",
  2100. url: "http://www.managerzone.com/xml/team_playerlist.php?sport_id=" + window.sport_id + "&team_id=" + userTeamsData[index].getAttribute("teamId"),
  2101. headers: {
  2102. "Content-Type": "application/json"
  2103. },
  2104. onload: function (response) {
  2105.  
  2106. var parser = new DOMParser();
  2107. var xmlDoc = parser.parseFromString(response.responseText, "text/xml");
  2108. var team_data = xmlDoc.getElementsByTagName("TeamPlayers");
  2109. GM_setValue("currency", team_data[0].getAttribute("teamCurrency"))
  2110. }
  2111. });
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117. }
  2118. });
  2119.  
  2120. }
  2121.  
  2122.  
  2123. }
  2124.  
  2125. function clashLeagues() {
  2126.  
  2127. var urlParams = new URLSearchParams(window.location.search);
  2128.  
  2129. document.getElementById("division-select").addEventListener('change', function () {
  2130. clashLeagues()
  2131. });
  2132.  
  2133.  
  2134. document.getElementById("season-select").addEventListener('change', function () {
  2135. clashLeagues()
  2136. });
  2137.  
  2138.  
  2139.  
  2140.  
  2141. var elems = document.getElementsByClassName("nice_table");
  2142. var tabla = elems[0]
  2143. var thSegundo = tabla.querySelector("thead th:nth-child(2)");
  2144. thSegundo.style.width = "250px";
  2145. var values = new Map();
  2146. values.set('valueLM', 'LM Value');
  2147. values.set('elo', 'ELO Score');
  2148. values.set('teams_count', 'Number of teams');
  2149.  
  2150. var contenidoNuevo = '<div id=testClick><center>'
  2151. getNativeTableStyles();
  2152. var idProgress = "noProgress";
  2153. if (urlParams.get('type') == "senior") {
  2154. idProgress = "divProgress"
  2155. }
  2156.  
  2157. ///MENU TABLE
  2158. contenidoNuevo += "<center><table id=showMenu border=1><thead style='background-color:" + GM_getValue("bg_native") + "; color:" + GM_getValue("color_native") + ";'><tr>";
  2159. contenidoNuevo += '<th align=center style="padding:4px;" colspan="3">Values</th></tr></thead>';
  2160. contenidoNuevo += "<tr>";
  2161. contenidoNuevo += "</tr></table></center>";
  2162. contenidoNuevo += '<table id=show3 border="0"><tr><td><label>';
  2163. contenidoNuevo += '<input class="statsxente" type="checkbox" checked id="value" value="Value">Value</label></td>';
  2164.  
  2165.  
  2166. values.forEach(function (valor, clave) {
  2167. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  2168. });
  2169. contenidoNuevo += "</tr></table></center>"
  2170. contenidoNuevo += "</div></br>";
  2171.  
  2172. values.set('value', 'Value');
  2173. elems = document.getElementsByClassName("nice_table");
  2174. tabla = elems[0]
  2175. tabla.insertAdjacentHTML('beforebegin', contenidoNuevo);
  2176.  
  2177.  
  2178.  
  2179. values.forEach(function (valor, clave) {
  2180.  
  2181. var elemento = document.getElementById(clave);
  2182. elemento.addEventListener('click', handleClickClash);
  2183.  
  2184. });
  2185. var nuevaCeldaEncabezado = document.createElement("th");
  2186. nuevaCeldaEncabezado.textContent = "Value";
  2187. nuevaCeldaEncabezado.style.textAlign = 'center';
  2188. var ser = document.getElementsByClassName("seriesHeader")
  2189. document.getElementsByClassName("nice_table")[0].querySelector('thead').querySelector('tr').appendChild(nuevaCeldaEncabezado);
  2190.  
  2191. nuevaCeldaEncabezado = document.createElement("th");
  2192. nuevaCeldaEncabezado.textContent = "Stats Xente";
  2193. nuevaCeldaEncabezado.style.textAlign = 'center';
  2194. document.getElementsByClassName("nice_table")[0].querySelector('thead').querySelector('tr').appendChild(nuevaCeldaEncabezado);
  2195.  
  2196.  
  2197. var contIds = 0
  2198. var linkIds = ""
  2199. var filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  2200. for (var i = 0; i < filasDatos.length; i++) {
  2201. var celda = tabla.rows[i + 1].cells[1];
  2202. var imagen = celda.querySelector('img');
  2203. var url = new URL(imagen.src);
  2204. var id = url.searchParams.get('fid');
  2205. linkIds += "&id" + contIds + "=" + id
  2206. contIds++
  2207. }
  2208.  
  2209.  
  2210. GM_xmlhttpRequest({
  2211. method: "GET",
  2212. url: "https://statsxente.com/MZ1/Functions/tamper_federations.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + linkIds,
  2213. headers: {
  2214. "Content-Type": "application/json"
  2215. },
  2216. onload: function (response) {
  2217. var jsonResponse = JSON.parse(response.responseText);
  2218. teams_data = jsonResponse;
  2219. var filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  2220. for (var i = 0; i < filasDatos.length; i++) {
  2221. var celda = tabla.rows[i + 1].cells[1];
  2222. var imagen = celda.querySelector('img');
  2223. var url = new URL(imagen.src);
  2224. var id = url.searchParams.get('fid');
  2225. var nuevaColumna = document.createElement("td");
  2226. var valor = 0
  2227.  
  2228. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[id]["value"]))
  2229. nuevaColumna.innerHTML = valor
  2230. nuevaColumna.style.textAlign = 'center';
  2231. filasDatos[i].appendChild(nuevaColumna);
  2232.  
  2233.  
  2234. nuevaColumna = document.createElement("td");
  2235. var iner = "<center><img src='https://statsxente.com/MZ1/View/Images/detail.png' width='20px' height='20px' id='but" + id + "' style='cursor:pointer;'/>";
  2236. iner += "</center>";
  2237. var cat = cats[urlParams.get('type')]
  2238. nuevaColumna.innerHTML = iner
  2239. filasDatos[i].appendChild(nuevaColumna);
  2240.  
  2241.  
  2242. (function (currentId, currentSport, lang) {
  2243. document.getElementById("but" + currentId).addEventListener('click', function () {
  2244.  
  2245. var link = "https://statsxente.com/MZ1/Functions/loadClashFederationDetail.php?tamper=yes&idioma=" +
  2246. lang + "&modal_to_close=myModal&divisa=" + GM_getValue("currency") + "&fid=" + currentId + "&sport=" + currentSport + "&modal=yes";
  2247. openWindow(link, 0.95, 1.25);
  2248. });
  2249. })(id, window.sport, window.lang);
  2250.  
  2251. }
  2252. }
  2253. });
  2254.  
  2255. var thead = document.getElementsByClassName("nice_table")[0].querySelector('thead')
  2256. var ths = thead.querySelectorAll("th");
  2257. ths.forEach(function (th, index) {
  2258. th.addEventListener("click", function () {
  2259. ordenarTabla(index, true, "nice_table");
  2260. });
  2261. });
  2262. }
  2263.  
  2264. function handleClickClash(event) {
  2265. var elems = document.getElementsByClassName("nice_table");
  2266. var tabla = elems[0]
  2267. var filas = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  2268. var thSegundo = tabla.querySelector("thead th:nth-child(2)");
  2269. thSegundo.style.width = "250px";
  2270. for (var i = 0; i < filas.length; i++) {
  2271. var celda = tabla.rows[i + 1].cells[1];
  2272. var imagen = celda.querySelector('img');
  2273. var url = new URL(imagen.src);
  2274. var id = url.searchParams.get('fid');
  2275.  
  2276.  
  2277. var celdas = filas[i].getElementsByTagName("td");
  2278. var ultimaCelda = celdas[celdas.length - 2];
  2279.  
  2280. var valor = 0;
  2281.  
  2282. if (teams_data[id] === undefined) {
  2283. valor = 0
  2284. } else {
  2285. if (event.target.id == "edad") {
  2286. valor = new Intl.NumberFormat(window.userLocal, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(teams_data[id][event.target.id])
  2287. } else {
  2288. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(teams_data[id][event.target.id]))
  2289. }
  2290.  
  2291. }
  2292.  
  2293. ultimaCelda.innerHTML = valor;
  2294. }
  2295. var checkboxes = document.querySelectorAll('.statsxente');
  2296. var thead = tabla.querySelector('thead');
  2297. var tr = thead.querySelectorAll('tr');
  2298. var td = tr[0].querySelectorAll('th');
  2299. td[td.length - 2].textContent = event.target.value;
  2300. checkboxes.forEach(function (checkbox) {
  2301. if (checkbox.id !== event.target.id) {
  2302. checkbox.checked = false;
  2303. }
  2304. });
  2305. var columna = 12
  2306. }
  2307.  
  2308. var players = []
  2309. var lines = []
  2310. var gk_line = ""
  2311. var skills_names = []
  2312. var su_line = "unsetted";
  2313.  
  2314. async function playersPageStats() {
  2315. var element = document.getElementById('thePlayers_0');
  2316. var elementos_ = element.getElementsByClassName('p_sublinks');
  2317. var subheaders = element.getElementsByClassName('subheader clearfix');
  2318. var enlace = subheaders[0].querySelector('.subheader a');
  2319. var urlObj = new URL("https://www.managerzone.com/" + enlace.getAttribute('href'));
  2320. var params = new URLSearchParams(urlObj.search);
  2321. var tid = params.get('tid');
  2322. var playerName = enlace.querySelector('.player_name').textContent
  2323. var ids = element.getElementsByClassName('player_id_span');
  2324. var txt = '<span id=but' + ids[0].textContent + ' class="player_icon_placeholder"><a href="#" onclick="return false"'
  2325. txt += 'title="Stats Xente" class="player_icon"><span class="player_icon_wrapper">'
  2326. 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;'
  2327. txt += 'z-index: 0;"></span><span class="player_icon_text"></span></span></a></span>'
  2328. elementos_[0].innerHTML += txt;
  2329. (function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
  2330. document.getElementById("but" + currentId).addEventListener('click', function () {
  2331. var link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
  2332. + "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
  2333. "&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
  2334. openWindow(link, 0.95, 1.25);
  2335. });
  2336. })(ids[0].textContent, tid, window.sport, window.lang, "[undefined]", playerName);
  2337. }
  2338.  
  2339. async function playersPage() {
  2340. setTimeout(function () {
  2341. var elementos = document.getElementsByClassName('playerContainer');
  2342.  
  2343. var player_values = {}
  2344. var tactics_list = []
  2345.  
  2346. var urlParams = new URLSearchParams(window.location.search);
  2347. var flagStats = true
  2348. if (urlParams.has('tid')) {
  2349. flagStats = false
  2350. }
  2351.  
  2352. if (flagStats) {
  2353. var habil_container = elementos[0].getElementsByClassName("player_skills")
  2354. var habil = habil_container[0].getElementsByClassName("clippable")
  2355.  
  2356. if (window.sport == "hockey") {
  2357. for (var q = 1; q < habil.length; q++) {
  2358. skills_names.push(habil[q].textContent)
  2359. }
  2360. } else {
  2361.  
  2362. for (q = 0; q < habil.length - 1; q++) {
  2363. skills_names.push(habil[q].textContent)
  2364. }
  2365.  
  2366. var player_images = document.getElementsByClassName("player-image soccer")
  2367.  
  2368. }
  2369. }
  2370.  
  2371. var ids_ = []
  2372.  
  2373. for (var i = 0; i < elementos.length; i++) {
  2374. var ids = elementos[i].getElementsByClassName('player_id_span');
  2375.  
  2376. var elementos_ = elementos[i].getElementsByClassName('p_sublinks');
  2377.  
  2378. var subheaders = elementos[i].getElementsByClassName('subheader clearfix');
  2379.  
  2380.  
  2381. var enlace = subheaders[0].querySelector('.subheader a');
  2382. var urlObj = new URL("https://www.managerzone.com/" + enlace.getAttribute('href'));
  2383. var params = new URLSearchParams(urlObj.search);
  2384. var tid = params.get('tid');
  2385. var playerName = enlace.querySelector('.player_name').textContent
  2386.  
  2387. ids_.push({ "id": ids[0].textContent, "name": playerName });
  2388.  
  2389.  
  2390. var txt = '<span id=but' + ids[0].textContent + ' class="player_icon_placeholder"><a href="#" onclick="return false"'
  2391. txt += 'title="Stats Xente" class="player_icon"><span class="player_icon_wrapper">'
  2392. 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;'
  2393. txt += 'z-index: 0;"></span><span class="player_icon_text"></span></span></a></span>'
  2394.  
  2395. elementos_[0].innerHTML += txt;
  2396.  
  2397. if (flagStats) {
  2398. var flag_gk = false;
  2399. var age_div = elementos[i].getElementsByClassName('dg_playerview_info');
  2400. var age_table = age_div[0].getElementsByTagName('table')[0];
  2401.  
  2402. var ini_age = age_table.getElementsByTagName('td')[0].textContent.indexOf(":")
  2403. var age = age_table.getElementsByTagName('td')[0].textContent.substring(ini_age + 2, ini_age + 4);
  2404.  
  2405.  
  2406. if ((window.sport == "soccer") && (player_images[i].innerHTML.includes("gk=1"))) {
  2407. flag_gk = true
  2408. }
  2409.  
  2410. var tactics = elementos[i].getElementsByClassName('player_tactic gradientSunriseIcon');
  2411.  
  2412. player_values = {
  2413. "id": ids[0].textContent,
  2414. "skills": [],
  2415. "lines": [],
  2416. "tactics-position": {},
  2417. "tactics": [],
  2418. "age": parseInt(age)
  2419. }
  2420.  
  2421. for (var j = 0; j < tactics.length; j++) {
  2422. var fin = 0;
  2423. var line = ""
  2424. var ini = tactics[j].textContent.indexOf('(');
  2425. var tactic = tactics[j].textContent.substring(0, ini - 1);
  2426.  
  2427. if (window.sport == "hockey") {
  2428.  
  2429. if (!tactics[j].textContent.includes(":")) {
  2430. ini = tactics[j].textContent.indexOf('(');
  2431. fin = tactics[j].textContent.indexOf(')');
  2432. line = tactics[j].textContent.substring(ini + 2, fin - 1);
  2433. gk_line = line;
  2434. } else {
  2435. ini = tactics[j].textContent.indexOf('(');
  2436. fin = tactics[j].textContent.indexOf(':');
  2437. line = tactics[j].textContent.substring(ini + 2, fin);
  2438. }
  2439.  
  2440. } else {
  2441. ini = tactics[j].textContent.indexOf('(');
  2442. fin = tactics[j].textContent.indexOf(')');
  2443. line = tactics[j].textContent.substring(ini + 2, fin - 1);
  2444. if (flag_gk) {
  2445. gk_line = line;
  2446. }
  2447. if (tactics[j].textContent.includes(",")) {
  2448. ini = tactics[j].textContent.indexOf('(');
  2449. fin = tactics[j].textContent.indexOf(',');
  2450. su_line = tactics[j].textContent.substring(ini + 2, fin);
  2451. }
  2452. }
  2453.  
  2454. if (!player_values['lines'].includes(line)) {
  2455. player_values['lines'].push(line);
  2456. }
  2457. if (!player_values['tactics'].includes(tactic)) {
  2458. player_values['tactics'].push(tactic);
  2459. }
  2460.  
  2461. player_values['tactics-position'][tactic] = line
  2462.  
  2463. if ((!lines.includes(line))) {
  2464. lines.push(line);
  2465. }
  2466.  
  2467. if (!tactics_list.includes(tactic)) {
  2468. tactics_list.push(tactic);
  2469. }
  2470.  
  2471.  
  2472. }
  2473. var skills = elementos[i].getElementsByClassName('skillval');
  2474. if (window.sport == "hockey") {
  2475.  
  2476. for (j = 1; j < skills.length; j++) {
  2477. var cleanedText = skills[j].textContent.replace(')', '');
  2478. cleanedText = cleanedText.replace('(', '');
  2479. let number = parseInt(cleanedText, 10);
  2480. player_values['skills'].push(number);
  2481. }
  2482.  
  2483. } else {
  2484. for (j = 0; j < skills.length - 1; j++) {
  2485. cleanedText = skills[j].textContent.replace(')', '');
  2486. cleanedText = cleanedText.replace('(', '');
  2487. let number = parseInt(cleanedText, 10);
  2488. player_values['skills'].push(number);
  2489. }
  2490. }
  2491. players.push(player_values)
  2492. }
  2493. }
  2494.  
  2495. if (flagStats) {
  2496. const container = document.getElementById("squad_tabs")
  2497. var contenidoNuevo = "<div id='containerTactics' style='background-color: #e3e3e3;'></br><center>"
  2498. contenidoNuevo += "<div id=selectDiv>Choose Tactic: <select id=tactics_select>"
  2499. contenidoNuevo += "<option value='All Team'>All Team</option>"
  2500. for (var x = 0; x < tactics_list.length; x++) {
  2501. var selected = ""
  2502. if (x == 0) {
  2503. selected = "selected=''";
  2504. }
  2505. contenidoNuevo += "<option " + selected + " value='" + tactics_list[x] + "'>" + tactics_list[x] + "</option>"
  2506. }
  2507. contenidoNuevo += "</select></div></br><div id=divMenu></div></center></div>"
  2508. container.innerHTML = contenidoNuevo + container.innerHTML;
  2509. skillDistrib(tactics_list[0]);
  2510. document.getElementById("tactics_select").addEventListener('change', function () {
  2511. var select = document.getElementById('tactics_select');
  2512. var valorSeleccionado = select.value;
  2513. document.getElementById("divMenu").innerHTML = ""
  2514. skillDistrib(valorSeleccionado)
  2515. });
  2516. }
  2517.  
  2518.  
  2519.  
  2520.  
  2521. for (i = 0; i < ids_.length; i++) {
  2522. (function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
  2523. document.getElementById("but" + currentId).addEventListener('click', function () {
  2524. var link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
  2525. + "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
  2526. "&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
  2527. openWindow(link, 0.95, 1.25);
  2528. });
  2529. })(ids_[i]['id'], tid, window.sport, window.lang, "[undefined]", ids_[i]['name'],);
  2530. }
  2531.  
  2532.  
  2533.  
  2534. }, 1000);
  2535. }
  2536.  
  2537. function skillDistrib(tactic) {
  2538. var t = tactic
  2539. if (window.sport == "hockey") {
  2540. var l = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  2541. } else {
  2542. l = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  2543. }
  2544.  
  2545. var li_t = {}
  2546. for (var i = 0; i < lines.length; i++) {
  2547. li_t[lines[i]] = [...l];
  2548. }
  2549.  
  2550. var no_gk_line = "Tactic -(" + gk_line + ")"
  2551. li_t["Team"] = [...l];
  2552. li_t["U23"] = [...l];
  2553. li_t["U21"] = [...l];
  2554. li_t["U18"] = [...l];
  2555. li_t["Tactic"] = [...l];
  2556. li_t[no_gk_line] = [...l];
  2557.  
  2558.  
  2559.  
  2560. for (i = 0; i < players.length; i++) {
  2561. if (players[i]['tactics'].includes(t)) {
  2562. for (var j = 0; j < players[i]['skills'].length; j++) {
  2563. li_t[players[i]['tactics-position'][t]][j] += players[i]['skills'][j]
  2564. li_t['Tactic'][j] += players[i]['skills'][j]
  2565. if (players[i]['tactics-position'][t] != "Po") {
  2566. li_t[no_gk_line][j] += players[i]['skills'][j]
  2567. }
  2568. }
  2569. li_t[players[i]['tactics-position'][t]][j] += 1
  2570. li_t['Tactic'][j] += 1
  2571. if (players[i]['tactics-position'][t] != "Po") {
  2572. li_t[no_gk_line][j] += 1
  2573. }
  2574. } else {
  2575.  
  2576. for (j = 0; j < players[i]['skills'].length; j++) {
  2577. if (players[i]['age'] <= 23) {
  2578. li_t['U23'][j] += players[i]['skills'][j]
  2579. }
  2580. if (players[i]['age'] <= 23) {
  2581. li_t['U21'][j] += players[i]['skills'][j]
  2582. }
  2583. if (players[i]['age'] <= 23) {
  2584. li_t['U18'][j] += players[i]['skills'][j]
  2585. }
  2586. li_t['Team'][j] += players[i]['skills'][j]
  2587. }
  2588.  
  2589. if (players[i]['age'] <= 23) {
  2590. li_t['U23'][li_t["U23"].length - 1] += 1
  2591. }
  2592.  
  2593. if (players[i]['age'] <= 21) {
  2594. li_t['U21'][li_t["U21"].length - 1] += 1
  2595. }
  2596. if (players[i]['age'] <= 18) {
  2597. li_t['U18'][li_t["U18"].length - 1] += 1
  2598. }
  2599. li_t['Team'][li_t["Team"].length - 1] += 1
  2600. }
  2601. }
  2602.  
  2603.  
  2604.  
  2605. const container = document.getElementById("divMenu")
  2606. 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>";
  2607. contenidoNuevo += '<th align=center style="padding:4px;">Line</th>'
  2608. for (var q = 0; q < skills_names.length; q++) {
  2609. contenidoNuevo += '<th align=center style="padding:4px;">' + skills_names[q] + '</th>'
  2610. }
  2611. contenidoNuevo += '</tr></thead>';
  2612. var l_aux = lines
  2613. l_aux = l_aux.filter(item => item !== gk_line);
  2614. l_aux.sort((a, b) => {
  2615. let numA = parseInt(a.substring(1), 10);
  2616. let numB = parseInt(b.substring(1), 10);
  2617. return numA - numB;
  2618. });
  2619.  
  2620. l_aux.unshift(gk_line);
  2621. l_aux.push("Tactic");
  2622. l_aux.push(no_gk_line);
  2623.  
  2624. if (window.sport == "hockey") {
  2625. if (li_t["L4"][10] == 0) {
  2626. let index = l_aux.indexOf('L4');
  2627. if (index !== -1) {
  2628. l_aux.splice(index, 1);
  2629. }
  2630. }
  2631. }
  2632.  
  2633. if (t == "All Team") {
  2634. l_aux = ["Team", "U23", "U21", "U18"]
  2635. }
  2636.  
  2637. l_aux = l_aux.filter(item => !item.includes(su_line));
  2638.  
  2639. for (var w = 0; w < l_aux.length; w++) {
  2640. var key = l_aux[w]
  2641. if (li_t.hasOwnProperty(key)) {
  2642. contenidoNuevo += "<tr>";
  2643. contenidoNuevo += "<td align=center style='padding:2px;'><strong>" + key + "</strong></td>";
  2644. for (var x = 0; x < li_t[key].length - 1; x++) {
  2645. contenidoNuevo += "<td align=center style='padding:2px;'>" + Math.round(li_t[key][x] / li_t[key][li_t[key].length - 1] * 100) / 100 + "</td>";
  2646. }
  2647. contenidoNuevo += "</tr>";
  2648.  
  2649. }
  2650. }
  2651. container.innerHTML += contenidoNuevo;
  2652. }
  2653.  
  2654. function countryRank() {
  2655. var table_values = ["players", "age", "value", "top11", "salary", "elo", "elo21", "lm", "lmu21"]
  2656. var newContent = "<center><div>";
  2657. newContent += '<label><input class="statsxente" type="checkbox" checked id="value" value="Value">Value</label>';
  2658. if (window.sport == "soccer") {
  2659. newContent += '<label><input class="statsxente" type="checkbox" id="top11" value="TOP 11">TOP 11</label>';
  2660. } else {
  2661. newContent += '<label><input class="statsxente" type="checkbox" id="top11" value="TOP 21">TOP 21</label>';
  2662. }
  2663.  
  2664. newContent += '<label><input class="statsxente" type="checkbox" id="players" value="Players">Players</label>';
  2665. newContent += '<label><input class="statsxente" type="checkbox" id="salary" value="Salary">Salary</label>';
  2666. newContent += '<label><input class="statsxente" type="checkbox" id="age" value="Age">Age</label>';
  2667. newContent += '<label><input class="statsxente" type="checkbox" checked id="elo" value="Elo">ELO</label>';
  2668. newContent += '<label><input class="statsxente" type="checkbox" checked id="elo21" value="U21 ELO">U21 ELO</label>';
  2669. newContent += '<label><input class="statsxente" type="checkbox" checked id="lm" value="LM">LM</label>';
  2670. newContent += '<label><input class="statsxente" type="checkbox" checked id="lmu21" value="U21 LM">U21 LM</label>';
  2671.  
  2672. var contenedor = document.getElementById('countryRankTable');
  2673. contenedor.insertAdjacentHTML('beforebegin', newContent);
  2674.  
  2675. GM_xmlhttpRequest({
  2676. method: "GET",
  2677. url: "https://statsxente.com/MZ1/Functions/tamper_national_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport,
  2678. headers: {
  2679. "Content-Type": "application/json"
  2680. },
  2681. onload: function (response) {
  2682. var jsonResponse = JSON.parse(response.responseText);
  2683. var data = jsonResponse;
  2684.  
  2685. var type = 1;
  2686. if (window.sport == "soccer") {
  2687. type = 2
  2688. }
  2689. var table = document.getElementById('countryRankTable');
  2690. for (var i = 0; i < table.rows.length; i++) {
  2691. var row = table.rows[i];
  2692. var insertIndex = row.cells.length - 1;
  2693. var raw_str = row.cells[3].innerHTML
  2694. row.deleteCell(3);
  2695. var cell_name = row.cells[2]
  2696. if (i > 0) {
  2697. cell_name.innerHTML = raw_str + " " + cell_name.innerHTML
  2698. }
  2699. var index = 0;
  2700. var cell0 = row.insertCell(insertIndex + index);
  2701. index++;
  2702. var cell1 = row.insertCell(insertIndex + index);
  2703. index++;
  2704. var cell2 = row.insertCell(insertIndex + index);
  2705. index++;
  2706. var cell3 = row.insertCell(insertIndex + index);
  2707. index++;
  2708. var cell4 = row.insertCell(insertIndex + index);
  2709. index++;
  2710. var cell5 = row.insertCell(insertIndex + index);
  2711. index++;
  2712. var cell6 = row.insertCell(insertIndex + index);
  2713. index++;
  2714. var cell7 = row.insertCell(insertIndex + index);
  2715. index++;
  2716. var cell8 = row.insertCell(insertIndex + index);
  2717. index++;
  2718. var cell9 = row.insertCell(insertIndex + index);
  2719.  
  2720.  
  2721.  
  2722. if (i === 0) {
  2723. cell0.outerHTML = "<th id='players_th' style='display:none;' class='header'><a href='#'>Players</a></th>";
  2724. cell1.outerHTML = "<th id='age_th' class='header' style='display:none;'><a href='#'>Age</a></th>";
  2725. cell2.outerHTML = "<th id='value_th' class='header' style='display:table-cell;'><a href='#'>Value</a></th>";
  2726. cell3.outerHTML = "<th id='top11_th' class='header' style='display:none;'><a href='#'>Top11</a></th>";
  2727. cell4.outerHTML = "<th id='salary_th' class='header' style='display:none;'><a href='#'>Salary</a></th>";
  2728. cell5.outerHTML = "<th id='elo_th' class='header' style='display:table-cell;'><a href='#'>ELO</a></th>";
  2729. cell6.outerHTML = "<th id='elo21_th' class='header' style='display:table-cell;'><a href='#'>U21 ELO</a></th>";
  2730. cell7.outerHTML = "<th id='lm_th' class='header' style='display:table-cell;'><a href='#'>LM</a></th>";
  2731. cell8.outerHTML = "<th id='lmu21_th' class='header' style='display:table-cell;'><a href='#'>U21 LM</a></th>";
  2732. cell9.outerHTML = "<th id='image' class='header' style='display:table-cell;'><a href='#'></a></th>";
  2733. } else {
  2734. var ini = raw_str.indexOf("s_");
  2735. var fin = raw_str.indexOf(".", ini + 1);
  2736. var c_code = raw_str.substring(ini + 2, fin)
  2737. cell0.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["numJugadores"]))
  2738. cell0.className = "players"
  2739. cell0.style.display = "none"
  2740.  
  2741. cell1.innerHTML = new Intl.NumberFormat(window.userLocal, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(data[c_code]["edad"])
  2742. cell1.className = "age"
  2743. cell1.style.display = "none"
  2744.  
  2745. cell2.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valor"]))
  2746. cell2.className = "value"
  2747. cell2.style.display = "table-cell"
  2748.  
  2749. cell3.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valor11"]))
  2750. cell3.className = "top11"
  2751. cell3.style.display = "none"
  2752.  
  2753. cell4.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["salario"]))
  2754. cell4.className = "salary"
  2755. cell4.style.display = "none"
  2756.  
  2757. cell5.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["elo"]))
  2758. cell5.className = "elo"
  2759. cell5.style.display = "table-cell"
  2760.  
  2761. cell6.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["elo21"]))
  2762. cell6.className = "elo21"
  2763. cell6.style.display = "table-cell"
  2764.  
  2765. cell7.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valorLM"]))
  2766. cell7.className = "lm"
  2767. cell7.style.display = "table-cell"
  2768.  
  2769. cell8.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valorLM21"]))
  2770. cell8.className = "lmu21"
  2771. cell8.style.display = "table-cell"
  2772.  
  2773. cell9.innerHTML = '<img style="cursor:pointer;" src="https://statsxente.com/MZ1/View/Images/calendar.png" width="20" height="20">'
  2774. var actual_id = "image" + i
  2775. cell9.id = actual_id
  2776. cell9.style.display = "table-cell";
  2777.  
  2778.  
  2779. (function (id, code, type_) {
  2780. document.getElementById(id).addEventListener('click', function () {
  2781. var link = "https://www.statsxente.com/MZ1/Graficos/graficoRachaEquipoELONT.php?tamper=yes&team_id=" + data[code]["idSenior"] +
  2782. "&team_id_u21=" + data[code]["idSub21"] + "&idioma=" + window.lang + "&type=" + type_ + "&cat=SENIOR&sport=" + window.sport;
  2783. openWindow(link, 0.95, 1.25);
  2784. });
  2785. })(actual_id, c_code, type);
  2786.  
  2787.  
  2788.  
  2789.  
  2790.  
  2791.  
  2792.  
  2793.  
  2794. }
  2795.  
  2796.  
  2797. }
  2798.  
  2799. setTimeout(function () {
  2800. for (var f = 0; f < table_values.length; f++) {
  2801.  
  2802. (function (actual_value, f) {
  2803.  
  2804. document.getElementById(actual_value + "_th").addEventListener('click', function () {
  2805. if (document.getElementById(actual_value + "_th").className == "header") {
  2806. document.getElementById(actual_value + "_th").className = "header headerSortDown";
  2807. } else {
  2808.  
  2809. if (document.getElementById(actual_value + "_th").className == "header headerSortDown") {
  2810. document.getElementById(actual_value + "_th").className = "header headerSortUp";
  2811. } else {
  2812. document.getElementById(actual_value + "_th").className = "header headerSortDown";
  2813. }
  2814.  
  2815. }
  2816. var index_ = 3 + f
  2817. ordenarTabla(index_, false, "countryRankTable")
  2818. });
  2819. document.getElementById(actual_value).addEventListener('click', function () {
  2820. var display = "table-cell"
  2821. if (document.getElementById(actual_value + "_th").style.display == "table-cell") {
  2822. display = "none"
  2823. }
  2824. var elementos = document.getElementsByClassName(actual_value)
  2825. Array.prototype.forEach.call(elementos, function (elemento) {
  2826. var aux_display = "table-cell"
  2827. if (document.getElementById(actual_value + "_th").style.display == "table-cell") {
  2828. aux_display = "none"
  2829. }
  2830. elemento.style.display = aux_display;
  2831. });
  2832. document.getElementById(actual_value + "_th").style.display = display
  2833. });
  2834. })(table_values[f], f);
  2835. }
  2836. }, 1000);
  2837. }
  2838. });
  2839. }
  2840.  
  2841. function nextMatchesClubhouse() {
  2842. var h1Elements = document.querySelectorAll('h1.box_dark');
  2843. var team_name = h1Elements[0].innerText
  2844. var team_id = document.getElementById("tid1").value;
  2845.  
  2846. GM_xmlhttpRequest({
  2847. method: "GET",
  2848. url: "https://statsxente.com/MZ1/Functions/tamper_user_next_matches.php?team_id=" + team_id,
  2849. headers: {
  2850. "Content-Type": "application/json"
  2851. },
  2852. onload: function (response) {
  2853. var jsonResponse = JSON.parse(response.responseText);
  2854. var data = jsonResponse;
  2855. if (data.length > 0) {
  2856.  
  2857.  
  2858. GM_xmlhttpRequest({
  2859. method: "GET",
  2860. url: "http://www.managerzone.com/xml/team_matchlist.php?sport_id=" + window.sport_id + "&team_id=" + team_id + "&match_status=2&limit=100",
  2861. headers: {
  2862. "Content-Type": "application/json"
  2863. },
  2864. onload: function (response) {
  2865.  
  2866. var matchesDate = []
  2867. var parser = new DOMParser();
  2868. var xmlDoc = parser.parseFromString(response.responseText, "text/xml");
  2869. var matches = xmlDoc.getElementsByTagName("Match");
  2870.  
  2871. var last_date = ""
  2872.  
  2873.  
  2874. for (var i = 0; i < matches.length; i++) {
  2875. var dateOnly = matches[i].getAttribute("date").split(" ")[0];
  2876. last_date = dateOnly
  2877. var teams = matches[i].getElementsByTagName("Team");
  2878.  
  2879. for (var j = 0; j < teams.length; j++) {
  2880. if (teams[j].getAttribute("teamId") != team_id) {
  2881. matchesDate.push(teams[j].getAttribute("teamId") + "-" + dateOnly)
  2882.  
  2883. }
  2884. }
  2885.  
  2886.  
  2887. }
  2888.  
  2889.  
  2890.  
  2891.  
  2892. var newContent = `
  2893. <div id="tour-container" class="widgets-container">
  2894. <div class="flex-wrap hub-widget-container">
  2895. <div class="flex-grow-1 box_dark">
  2896. <div id="clubhouse-widget-tour" class="widget-content clearfix">
  2897. <i class="fa minimize-button fa-minus-square" aria-hidden="true" data-time="1722549599"></i>
  2898. <span class="fa fa-stack fa-2x floatRight">
  2899. <i class="fa fa-circle fa-stack-2x fa-inverse"></i>
  2900. <i class="fa fa-thumbs-up fa-stack-1x green" aria-hidden="true"></i>
  2901. </span>
  2902. <h3 style="background-image: url('https://www.statsxente.com/MZ1/View/Images/etiqueta_bota.png');">Stats Xente</h3>
  2903. <div class="widget-content-wrapper">
  2904. <div class="flex-wrap" style="margin-bottom: 35px;">
  2905. <div class="flex-grow-0" style="margin: 0 auto">
  2906. <img src="https://www.statsxente.com/MZ1/View/Images/etiqueta_bota.png" alt="" width="114" height="127">
  2907. </div>
  2908. <div class="flex-grow-1 textLeft">`
  2909.  
  2910. data.forEach(function (match_data) {
  2911.  
  2912. var dateObj1 = new Date(last_date);
  2913. var dateObj2 = new Date(match_data['fecha']);
  2914.  
  2915.  
  2916. var icon_ = "fa-check-square"
  2917. var style_ = ""
  2918. var flagFriendly = false;
  2919. if (dateObj1 < dateObj2) {
  2920. icon_ = "fa-calendar-minus-o"
  2921. style_ = "style='color:#e5ac00;'"
  2922. flagFriendly = true;
  2923. } else {
  2924.  
  2925. if (matchesDate.includes(match_data['rival_id'] + "-" + match_data['fecha'])) {
  2926. if (window.sport == "hockey") {
  2927. style_ = "style='color:#6d93fd;'"
  2928. }
  2929. } else {
  2930. icon_ = "fa-times-square"
  2931. style_ = "style='color:#AD4039;'"
  2932. flagFriendly = true;
  2933.  
  2934.  
  2935. }
  2936.  
  2937. }
  2938.  
  2939.  
  2940. var match = '<img src="https://www.managerzone.com/dynimg/badge.php?team_id=' + match_data['idEquipoLocal'] + '&sport="' + window.sport + ' width="15px" height="15px"/> '
  2941. + 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"/>'
  2942. if (match_data['field'] == "away") {
  2943. match = '<img src="https://www.managerzone.com/dynimg/badge.php?team_id=' + match_data['idEquipoLocal'] + '&sport="' + window.sport + ' width="15px" height="15px"/> '
  2944. + 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"/>'
  2945. }
  2946.  
  2947.  
  2948. newContent += '<fieldset class="grouping self box_light_on_dark flex-nowrap" style="max-width: 555px; margin-left: 10px;">'
  2949. newContent += '<legend>' + match_data['clash_name'] + '</legend>'
  2950. newContent += '<div class="flex-grow-0 mission-icon">'
  2951. newContent += '<i class="fa ' + icon_ + ' green fa-2x t-checked" aria-hidden="true" ' + style_ + '></i>'
  2952. newContent += '</div>'
  2953. newContent += '<div class="flex-grow-1 mission">'
  2954.  
  2955. var link = "CompAmis_CALENDAR_View.php?" + 'id=' + match_data['idComp']
  2956. if (match_data['comp'] == "cup") {
  2957. link = 'CompAmis_Cup_CALENDAR_View.php?grupo=' + match_data['grupo'] + '&id=' + match_data['idComp']
  2958. }
  2959.  
  2960.  
  2961. newContent += '<p><b><a href="https://www.statsxente.com/MZ1/View/' + link + '" target="_blank">' + match + '</a></b>'
  2962. newContent += "</br></p>"
  2963. newContent += 'Date: ' + match_data['fecha']
  2964. if (flagFriendly) {
  2965. 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>"
  2966. }
  2967.  
  2968.  
  2969. newContent += '</p>'
  2970. newContent += '</div>'
  2971. newContent += '</fieldset>'
  2972. });
  2973.  
  2974.  
  2975.  
  2976.  
  2977. newContent += `</div>
  2978. </div>
  2979. </div>
  2980. </div>
  2981. </div>
  2982. </div>
  2983. </div>`;
  2984.  
  2985.  
  2986.  
  2987.  
  2988. var contenedor = document.getElementById('tour-container');
  2989. if (data.length > 0) {
  2990. contenedor.insertAdjacentHTML('beforebegin', newContent);
  2991.  
  2992. }
  2993.  
  2994.  
  2995. }
  2996.  
  2997. });
  2998.  
  2999. }
  3000.  
  3001.  
  3002. }
  3003. });
  3004.  
  3005. }
  3006.  
  3007. function checkClassNameExists(element, className) {
  3008.  
  3009. if (className == "") {
  3010. return true;
  3011. } else {
  3012. return element.classList.contains(className);
  3013. }
  3014. return false;
  3015.  
  3016. }
  3017.  
  3018. function fetchAgeRestriction(url) {
  3019. return new Promise((resolve, reject) => {
  3020.  
  3021. GM_xmlhttpRequest({
  3022. method: "GET",
  3023. url: url,
  3024. headers: {
  3025. "Content-Type": "application/json"
  3026. },
  3027. onload: function (response) {
  3028. var parser = new DOMParser();
  3029. var doc = parser.parseFromString(response.responseText, "text/html");
  3030. var strongElements = doc.getElementsByTagName("b");
  3031. var nextElement = strongElements[1].nextElementSibling;
  3032. var nextSibling = strongElements[1].nextSibling;
  3033. try {
  3034. while (nextSibling && nextSibling.nodeName === "BR") {
  3035. nextSibling = nextSibling.nextSibling;
  3036. }
  3037.  
  3038. if (nextSibling && nextSibling.nodeType === Node.TEXT_NODE) {
  3039. var age_restriction = nextSibling.textContent.trim();
  3040. resolve(age_restriction);
  3041. } else {
  3042. resolve("none");
  3043. }
  3044. } catch (error) {
  3045. reject("none");
  3046. }
  3047. },
  3048. onerror: function (error) {
  3049. reject("none");
  3050. }
  3051. });
  3052. });
  3053. }
  3054.  
  3055. function fetchCupAgeRestriction(url) {
  3056. return new Promise((resolve, reject) => {
  3057.  
  3058. GM_xmlhttpRequest({
  3059. method: "GET",
  3060. url: url,
  3061. headers: {
  3062. "Content-Type": "application/json"
  3063. },
  3064. onload: function (response) {
  3065. var parser = new DOMParser();
  3066. try {
  3067. var doc = parser.parseFromString(response.responseText, "text/html")
  3068. var tables = doc.getElementsByTagName("table");
  3069. var table = tables[1]
  3070. var tds = table.getElementsByTagName("td");
  3071. resolve(tds[5].innerHTML)
  3072. } catch (error) {
  3073. reject("none");
  3074. }
  3075. },
  3076. onerror: function (error) {
  3077. reject("none");
  3078. }
  3079. });
  3080. });
  3081. }
  3082.  
  3083. async function friendlyCupsAndLeagues() {
  3084. var urlParams = new URLSearchParams(window.location.search);
  3085. var age_restriction = "none"
  3086. var link = "https://www.managerzone.com" + document.getElementById("ui-id-1").getAttribute('href')
  3087. if (urlParams.get('fsid')) {
  3088. age_restriction = await fetchAgeRestriction(link);
  3089. } else {
  3090. age_restriction = await fetchCupAgeRestriction(link);
  3091. }
  3092.  
  3093. var detected_cat = "senior"
  3094.  
  3095. if (age_restriction !== "none") {
  3096.  
  3097.  
  3098. switch (age_restriction) {
  3099. case "U23":
  3100. detected_cat = "u23"
  3101. break;
  3102. case "U21":
  3103. detected_cat = "u21"
  3104. break;
  3105. case "U18":
  3106. detected_cat = "u18"
  3107. break;
  3108. }
  3109.  
  3110. }
  3111.  
  3112.  
  3113.  
  3114. var initialValues = {};
  3115. initialValues["senior"] = GM_getValue("league_default_senior");
  3116. initialValues["world"] = GM_getValue("league_default_senior");
  3117. initialValues["u23"] = GM_getValue("league_default_u23");
  3118. initialValues["u21"] = GM_getValue("league_default_u21");
  3119. initialValues["u18"] = GM_getValue("league_default_u18");
  3120. initialValues["u23_world"] = GM_getValue("league_default_u23");
  3121. initialValues["u21_world"] = GM_getValue("league_default_u21");
  3122. initialValues["u18_world"] = GM_getValue("league_default_u18");;
  3123.  
  3124. var linkIds = ""
  3125. setTimeout(function () {
  3126.  
  3127. var elems = document.getElementsByClassName("nice_table");
  3128. var tabla = elems[0]
  3129. var thSegundo = tabla.querySelector("thead th:nth-child(2)");
  3130. thSegundo.style.width = "250px";
  3131.  
  3132.  
  3133. var values = new Map();
  3134. values.set('valor23', 'U23 Value');
  3135. values.set('valor21', 'U21 Value');
  3136. values.set('valor18', 'U18 Value');
  3137. values.set('salario', 'Salary');
  3138. values.set('valorUPSenior', 'LM Value');
  3139. values.set('valorUPSUB23', 'U23 LM Value');
  3140. values.set('valorUPSUB21', 'U21 LM Value');
  3141. values.set('valorUPSUB18', 'U18 LM Value');
  3142. values.set('edad', 'Age');
  3143. if (window.sport == "soccer") {
  3144. values.set('valor11', 'TOP 11');
  3145. values.set('valor11_23', 'U23 TOP 11');
  3146. values.set('valor11_21', 'U21 TOP 11');
  3147. values.set('valor11_18', 'U18 TOP 11');
  3148. } else {
  3149. values.set('valor11', 'TOP 21');
  3150. values.set('valor11_23', 'U23 TOP 21');
  3151. values.set('valor11_21', 'U21 TOP 21');
  3152. values.set('valor11_18', 'U18 TOP 21');
  3153. }
  3154.  
  3155. values.set('noNac', 'Foreigners');
  3156. values.set('elo', 'ELO Score');
  3157. values.set('elo23', 'U23 ELO Score');
  3158. values.set('elo21', 'U21 ELO Score');
  3159. values.set('elo18', 'U18 ELO Score');
  3160. values.set('numJugadores', 'Number of players');
  3161. values.set('leagues', 'Leagues');
  3162. values.set('world_leagues_all', 'World Leagues');
  3163. values.set('youth_leagues_all', 'Youth Leagues');
  3164. values.set('world_youth_leagues_all', 'Youth World Leagues');
  3165. values.set('federation_leagues', 'Federation Leagues');
  3166. values.set('cup', 'Cups');
  3167. values.set('cup_u23', 'U23 Cups');
  3168. values.set('cup_u21', 'U21 Cups');
  3169. values.set('cup_u18', 'U18 Cups');
  3170. values.set('special_cup', 'Special Cups');
  3171.  
  3172. var contenidoNuevo = '<div id=testClick><center>'
  3173.  
  3174.  
  3175. getNativeTableStyles();
  3176.  
  3177. var idProgress = "noProgress";
  3178. if (urlParams.get('type') == "senior") {
  3179. idProgress = "divProgress"
  3180. }
  3181.  
  3182.  
  3183. var widthTable = "1.5em"
  3184. ///MENU TABLE
  3185. contenidoNuevo += "<center><table id=showMenu border=0><thead style='background-color:" + GM_getValue("bg_native") + "; color:" + GM_getValue("color_native") + ";'><tr>";
  3186. contenidoNuevo += '<th align=center style="padding:4px;" colspan="4">Stats Xente</th>';
  3187. contenidoNuevo += "</tr></thead>";
  3188. var styleTable = " style='display:none;'";
  3189. var styleIcon = ""
  3190. var styleSep = "style='padding-top:5px;'";
  3191.  
  3192. if (GM_getValue("show_league_selects") == true) {
  3193. styleTable = "";
  3194. styleIcon = " active"
  3195. styleSep = " style='display:none;'";
  3196.  
  3197. }
  3198.  
  3199.  
  3200. contenidoNuevo += "<tr><td></td><td style='padding-top:5px' colspan='2'>";
  3201.  
  3202. 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>';
  3203.  
  3204. contenidoNuevo += "</td><td></td></tr>";
  3205.  
  3206. contenidoNuevo += "<tr><td colspan='5' id='separatorTd'" + styleSep + "></td></tr>";
  3207.  
  3208.  
  3209.  
  3210. contenidoNuevo += "</table></center>";
  3211.  
  3212.  
  3213.  
  3214. contenidoNuevo += '<table id=show3 border="0"' + styleTable + '><tr><td><label>';
  3215.  
  3216. if ((urlParams.get('type') == 'senior') || (urlParams.get('type') == 'world')) {
  3217. if ("valor" == initialValues[detected_cat]) {
  3218. contenidoNuevo += '<input class="statsxente" type="checkbox" checked id="valor" value="Value">Value</label></td>';
  3219. } else {
  3220. contenidoNuevo += '<input class="statsxente" type="checkbox" id="valor" value="Value">Value</label></td>';
  3221. }
  3222. } else {
  3223. contenidoNuevo += '<input class="statsxente" type="checkbox" id="valor" value="Value">Value</label></td>';
  3224. }
  3225.  
  3226. values.forEach(function (valor, clave) {
  3227.  
  3228. if (clave == "valorUPSenior") {
  3229. contenidoNuevo += "</tr><tr>";
  3230. }
  3231.  
  3232. if (clave == "valor11") {
  3233. contenidoNuevo += "</tr><tr>";
  3234. }
  3235. if (clave == "elo") {
  3236. contenidoNuevo += "</tr><tr>";
  3237. }
  3238.  
  3239. if (clave == "leagues") {
  3240. contenidoNuevo += "</tr><tr>";
  3241. }
  3242.  
  3243. if (clave == "leagues_all") {
  3244. contenidoNuevo += "</tr><tr>";
  3245. }
  3246.  
  3247. if (clave == "cup") {
  3248. contenidoNuevo += "</tr><tr>";
  3249. }
  3250.  
  3251. if (clave == initialValues[detected_cat]) {
  3252. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" checked value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  3253. } else {
  3254. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  3255. }
  3256. });
  3257. contenidoNuevo += "</tr></table></center>"
  3258. contenidoNuevo += "</div></br>";
  3259.  
  3260.  
  3261. values.set('valor', 'Value');
  3262.  
  3263. elems = document.getElementsByClassName("nice_table");
  3264. tabla = elems[0]
  3265.  
  3266.  
  3267. tabla.insertAdjacentHTML('beforebegin', contenidoNuevo);
  3268.  
  3269. if (GM_getValue("show_league_selects") == true) {
  3270.  
  3271. document.getElementById("line2").style.transform = 'rotateZ(0deg)';
  3272. document.getElementById("line1").style.transform = 'rotateZ(180deg)';
  3273. document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
  3274. }
  3275.  
  3276.  
  3277. values.forEach(function (valor, clave) {
  3278.  
  3279. var elemento = document.getElementById(clave);
  3280. elemento.addEventListener('click', handleClick);
  3281.  
  3282. });
  3283. var nuevaCeldaEncabezado = document.createElement("th");
  3284. nuevaCeldaEncabezado.textContent = values.get(initialValues[detected_cat]);
  3285. nuevaCeldaEncabezado.style.textAlign = 'center';
  3286. nuevaCeldaEncabezado.style.maxWidth = '7.5em';
  3287. nuevaCeldaEncabezado.style.width = '7.5em';
  3288. nuevaCeldaEncabezado.style.whiteSpace = 'nowrap';
  3289. nuevaCeldaEncabezado.style.overflow = 'hidden';
  3290. nuevaCeldaEncabezado.style.textOverflow = 'ellipsis';
  3291.  
  3292. var ser = document.getElementsByClassName("seriesHeader")
  3293.  
  3294.  
  3295. var table_index = 0;
  3296. for (var kl = 0; kl < ser.length; kl++) {
  3297. if (document.getElementsByClassName("seriesHeader")[kl].parentNode.parentNode.className == "nice_table") {
  3298. table_index = kl
  3299. }
  3300.  
  3301.  
  3302. }
  3303.  
  3304. document.getElementsByClassName("seriesHeader")[table_index].cells[1].style.width = "180px"
  3305. document.getElementsByClassName("seriesHeader")[table_index].appendChild(nuevaCeldaEncabezado);
  3306.  
  3307. nuevaCeldaEncabezado = document.createElement("th");
  3308. nuevaCeldaEncabezado.textContent = "Stats Xente";
  3309. nuevaCeldaEncabezado.style.textAlign = 'center';
  3310. ser = document.getElementsByClassName("seriesHeader")
  3311. document.getElementsByClassName("seriesHeader")[table_index].appendChild(nuevaCeldaEncabezado);
  3312.  
  3313.  
  3314. if (tabla.getElementsByTagName("tbody")[0].innerHTML.includes("mazyar")) {
  3315. searchClassName = "responsive-hide"
  3316. }
  3317.  
  3318. var contIds = 0
  3319. var filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  3320. for (var i = 0; i < filasDatos.length; i++) {
  3321. if (checkClassNameExists(tabla.rows[i + 1], searchClassName)) {
  3322. var celda = tabla.rows[i + 1].cells[1];
  3323. var equipo = celda.textContent.trim()
  3324. var iniIndex = celda.innerHTML.indexOf("tid=");
  3325. var lastIndex = celda.innerHTML.indexOf("\">", iniIndex + 4);
  3326. var data = String(celda.innerHTML)
  3327. var id = data.substring(iniIndex + 4, lastIndex)
  3328. linkIds += "&idEquipo" + contIds + "=" + id
  3329. contIds++
  3330. celda.innerHTML += "<input type='hidden' id='team_" + id + "' value='" + equipo + "'/>"
  3331. }
  3332.  
  3333. }
  3334.  
  3335.  
  3336.  
  3337. ///DIV PROGRESS
  3338. setTimeout(function () {
  3339.  
  3340.  
  3341. (function () {
  3342. document.getElementById("moreInfo").addEventListener('click', function () {
  3343. document.getElementById("moreInfo").classList.toggle('active');
  3344.  
  3345. if (document.getElementById("moreInfo").classList.contains("active")) {
  3346. document.getElementById("line2").style.transform = 'rotateZ(0deg)';
  3347. document.getElementById("line1").style.transform = 'rotateZ(180deg)';
  3348. document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
  3349. $('#separatorTd').fadeOut(1);
  3350. document.getElementById("separatorTd").style.paddingTop = "5px";
  3351. $('#show3').fadeIn('slow');
  3352. } else {
  3353. document.getElementById("line2").style.transform = 'rotateZ(45deg)';
  3354. document.getElementById("line1").style.transform = 'rotateZ(-45deg)';
  3355. document.getElementById("moreInfo").style.transform = 'rotateZ(45deg)';
  3356. $('#separatorTd').fadeIn(1);
  3357. $('#show3').fadeOut('slow');
  3358. }
  3359.  
  3360.  
  3361.  
  3362. });
  3363. })();
  3364.  
  3365. }, 200);
  3366.  
  3367. GM_xmlhttpRequest({
  3368. method: "GET",
  3369. url: "https://statsxente.com/MZ1/Functions/tamper_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + linkIds,
  3370. headers: {
  3371. "Content-Type": "application/json"
  3372. },
  3373. onload: function (response) {
  3374. var jsonResponse = JSON.parse(response.responseText);
  3375. teams_data = jsonResponse;
  3376. var filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  3377. for (var i = 0; i < filasDatos.length; i++) {
  3378. if (checkClassNameExists(filasDatos[i], searchClassName)) {
  3379. var celda = filasDatos[i].cells[1]
  3380. var equipo = celda.textContent.trim()
  3381. var iniIndex = celda.innerHTML.indexOf("tid=");
  3382. var lastIndex = celda.innerHTML.indexOf("\">", iniIndex + 4);
  3383. var data = String(celda.innerHTML)
  3384. var id = data.substring(iniIndex + 4, lastIndex)
  3385. var nuevaColumna = document.createElement("td");
  3386. var valor = 0;
  3387.  
  3388. if (jsonResponse[id] && jsonResponse[id][initialValues[detected_cat]] !== undefined) {
  3389. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[id][initialValues[detected_cat]]))
  3390. }
  3391. nuevaColumna.innerHTML = valor
  3392. nuevaColumna.style.textAlign = 'center';
  3393. filasDatos[i].appendChild(nuevaColumna);
  3394.  
  3395. var eloType = 1
  3396. if (window.sport == "soccer") { eloType = 2 }
  3397. var cats_elo = {}
  3398. cats_elo["senior"] = "SENIOR";
  3399. cats_elo["seniorw"] = "SENIOR";
  3400. cats_elo["SUB23"] = "U23";
  3401. cats_elo["SUB21"] = "U21";
  3402. cats_elo["SUB18"] = "U18";
  3403. cats_elo["SUB23w"] = "U23";
  3404. cats_elo["SUB21w"] = "U21";
  3405. cats_elo["SUB18w"] = "U18";
  3406.  
  3407. var cat = cats[detected_cat]
  3408.  
  3409.  
  3410. var flagSenior = 0, flagSub23 = 0, flagSub21 = 0, flagSub18 = 0;
  3411. if (jsonResponse[id]["elo"] > 0) { flagSenior = 1 }
  3412. if (jsonResponse[id]["elo23"] > 0) { flagSub23 = 1 }
  3413. if (jsonResponse[id]["elo21"] > 0) { flagSub21 = 1 }
  3414. if (jsonResponse[id]["elo18"] > 0) { flagSub18 = 1 }
  3415.  
  3416. var buttonDisplay = "display:block;";
  3417. nuevaColumna = document.createElement("td");
  3418. 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;'/>";
  3419. if (GM_getValue("league_graph_button") == "checked") {
  3420. buttonDisplay = ""
  3421. } else {
  3422. buttonDisplay = "display:none;";
  3423. }
  3424. 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 + "'/>";
  3425.  
  3426. if (GM_getValue("league_report_button") == "checked") {
  3427. buttonDisplay = ""
  3428. } else {
  3429. buttonDisplay = "display:none;";
  3430. }
  3431. 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 + "'/>";
  3432.  
  3433. if (GM_getValue("league_calendar_button") == "checked") {
  3434. buttonDisplay = ""
  3435. } else {
  3436. buttonDisplay = "display:none;";
  3437. }
  3438. 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 + "'/>";
  3439. iner += "</center>";
  3440.  
  3441. nuevaColumna.innerHTML = iner
  3442. filasDatos[i].appendChild(nuevaColumna);
  3443. nuevaColumna = document.createElement("td");
  3444. (function (currentId, currentLSport, lang) {
  3445. document.getElementById("but1" + currentId).addEventListener('click', function () {
  3446. var link = "https://statsxente.com/MZ1/Graficos/graficoProgresoEquipo.php?idEquipo=" + currentId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") + "&deporte=" + currentLSport;
  3447. openWindow(link, 0.95, 1.25);
  3448. });
  3449. })(id, window.lsport, window.lang);
  3450.  
  3451.  
  3452. (function (currentId, currentLSport, lang, currentCat) {
  3453. document.getElementById("but2" + currentId).addEventListener('click', function () {
  3454. var src = "filtroGraficoEquiposHistoricoHockey";
  3455. if (currentLSport == "F") {
  3456. src = "filtroGraficoLinealEquiposHistorico";
  3457. }
  3458.  
  3459. 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=-"
  3460. openWindow(link, 0.95, 1.25);
  3461. });
  3462. })(id, window.lsport, window.lang, cat);
  3463.  
  3464.  
  3465. (function (currentId, currentEquipo, currentCat, currentSport, lang) {
  3466. document.getElementById("but" + currentId).addEventListener('click', function () {
  3467. 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";
  3468. openWindow(link, 0.95, 1.25);
  3469. });
  3470. })(id, equipo, cat, window.sport, window.lang);
  3471.  
  3472.  
  3473.  
  3474.  
  3475. (function (currentId, type, currentCat, currentSport, lang, flagS, flagS23, flagS21, flagS18) {
  3476. document.getElementById("but3" + currentId).addEventListener('click', function () {
  3477. var link = "https://statsxente.com/MZ1/Graficos/graficoRachaEquipoELO.php?tamper=yes&team_id=" + currentId + "&idioma=" + lang + "&deporte=" + currentSport + "&type=" + type + "&cat=" + currentCat + "&flagSenior=" +
  3478. flagS + "&flagSub23=" + flagS23 + "&flagSub21=" + flagS21 + "&flagSub18=" + flagS18;
  3479. openWindow(link, 0.95, 1.25);
  3480. });
  3481. })(id, eloType, cats_elo[cat], window.sport, window.lang, flagSenior, flagSub23, flagSub21, flagSub18);
  3482.  
  3483. }
  3484.  
  3485. }
  3486. var thead = document.getElementsByClassName("seriesHeader")[table_index]
  3487. var ths = thead.querySelectorAll("th");
  3488. ths.forEach(function (th, index) {
  3489. th.addEventListener("click", function () {
  3490. ordenarTabla(index, true, "nice_table");
  3491. });
  3492. });
  3493. }
  3494. });
  3495. }, 2500);
  3496.  
  3497. }
  3498.  
  3499. })();