Stats Xente Script

Stats Xente script for inject own data on Managerzone site

目前為 2024-09-26 提交的版本,檢視 最新版本

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