Greasy Fork is available in English.

Stats Xente Script

Stats Xente script for inject own data on Managerzone site

Pada tanggal 06 Oktober 2024. Lihat %(latest_version_link).

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