Stats Xente Script

Stats Xente script for inject own data on Managerzone site

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

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