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.95
  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. waitToDOM(match, ".hitlist.statsLite.marker", 0)
  522. }
  523.  
  524. if ((urlParams.has('p')) && (urlParams.get('p') === 'players') && (!urlParams.has('pid'))
  525. && (GM_getValue("playersFlag"))) {
  526.  
  527. waitToDOM(playersPage, ".playerContainer", 0)
  528. }
  529.  
  530. if ((urlParams.has('p')) && (urlParams.get('p') === 'players') && (urlParams.has('pid'))) {
  531. waitToDOM(playersPageStats, ".player_name", 0)
  532. }
  533.  
  534.  
  535. if ((urlParams.has('p')) && (urlParams.get('p') === 'rank') && (urlParams.get('sub') === 'countryrank')
  536. && (GM_getValue("countryRankFlag"))) {
  537. countryRank();
  538. }
  539.  
  540. if ((urlParams.has('p')) && (urlParams.get('p') === 'clubhouse')) {
  541. nextMatchesClubhouse()
  542. }
  543.  
  544.  
  545. if ((urlParams.has('p')) && (urlParams.get('p') === 'friendlyseries')
  546. && (urlParams.get('sub') === 'standings')) {
  547. waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0)
  548. }
  549.  
  550.  
  551. if ((urlParams.has('p')) && (urlParams.get('p') === 'cup') && (urlParams.get('sub') === 'groupplay')) {
  552. waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0)
  553. }
  554.  
  555.  
  556. if ((urlParams.has('p')) && (urlParams.get('p') === 'private_cup') && (urlParams.get('sub') === 'groupplay')) {
  557. waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0)
  558. }
  559.  
  560.  
  561. }, 2000);
  562.  
  563.  
  564.  
  565.  
  566. const elementos = document.querySelectorAll('.player_link'); //Adds stats icon in players page, when click on player info
  567. elementos.forEach(function (elemento) {
  568. elemento.addEventListener('click', function () {
  569. waitToDOM(playersPageStats, ".player_name", 0)
  570. });
  571. });
  572.  
  573.  
  574.  
  575.  
  576. (function () {
  577. if (document.getElementById("league_tab_table") !== null) {
  578. document.getElementById("league_tab_table").addEventListener('click', function () {
  579. if (document.getElementById("showMenu") === null) {
  580. waitToDOM(leagues, ".nice_table", 0)
  581. }
  582. });
  583.  
  584. }
  585. })();
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. setTimeout(function () {
  599.  
  600.  
  601.  
  602.  
  603. (function () {
  604.  
  605. if (document.getElementById("ui-id-2") !== null) {
  606. document.getElementById("ui-id-2").parentNode.addEventListener('click', function () {
  607. if (document.getElementById("showMenu") === null) {
  608.  
  609. var urlParams = new URLSearchParams(window.location.search);
  610.  
  611. if (urlParams.get('fsid')) {
  612. waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0)
  613. } else {
  614. waitToDOM(clashLeagues, ".nice_table", 0)
  615. }
  616.  
  617.  
  618. }
  619. });
  620.  
  621. }
  622. })();
  623.  
  624.  
  625.  
  626. (function () {
  627.  
  628. if (document.getElementById("ui-id-4") !== null) {
  629. document.getElementById("ui-id-4").parentNode.addEventListener('click', function () {
  630. if (document.getElementById("showMenu") === null) {
  631. waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0)
  632. }
  633. });
  634.  
  635. }
  636. })();
  637.  
  638.  
  639.  
  640.  
  641.  
  642. }, 2000);
  643.  
  644.  
  645. function fetchExistTeam(url) {
  646. return new Promise((resolve, reject) => {
  647.  
  648. GM_xmlhttpRequest({
  649. method: "GET",
  650. url: url,
  651. headers: {
  652. "Content-Type": "application/json"
  653. },
  654. onload: function (response) {
  655. var jsonResponse = JSON.parse(response.responseText);
  656. resolve(jsonResponse['inserted'])
  657. },
  658. onerror: function (error) {
  659. reject("no");
  660. }
  661. });
  662. });
  663. }
  664.  
  665. function fetchExistPlayers(url) {
  666. return new Promise((resolve, reject) => {
  667.  
  668. GM_xmlhttpRequest({
  669. method: "GET",
  670. url: url,
  671. headers: {
  672. "Content-Type": "application/json"
  673. },
  674. onload: function (response) {
  675. var jsonResponse = JSON.parse(response.responseText);
  676. resolve(jsonResponse)
  677. },
  678. onerror: function (error) {
  679. reject("no");
  680. }
  681. });
  682. });
  683. }
  684.  
  685. async function match() {
  686. var team_div = document.getElementsByClassName("flex-grow-0 textCenter team-table block")
  687. var teams_ = []
  688.  
  689.  
  690. for (var x = 0; x < 2; x++) {
  691. var as = team_div[x].getElementsByTagName("a")
  692. var urlObj = new URL("https://www.managerzone.com/" + as[0].getAttribute('href'));
  693. var params = new URLSearchParams(urlObj.search);
  694. var tidValue = params.get('tid');
  695. teams_[x] = { "team_name": as[0].innerHTML, "team_id": tidValue, "inserted": "" }
  696. }
  697.  
  698. var elems = document.getElementsByClassName("hitlist " + window.sport + " statsLite marker tablesorter");
  699. for (x = 0; x < 2; x++) {
  700. var linkIds = ""
  701. var contIds = 0;
  702. var tabla = elems[x]
  703. var filas = tabla.getElementsByTagName("tr");
  704. var fila = filas[1];
  705.  
  706. for (var i = 2; i < filas.length - 1; i++) {
  707.  
  708. fila = filas[i];
  709. var tds = fila.getElementsByTagName("td");
  710. var as_ = tds[2].getElementsByTagName("a");
  711. urlObj = new URL("https://www.managerzone.com/" + as_[0].getAttribute("href"));
  712. params = new URLSearchParams(urlObj.search);
  713. var pid = params.get('pid');
  714.  
  715. linkIds += "&id" + contIds + "=" + pid
  716. contIds++;
  717. }
  718.  
  719. link = "http://statsxente.com/MZ1/Functions/tamper_check_stats_player.php?sport=" + window.sport + linkIds
  720. var inserted = await fetchExistPlayers(link);
  721. teams_[x]["inserted"]= inserted;
  722.  
  723. }
  724.  
  725.  
  726. elems = document.getElementsByClassName("hitlist " + window.sport + " statsLite marker tablesorter");
  727. for (x = 0; x < 2; x++) {
  728. if (teams_[x]['inserted']['total'] > 0) {
  729. tabla = elems[x]
  730. var firstTrThead = tabla.querySelector('thead td');
  731. var currentColspan = firstTrThead.getAttribute('colspan');
  732. currentColspan = parseInt(currentColspan, 10) + 1;
  733. firstTrThead.setAttribute('colspan', currentColspan);
  734. var secondTrThead = tabla.querySelector('thead tr:nth-of-type(2)')
  735. var newTd = document.createElement('td');
  736. newTd.textContent = '';
  737. secondTrThead.appendChild(newTd);
  738. filas = tabla.getElementsByTagName("tr");
  739. fila = filas[1];
  740. var dato = document.createElement("td");
  741. var tfoot = tabla.querySelector("tfoot");
  742. var primeraFilaTfoot = tfoot.querySelector("tr");
  743. var primerTDTfoot = primeraFilaTfoot.querySelector("td");
  744. primerTDTfoot.setAttribute("colspan", "9");
  745.  
  746. var elems2 = document.getElementsByClassName("listHeadColor");
  747. var lista = elems2[0]
  748.  
  749. var nuevoElementoDD = document.createElement("dd");
  750. nuevoElementoDD.textContent = "Nuevo elemento";
  751. nuevoElementoDD.className = "c6"
  752. lista.appendChild(nuevoElementoDD);
  753.  
  754. var id = 1516;
  755. for (i = 2; i < filas.length - 1; i++) {
  756. fila = filas[i];
  757.  
  758. tds = fila.getElementsByTagName("td");
  759. as_ = tds[2].getElementsByTagName("a");
  760. urlObj = new URL("https://www.managerzone.com/" + as_[0].getAttribute("href"));
  761. params = new URLSearchParams(urlObj.search);
  762. pid = params.get('pid');
  763. if (teams_[x]['inserted'][pid] == "yes") {
  764. dato = document.createElement("td");
  765. var iner = "<img src='https://statsxente.com/MZ1/View/Images/etiqueta_bota.png' width='20px' height='20px' id='but" + pid + "' style='cursor:pointer;'/>";
  766. dato.innerHTML = iner
  767. fila.appendChild(dato);
  768.  
  769.  
  770.  
  771. (function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
  772. document.getElementById("but" + currentId).addEventListener('click', function () {
  773.  
  774. var link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
  775. + "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
  776. "&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
  777. openWindow(link, 0.95, 1.25);
  778. });
  779. })(pid, teams_[x]['team_id'], window.sport, window.lang, teams_[x]['team_name'], as_[0].innerHTML);
  780.  
  781.  
  782. }
  783. }
  784. }
  785. }
  786. }
  787.  
  788. function clash() {
  789.  
  790. var badges = document.getElementsByClassName("fed_badge");
  791. var regex = /fid=(\d+)/;
  792. var srcLocal = badges[0].getAttribute('src');
  793. var local_id = srcLocal.match(regex);
  794. var src_away = badges[1].getAttribute('src');
  795. var away_id = src_away.match(regex);
  796. var names = document.getElementsByClassName("name-score text-ellipsis")
  797. var elems = document.getElementsByClassName("top-pane__deadline");
  798. var tabla = elems[0]
  799.  
  800. 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>";
  801. tabla.insertAdjacentHTML('beforeend', contenidoNuevo)
  802.  
  803. document.getElementById("clashCompare").addEventListener('click', function () {
  804. 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;
  805. openWindow(link, 0.95, 1.25);
  806. });
  807.  
  808. }
  809.  
  810.  
  811. var teams_data = "";
  812. var searchClassName = ""
  813.  
  814. function leagues() {
  815. var urlParams = new URLSearchParams(window.location.search);
  816. var initialValues = {};
  817. initialValues["senior"] = GM_getValue("league_default_senior");
  818. initialValues["world"] = GM_getValue("league_default_senior");
  819. initialValues["u23"] = GM_getValue("league_default_u23");
  820. initialValues["u21"] = GM_getValue("league_default_u21");
  821. initialValues["u18"] = GM_getValue("league_default_u18");
  822. initialValues["u23_world"] = GM_getValue("league_default_u23");
  823. initialValues["u21_world"] = GM_getValue("league_default_u21");
  824. initialValues["u18_world"] = GM_getValue("league_default_u18");;
  825.  
  826. var linkIds = ""
  827. var elems = document.getElementsByClassName("nice_table");
  828. var tabla = elems[0]
  829. var thSegundo = tabla.querySelector("thead th:nth-child(2)");
  830. thSegundo.style.width = "250px";
  831.  
  832.  
  833. var values = new Map();
  834. values.set('valor23', 'U23 Value');
  835. values.set('valor21', 'U21 Value');
  836. values.set('valor18', 'U18 Value');
  837. values.set('salario', 'Salary');
  838. values.set('valorUPSenior', 'LM Value');
  839. values.set('valorUPSUB23', 'U23 LM Value');
  840. values.set('valorUPSUB21', 'U21 LM Value');
  841. values.set('valorUPSUB18', 'U18 LM Value');
  842. values.set('edad', 'Age');
  843. if (window.sport == "soccer") {
  844. values.set('valor11', 'TOP 11');
  845. values.set('valor11_23', 'U23 TOP 11');
  846. values.set('valor11_21', 'U21 TOP 11');
  847. values.set('valor11_18', 'U18 TOP 11');
  848. } else {
  849. values.set('valor11', 'TOP 21');
  850. values.set('valor11_23', 'U23 TOP 21');
  851. values.set('valor11_21', 'U21 TOP 21');
  852. values.set('valor11_18', 'U18 TOP 21');
  853. }
  854.  
  855. values.set('noNac', 'Foreigners');
  856. values.set('elo', 'ELO Score');
  857. values.set('elo23', 'U23 ELO Score');
  858. values.set('elo21', 'U21 ELO Score');
  859. values.set('elo18', 'U18 ELO Score');
  860. values.set('numJugadores', 'Number of players');
  861.  
  862. if (urlParams.get('type') == "senior") {
  863. values.set('leagues', 'Leagues');
  864. values.set('world_leagues_all', 'World Leagues');
  865. values.set('youth_leagues_all', 'Youth Leagues');
  866. values.set('world_youth_leagues_all', 'Youth World Leagues');
  867. values.set('federation_leagues', 'Federation Leagues');
  868. }
  869.  
  870.  
  871. if (urlParams.get('type') == "world") {
  872. values.set('leagues_all', 'Leagues');
  873. values.set('world_leagues', 'World Leagues');
  874. values.set('youth_leagues_all', 'Youth Leagues');
  875. values.set('world_youth_leagues_all', 'Youth World Leagues');
  876. values.set('federation_leagues', 'Federation Leagues');
  877. }
  878.  
  879.  
  880. if ((urlParams.get('type').includes("u")) && (!urlParams.get('type').includes("_"))) {
  881. var actual_cat = urlParams.get('type').toUpperCase();
  882. GM_setValue("actual_league_cat", actual_cat)
  883. values.set('leagues_all', 'Leagues');
  884. values.set('world_leagues_all', 'World Leagues');
  885. values.set('youth_leagues', actual_cat + ' Youth Leagues');
  886. values.set('world_youth_leagues_all', 'Youth World Leagues');
  887. values.set('federation_leagues', 'Federation Leagues');
  888. }
  889.  
  890.  
  891. if ((urlParams.get('type').includes("u")) && (urlParams.get('type').includes("_"))) {
  892. actual_cat = urlParams.get('type').substring(0, 3).toUpperCase();
  893. GM_setValue("actual_league_cat", actual_cat)
  894. values.set('leagues_all', 'Leagues');
  895. values.set('world_leagues_all', 'World Leagues');
  896. values.set('youth_leagues_all', 'Youth Leagues');
  897. values.set('world_youth_leagues', actual_cat + ' Youth World Leagues');
  898. values.set('federation_leagues', 'Federation Leagues');
  899. }
  900. values.set('cup', 'Cups');
  901. values.set('cup_u23', 'U23 Cups');
  902. values.set('cup_u21', 'U21 Cups');
  903. values.set('cup_u18', 'U18 Cups');
  904. values.set('special_cup', 'Special Cups');
  905.  
  906. var contenidoNuevo = '<div id=testClick><center>'
  907.  
  908.  
  909. getNativeTableStyles();
  910.  
  911. var idProgress = "noProgress";
  912. if (urlParams.get('type') == "senior") {
  913. idProgress = "divProgress"
  914. }
  915.  
  916.  
  917. var widthTable = "1.5em"
  918. ///MENU TABLE
  919. contenidoNuevo += "<center><table id=showMenu border=0><thead style='background-color:" + GM_getValue("bg_native") + "; color:" + GM_getValue("color_native") + ";'><tr>";
  920. contenidoNuevo += '<th align=center style="padding:4px;">Stats</th><th align=center style="padding:4px;">Graph</th>';
  921. contenidoNuevo += "<th align=center style='padding:4px;'>History</th>";
  922. contenidoNuevo += "<th align=center style='padding:4px;'>Top Players</th></tr></thead>";
  923. contenidoNuevo += "<tr>";
  924. 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>";
  925. 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>";
  926. if (idProgress == "noProgress") {
  927. 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>";
  928. } else {
  929. 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>";
  930. }
  931. 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>";
  932. contenidoNuevo += "</tr>";
  933.  
  934. var styleTable = " style='display:none;'";
  935. var styleIcon = ""
  936. var styleSep = "style='padding-top:5px;'";
  937.  
  938. if (GM_getValue("show_league_selects") == true) {
  939. styleTable = "";
  940. styleIcon = " active"
  941. styleSep = " style='display:none;'";
  942. }
  943.  
  944.  
  945. contenidoNuevo += "<tr><td></td><td colspan='2'>";
  946. 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>';
  947. contenidoNuevo += "</td><td></td></tr>";
  948. contenidoNuevo += "<tr><td colspan='5' id='separatorTd'" + styleSep + "></td></tr>";
  949. contenidoNuevo += "</table></center>";
  950. contenidoNuevo += '<table id=show3 border="0"' + styleTable + '><tr><td><label>';
  951.  
  952. if ((urlParams.get('type') == 'senior') || (urlParams.get('type') == 'world')) {
  953. if ("valor" == initialValues[urlParams.get('type')]) {
  954. contenidoNuevo += '<input class="statsxente" type="checkbox" checked id="valor" value="Value">Value</label></td>';
  955. } else {
  956. contenidoNuevo += '<input class="statsxente" type="checkbox" id="valor" value="Value">Value</label></td>';
  957. }
  958. } else {
  959. contenidoNuevo += '<input class="statsxente" type="checkbox" id="valor" value="Value">Value</label></td>';
  960. }
  961.  
  962. values.forEach(function (valor, clave) {
  963.  
  964. if (clave == "valorUPSenior") {
  965. contenidoNuevo += "</tr><tr>";
  966. }
  967.  
  968. if (clave == "valor11") {
  969. contenidoNuevo += "</tr><tr>";
  970. }
  971. if (clave == "elo") {
  972. contenidoNuevo += "</tr><tr>";
  973. }
  974.  
  975. if (clave == "leagues") {
  976. contenidoNuevo += "</tr><tr>";
  977. }
  978.  
  979. if (clave == "leagues_all") {
  980. contenidoNuevo += "</tr><tr>";
  981. }
  982.  
  983. if (clave == "cup") {
  984. contenidoNuevo += "</tr><tr>";
  985. }
  986.  
  987. if (clave == initialValues[urlParams.get('type')]) {
  988. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" checked value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  989. } else {
  990. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  991. }
  992. });
  993. contenidoNuevo += "</tr></table></center>"
  994. contenidoNuevo += "</div></br>";
  995. values.set('valor', 'Value');
  996.  
  997. elems = document.getElementsByClassName("nice_table");
  998. tabla = elems[0]
  999. tabla.insertAdjacentHTML('beforebegin', contenidoNuevo);
  1000.  
  1001. if (GM_getValue("show_league_selects") == true) {
  1002. document.getElementById("line2").style.transform = 'rotateZ(0deg)';
  1003. document.getElementById("line1").style.transform = 'rotateZ(180deg)';
  1004. document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
  1005. }
  1006.  
  1007.  
  1008. values.forEach(function (valor, clave) {
  1009. var elemento = document.getElementById(clave);
  1010. elemento.addEventListener('click', handleClick);
  1011. });
  1012.  
  1013. var nuevaCeldaEncabezado = document.createElement("th");
  1014. nuevaCeldaEncabezado.textContent = values.get(initialValues[urlParams.get('type')]);
  1015. nuevaCeldaEncabezado.style.textAlign = 'center';
  1016. nuevaCeldaEncabezado.style.maxWidth = '6.5em';
  1017. nuevaCeldaEncabezado.style.width = '6.5em';
  1018. nuevaCeldaEncabezado.style.whiteSpace = 'nowrap';
  1019. nuevaCeldaEncabezado.style.overflow = 'hidden';
  1020. nuevaCeldaEncabezado.style.textOverflow = 'ellipsis';
  1021.  
  1022. var ser = document.getElementsByClassName("seriesHeader")
  1023. document.getElementsByClassName("seriesHeader")[0].appendChild(nuevaCeldaEncabezado);
  1024.  
  1025. nuevaCeldaEncabezado = document.createElement("th");
  1026. nuevaCeldaEncabezado.textContent = "Stats Xente";
  1027. nuevaCeldaEncabezado.style.textAlign = 'center';
  1028. document.getElementsByClassName("seriesHeader")[0].appendChild(nuevaCeldaEncabezado);
  1029.  
  1030.  
  1031. if (tabla.getElementsByTagName("tbody")[0].innerHTML.includes("mazyar")) {
  1032. searchClassName = "responsive-hide"
  1033. }
  1034.  
  1035. var contIds = 0
  1036. var filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  1037. for (var i = 0; i < filasDatos.length; i++) {
  1038. if (checkClassNameExists(tabla.rows[i + 1], searchClassName)) {
  1039. var celda = tabla.rows[i + 1].cells[1];
  1040. var equipo = celda.textContent.trim()
  1041. var iniIndex = celda.innerHTML.indexOf("tid=");
  1042. var lastIndex = celda.innerHTML.indexOf("\">", iniIndex + 4);
  1043. var data = String(celda.innerHTML)
  1044. var id = data.substring(iniIndex + 4, lastIndex)
  1045. linkIds += "&idEquipo" + contIds + "=" + id
  1046. contIds++
  1047. celda.innerHTML += "<input type='hidden' id='team_" + id + "' value='" + equipo + "'/>"
  1048. }
  1049.  
  1050. }
  1051. var cat = cats[urlParams.get('type')]
  1052. var enlace = document.getElementById('league_tab_schedule');
  1053. var href = enlace.href;
  1054. var url = new URL(href);
  1055. var league_id = url.searchParams.get('sid');
  1056.  
  1057.  
  1058.  
  1059. ///DIV PROGRESS
  1060. setTimeout(function () {
  1061.  
  1062.  
  1063. if (idProgress != "noProgress") {
  1064. (function (currentId, currentLSport, lang) {
  1065. document.getElementById("divProgress").addEventListener('click', function () {
  1066.  
  1067. var link = "https://statsxente.com/MZ1/Graficos/graficoProgresoDivision.php?idLiga=" + currentId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") + "&deporte=" + currentLSport;
  1068. openWindow(link, 0.95, 1.25);
  1069. });
  1070. })(league_id, window.lsport, window.lang);
  1071.  
  1072. }
  1073.  
  1074.  
  1075. (function () {
  1076. document.getElementById("moreInfo").addEventListener('click', function () {
  1077. document.getElementById("moreInfo").classList.toggle('active');
  1078.  
  1079. if (document.getElementById("moreInfo").classList.contains("active")) {
  1080. document.getElementById("line2").style.transform = 'rotateZ(0deg)';
  1081. document.getElementById("line1").style.transform = 'rotateZ(180deg)';
  1082. document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
  1083. $('#separatorTd').fadeOut(1);
  1084. document.getElementById("separatorTd").style.paddingTop = "5px";
  1085. $('#show3').fadeIn('slow');
  1086. } else {
  1087. document.getElementById("line2").style.transform = 'rotateZ(45deg)';
  1088. document.getElementById("line1").style.transform = 'rotateZ(-45deg)';
  1089. document.getElementById("moreInfo").style.transform = 'rotateZ(45deg)';
  1090. $('#separatorTd').fadeIn(1);
  1091. $('#show3').fadeOut('slow');
  1092. }
  1093.  
  1094.  
  1095.  
  1096. });
  1097. })();
  1098.  
  1099. (function (currentId, currentLSport, lang, currentCat) {
  1100. document.getElementById("detailDivision").addEventListener('click', function () {
  1101. var url_ = "https://statsxente.com/MZ1/Functions/lecturaStatsDivisionesHistorico2.0.php"
  1102. if (window.sport == "hockey") {
  1103. url_ = "https://statsxente.com/MZ1/Functions/lecturaStatsDivisionesHockeyHistorico.php"
  1104. }
  1105.  
  1106. var link = url_ + "?tamper=yes&modal=yes&idLiga=" + currentId + "&idioma=" + lang + "&categoria=" + currentCat + "&season=75&season_actual=75";
  1107. openWindow(link, 0.95, 1.25);
  1108. });
  1109. })(league_id, window.lsport, window.lang, cat);
  1110.  
  1111. (function (currentId, sport, lang, currentCat) {
  1112. document.getElementById("topPlayersDivision").addEventListener('click', function () {
  1113. var url_ = "https://statsxente.com/MZ1/Functions/tamper_top_players_division.php"
  1114. if (window.sport == "hockey") {
  1115. url_ = "https://statsxente.com/MZ1/Functions/tamper_top_players_division_hockey.php"
  1116. }
  1117. var link = url_ + "?league_id=" + currentId + "&sport=" + sport + "&category=" + cat + "&idioma=" + lang;
  1118. openWindow(link, 0.95, 1.25);
  1119. });
  1120. })(league_id, window.sport, window.lang, cat);
  1121.  
  1122. (function (currentId, currentLSport, lang, currentCat) {
  1123. document.getElementById("graphDivision").addEventListener('click', function () {
  1124. var url_sport = ""
  1125. if (window.sport == "hockey") {
  1126. url_sport = "Hockey"
  1127. }
  1128. 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";
  1129. openWindow(link, 0.95, 1.25);
  1130. });
  1131. })(league_id, window.lsport, window.lang, cat);
  1132.  
  1133.  
  1134. }, 200);
  1135.  
  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%;"></br><table border=0><tbody><tr>';
  1807. newContent += '<td><label class="containerPeqAmarillo">League<input type="checkbox" id="leagueSelect" ' + leagueFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  1808. newContent += '<td><label class="containerPeqAmarillo">Federation<input type="checkbox" id="federationSelect" ' + federationFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  1809. newContent += '<td><label class="containerPeqAmarillo">Match<input type="checkbox" id="matchSelect" ' + matchFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  1810. newContent += '<td><label class="containerPeqAmarillo">Players<input type="checkbox" id="playersSelect" ' + playersFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  1811. newContent += '<td><label class="containerPeqAmarillo">Country Rank<input type="checkbox" id="countryRankSelect" ' + countryRankFlag + '><span class="checkmarkPeqAmarillo"></span></td>'
  1812. newContent += "</tr></tbody></table>"
  1813.  
  1814. newContent += "<hr>"
  1815. newContent += "<h3 style='text-align: left; padding-left:7px;'>Leagues Config</h3>"
  1816.  
  1817. newContent += "<table border='0'><tr>"
  1818. newContent += "<td>Default Senior Param: <td>" + generateValuesSelect('senior') + "</td>";
  1819. newContent += "<td>Default U23 Param: <td>" + generateValuesSelect('u23') + "</td>";
  1820. newContent += "<td>Default U21 Param: <td>" + generateValuesSelect('u21') + "</td>";
  1821. newContent += "<td>Default U18 Param: <td>" + generateValuesSelect('u18') + "</td>";
  1822.  
  1823. newContent += "</tr><tr>"
  1824.  
  1825.  
  1826. var checked_graph = GM_getValue("league_graph_button")
  1827. var checked_report = GM_getValue("league_report_button")
  1828. var checked_calendar = GM_getValue("league_calendar_button")
  1829.  
  1830. 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>"
  1831. 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>"
  1832.  
  1833. 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>"
  1834.  
  1835. newContent += '</tr><tr>';
  1836.  
  1837. 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">'
  1838. newContent += '<img class="textMiddle" id="testImage" src="https://statsxente.com/MZ1/View/Images/calendar.png" width="20px" height="20px"/>'
  1839. newContent += '<span class="textMiddle" style="padding-left:10px;" id="sizeImageLeagueSpan"> (' + GM_getValue("league_image_size") + ')</span></label></center></td>'
  1840.  
  1841.  
  1842.  
  1843. var checkedLeagueSelects = ""
  1844. if (GM_getValue("show_league_selects")) {
  1845. checkedLeagueSelects = "checked"
  1846. }
  1847.  
  1848. 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>'
  1849. newContent += "</tr></table>"
  1850. newContent += "<hr>"
  1851. newContent += "<h3 style='text-align: left; padding-left:7px;'>Tabs Config</h3>"
  1852. newContent += "<table style='display:flex;'><tr><td>"
  1853.  
  1854. var checkedTab = ""
  1855. if (GM_getValue("tabsConfig")) {
  1856. checkedTab = "checked"
  1857. }
  1858.  
  1859. var checkedWin = ""
  1860. if (GM_getValue("windowsConfig")) {
  1861. checkedWin = "checked"
  1862. }
  1863.  
  1864.  
  1865. newContent += "<label><input type='checkbox' id='windowsConfig' " + checkedWin + ">Windows</label>";
  1866. newContent += "<label><input type='checkbox' id='tabsConfig' " + checkedTab + ">Tabs</label>";
  1867. newContent += "</td></tr></table></br></br>"
  1868.  
  1869.  
  1870.  
  1871.  
  1872. 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>'
  1873. newContent += '</div></center></br></br>';
  1874. document.getElementById("contenido_modal_cargando").innerHTML = newContent
  1875. createLeagueConfigOptionsListeners();
  1876. document.getElementById("contenido_modal_cargando").style.width = "75%";
  1877. document.getElementById("myModal_cargando").style.display = "none"
  1878. getNativeTableStyles()
  1879.  
  1880. document.getElementById("alert_tittle").style.backgroundColor = GM_getValue("bg_native")
  1881.  
  1882. document.getElementById("legendDiv").addEventListener('click', function () {
  1883.  
  1884. if (document.getElementById("myModal_cargando").style.display == "none") {
  1885. document.getElementById("myModal_cargando").style.display = "flex";
  1886. } else {
  1887. document.getElementById("myModal_cargando").style.display = "none";
  1888. }
  1889.  
  1890. });
  1891.  
  1892.  
  1893. document.getElementById("closeButton").addEventListener('click', function () {
  1894. document.getElementById("myModal_cargando").style.display = "none";
  1895. });
  1896.  
  1897.  
  1898. document.getElementById("saveButton").addEventListener('click', function () {
  1899. window.location.reload();
  1900. });
  1901.  
  1902.  
  1903.  
  1904.  
  1905. (function () {
  1906. document.getElementById("deleteButton").addEventListener('click', function () {
  1907. var keys = GM_listValues();
  1908. keys.forEach(function (key) {
  1909. GM_deleteValue(key);
  1910. });
  1911. window.location.reload();
  1912. });
  1913. })();
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919. // }, 3000);
  1920.  
  1921. }
  1922. function getNativeTableStyles() {
  1923. var elemento = document.querySelector('.subheader.clearfix');
  1924. if (elemento) {
  1925. var estilo = getComputedStyle(elemento);
  1926. var bg = estilo.backgroundColor
  1927. var color = "white"
  1928. if (estilo.backgroundColor == "rgba(0, 0, 0, 0)") {
  1929. bg = "#a9b0b4"
  1930. }
  1931. GM_setValue("bg_native", bg)
  1932. GM_setValue("color_native", color)
  1933. }
  1934.  
  1935.  
  1936. }
  1937. function createModalEventListeners() {
  1938. setTimeout(function () {
  1939.  
  1940.  
  1941. document.getElementById('leagueSelect').addEventListener('click', function () {
  1942. GM_setValue("leagueFlag", !GM_getValue("leagueFlag"))
  1943. });
  1944.  
  1945.  
  1946. document.getElementById('federationSelect').addEventListener('click', function () {
  1947. GM_setValue("federationFlag", !GM_getValue("federationFlag"))
  1948. });
  1949.  
  1950. document.getElementById('matchSelect').addEventListener('click', function () {
  1951. GM_setValue("matchFlag", !GM_getValue("matchFlag"))
  1952. });
  1953.  
  1954. document.getElementById('playersSelect').addEventListener('click', function () {
  1955. GM_setValue("playersFlag", !GM_getValue("playersFlag"))
  1956. });
  1957.  
  1958. document.getElementById('countryRankSelect').addEventListener('click', function () {
  1959. GM_setValue("countryRankFlag", !GM_getValue("countryRankFlag"))
  1960. });
  1961.  
  1962.  
  1963.  
  1964.  
  1965. document.getElementById('show_league_checkbox').addEventListener('click', function () {
  1966. GM_setValue("show_league_selects", !GM_getValue("show_league_selects"))
  1967. });
  1968.  
  1969.  
  1970.  
  1971. document.getElementById('windowsConfig').addEventListener('click', function () {
  1972.  
  1973. if (document.getElementById('windowsConfig').checked) {
  1974. document.getElementById('tabsConfig').checked = false;
  1975. } else {
  1976. document.getElementById('tabsConfig').checked = true;
  1977. }
  1978.  
  1979. GM_setValue("windowsConfig", !GM_getValue("windowsConfig"))
  1980. GM_setValue("tabsConfig", !GM_getValue("tabsConfig"))
  1981.  
  1982.  
  1983. });
  1984.  
  1985.  
  1986. document.getElementById('tabsConfig').addEventListener('click', function () {
  1987. if (document.getElementById('tabsConfig').checked) {
  1988. document.getElementById('windowsConfig').checked = false;
  1989. } else {
  1990. document.getElementById('windowsConfig').checked = true;
  1991. }
  1992. GM_setValue("windowsConfig", !GM_getValue("windowsConfig"))
  1993. GM_setValue("tabsConfig", !GM_getValue("tabsConfig"))
  1994.  
  1995.  
  1996. });
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002. (function () {
  2003. document.getElementById("slider_input").addEventListener('input', function () {
  2004. document.getElementById("testImage").style.width = document.getElementById("slider_input").value + "px";
  2005. document.getElementById("testImage").style.height = document.getElementById("slider_input").value + "px";
  2006.  
  2007. document.getElementById("sizeImageLeagueSpan").innerText = "(" + document.getElementById("slider_input").value + ")"
  2008.  
  2009.  
  2010. GM_setValue("league_image_size", document.getElementById("slider_input").value)
  2011.  
  2012.  
  2013. });
  2014. })();
  2015.  
  2016.  
  2017.  
  2018.  
  2019. }, 5000);
  2020.  
  2021. }
  2022.  
  2023. function setLangSportCats() {
  2024.  
  2025. var langs = new Map();
  2026. langs.set('es', 'SPANISH');
  2027. langs.set('ar', 'SPANISH')
  2028. langs.set('en', 'ENGLISH');
  2029. langs.set('br', 'PORTUGUES');
  2030. langs.set('pt', 'PORTUGUES');
  2031. langs.set('pl', 'POLISH');
  2032. langs.set('ro', 'ROMANIAN');
  2033. langs.set('tr', 'TURKISH');
  2034.  
  2035. var lanCookie = getCookie("MZLANG");
  2036. if (langs.has(lanCookie)) {
  2037. window.lang = langs.get(lanCookie);
  2038. } else {
  2039. window.lang = "ENGLISH";
  2040. }
  2041.  
  2042. var sportCookie = getCookie("MZSPORT");
  2043. var lsport = "F"
  2044. var sport_id = 1;
  2045. if (sportCookie == "hockey") {
  2046. lsport = "H";
  2047. sport_id = 2;
  2048. }
  2049.  
  2050. var cats = {};
  2051. cats["senior"] = "senior";
  2052. cats["world"] = "seniorw";
  2053. cats["u23"] = "SUB23";
  2054. cats["u21"] = "SUB21";
  2055. cats["u18"] = "SUB18";
  2056. cats["u23_world"] = "SUB23w";
  2057. cats["u21_world"] = "SUB21w";
  2058. cats["u18_world"] = "SUB18w";
  2059.  
  2060.  
  2061. window.cats = cats;
  2062. window.sport = sportCookie;
  2063. window.lsport = lsport;
  2064. window.sport_id = sport_id;
  2065. window.userLocal = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.language;
  2066.  
  2067. }
  2068.  
  2069. function getUsernameData() {
  2070. if ((GM_getValue("currency") === undefined) || (GM_getValue("currency") == "")) {
  2071. var username = document.getElementById("header-username").innerText
  2072. GM_xmlhttpRequest({
  2073. method: "GET",
  2074. url: "http://www.managerzone.com/xml/manager_data.php?sport_id=" + window.sport_id + "&username=" + username,
  2075. headers: {
  2076. "Content-Type": "application/json"
  2077. },
  2078. onload: function (response) {
  2079.  
  2080. var parser = new DOMParser();
  2081. var xmlDoc = parser.parseFromString(response.responseText, "text/xml");
  2082. var userTeamsData = xmlDoc.getElementsByTagName("Team");
  2083. var index = 1;
  2084. if (userTeamsData[0].getAttribute("sport") == window.sport) {
  2085. index = 0;
  2086. }
  2087. GM_xmlhttpRequest({
  2088. method: "GET",
  2089. url: "http://www.managerzone.com/xml/team_playerlist.php?sport_id=" + window.sport_id + "&team_id=" + userTeamsData[index].getAttribute("teamId"),
  2090. headers: {
  2091. "Content-Type": "application/json"
  2092. },
  2093. onload: function (response) {
  2094.  
  2095. var parser = new DOMParser();
  2096. var xmlDoc = parser.parseFromString(response.responseText, "text/xml");
  2097. var team_data = xmlDoc.getElementsByTagName("TeamPlayers");
  2098. GM_setValue("currency", team_data[0].getAttribute("teamCurrency"))
  2099. }
  2100. });
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106. }
  2107. });
  2108.  
  2109. }
  2110.  
  2111.  
  2112. }
  2113.  
  2114. function clashLeagues() {
  2115.  
  2116. var urlParams = new URLSearchParams(window.location.search);
  2117.  
  2118. document.getElementById("division-select").addEventListener('change', function () {
  2119. clashLeagues()
  2120. });
  2121.  
  2122.  
  2123. document.getElementById("season-select").addEventListener('change', function () {
  2124. clashLeagues()
  2125. });
  2126.  
  2127.  
  2128.  
  2129.  
  2130. var elems = document.getElementsByClassName("nice_table");
  2131. var tabla = elems[0]
  2132. var thSegundo = tabla.querySelector("thead th:nth-child(2)");
  2133. thSegundo.style.width = "250px";
  2134. var values = new Map();
  2135. values.set('valueLM', 'LM Value');
  2136. values.set('elo', 'ELO Score');
  2137. values.set('teams_count', 'Number of teams');
  2138.  
  2139. var contenidoNuevo = '<div id=testClick><center>'
  2140. getNativeTableStyles();
  2141. var idProgress = "noProgress";
  2142. if (urlParams.get('type') == "senior") {
  2143. idProgress = "divProgress"
  2144. }
  2145.  
  2146. ///MENU TABLE
  2147. contenidoNuevo += "<center><table id=showMenu border=1><thead style='background-color:" + GM_getValue("bg_native") + "; color:" + GM_getValue("color_native") + ";'><tr>";
  2148. contenidoNuevo += '<th align=center style="padding:4px;" colspan="3">Values</th></tr></thead>';
  2149. contenidoNuevo += "<tr>";
  2150. contenidoNuevo += "</tr></table></center>";
  2151. contenidoNuevo += '<table id=show3 border="0"><tr><td><label>';
  2152. contenidoNuevo += '<input class="statsxente" type="checkbox" checked id="value" value="Value">Value</label></td>';
  2153.  
  2154.  
  2155. values.forEach(function (valor, clave) {
  2156. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  2157. });
  2158. contenidoNuevo += "</tr></table></center>"
  2159. contenidoNuevo += "</div></br>";
  2160.  
  2161. values.set('value', 'Value');
  2162. elems = document.getElementsByClassName("nice_table");
  2163. tabla = elems[0]
  2164. tabla.insertAdjacentHTML('beforebegin', contenidoNuevo);
  2165.  
  2166.  
  2167.  
  2168. values.forEach(function (valor, clave) {
  2169.  
  2170. var elemento = document.getElementById(clave);
  2171. elemento.addEventListener('click', handleClickClash);
  2172.  
  2173. });
  2174. var nuevaCeldaEncabezado = document.createElement("th");
  2175. nuevaCeldaEncabezado.textContent = "Value";
  2176. nuevaCeldaEncabezado.style.textAlign = 'center';
  2177. var ser = document.getElementsByClassName("seriesHeader")
  2178. document.getElementsByClassName("nice_table")[0].querySelector('thead').querySelector('tr').appendChild(nuevaCeldaEncabezado);
  2179.  
  2180. nuevaCeldaEncabezado = document.createElement("th");
  2181. nuevaCeldaEncabezado.textContent = "Stats Xente";
  2182. nuevaCeldaEncabezado.style.textAlign = 'center';
  2183. document.getElementsByClassName("nice_table")[0].querySelector('thead').querySelector('tr').appendChild(nuevaCeldaEncabezado);
  2184.  
  2185.  
  2186. var contIds = 0
  2187. var linkIds = ""
  2188. var filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  2189. for (var i = 0; i < filasDatos.length; i++) {
  2190. var celda = tabla.rows[i + 1].cells[1];
  2191. var imagen = celda.querySelector('img');
  2192. var url = new URL(imagen.src);
  2193. var id = url.searchParams.get('fid');
  2194. linkIds += "&id" + contIds + "=" + id
  2195. contIds++
  2196. }
  2197.  
  2198.  
  2199. GM_xmlhttpRequest({
  2200. method: "GET",
  2201. url: "https://statsxente.com/MZ1/Functions/tamper_federations.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + linkIds,
  2202. headers: {
  2203. "Content-Type": "application/json"
  2204. },
  2205. onload: function (response) {
  2206. var jsonResponse = JSON.parse(response.responseText);
  2207. teams_data = jsonResponse;
  2208. var filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  2209. for (var i = 0; i < filasDatos.length; i++) {
  2210. var celda = tabla.rows[i + 1].cells[1];
  2211. var imagen = celda.querySelector('img');
  2212. var url = new URL(imagen.src);
  2213. var id = url.searchParams.get('fid');
  2214. var nuevaColumna = document.createElement("td");
  2215. var valor = 0
  2216.  
  2217. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[id]["value"]))
  2218. nuevaColumna.innerHTML = valor
  2219. nuevaColumna.style.textAlign = 'center';
  2220. filasDatos[i].appendChild(nuevaColumna);
  2221.  
  2222.  
  2223. nuevaColumna = document.createElement("td");
  2224. var iner = "<center><img src='https://statsxente.com/MZ1/View/Images/detail.png' width='20px' height='20px' id='but" + id + "' style='cursor:pointer;'/>";
  2225. iner += "</center>";
  2226. var cat = cats[urlParams.get('type')]
  2227. nuevaColumna.innerHTML = iner
  2228. filasDatos[i].appendChild(nuevaColumna);
  2229.  
  2230.  
  2231. (function (currentId, currentSport, lang) {
  2232. document.getElementById("but" + currentId).addEventListener('click', function () {
  2233.  
  2234. var link = "https://statsxente.com/MZ1/Functions/loadClashFederationDetail.php?tamper=yes&idioma=" +
  2235. lang + "&modal_to_close=myModal&divisa=" + GM_getValue("currency") + "&fid=" + currentId + "&sport=" + currentSport + "&modal=yes";
  2236. openWindow(link, 0.95, 1.25);
  2237. });
  2238. })(id, window.sport, window.lang);
  2239.  
  2240. }
  2241. }
  2242. });
  2243.  
  2244. var thead = document.getElementsByClassName("nice_table")[0].querySelector('thead')
  2245. var ths = thead.querySelectorAll("th");
  2246. ths.forEach(function (th, index) {
  2247. th.addEventListener("click", function () {
  2248. ordenarTabla(index, true, "nice_table",true);
  2249. });
  2250. });
  2251. }
  2252.  
  2253. function handleClickClash(event) {
  2254. var elems = document.getElementsByClassName("nice_table");
  2255. var tabla = elems[0]
  2256. var filas = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  2257. var thSegundo = tabla.querySelector("thead th:nth-child(2)");
  2258. thSegundo.style.width = "250px";
  2259. for (var i = 0; i < filas.length; i++) {
  2260. var celda = tabla.rows[i + 1].cells[1];
  2261. var imagen = celda.querySelector('img');
  2262. var url = new URL(imagen.src);
  2263. var id = url.searchParams.get('fid');
  2264.  
  2265.  
  2266. var celdas = filas[i].getElementsByTagName("td");
  2267. var ultimaCelda = celdas[celdas.length - 2];
  2268.  
  2269. var valor = 0;
  2270.  
  2271. if (teams_data[id] === undefined) {
  2272. valor = 0
  2273. } else {
  2274. if (event.target.id == "edad") {
  2275. valor = new Intl.NumberFormat(window.userLocal, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(teams_data[id][event.target.id])
  2276. } else {
  2277. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(teams_data[id][event.target.id]))
  2278. }
  2279.  
  2280. }
  2281.  
  2282. ultimaCelda.innerHTML = valor;
  2283. }
  2284. var checkboxes = document.querySelectorAll('.statsxente');
  2285. var thead = tabla.querySelector('thead');
  2286. var tr = thead.querySelectorAll('tr');
  2287. var td = tr[0].querySelectorAll('th');
  2288. td[td.length - 2].textContent = event.target.value;
  2289. checkboxes.forEach(function (checkbox) {
  2290. if (checkbox.id !== event.target.id) {
  2291. checkbox.checked = false;
  2292. }
  2293. });
  2294. var columna = 12
  2295. }
  2296.  
  2297. var players = []
  2298. var lines = []
  2299. var gk_line = ""
  2300. var skills_names = []
  2301. var su_line = "unsetted";
  2302.  
  2303. async function playersPageStats() {
  2304. var element = document.getElementById('thePlayers_0');
  2305. var elementos_ = element.getElementsByClassName('p_sublinks');
  2306. var subheaders = element.getElementsByClassName('subheader clearfix');
  2307. var enlace = subheaders[0].querySelector('.subheader a');
  2308. var urlObj = new URL("https://www.managerzone.com/" + enlace.getAttribute('href'));
  2309. var params = new URLSearchParams(urlObj.search);
  2310. var tid = params.get('tid');
  2311. var playerName = enlace.querySelector('.player_name').textContent
  2312. var ids = element.getElementsByClassName('player_id_span');
  2313. var txt = '<span id=but' + ids[0].textContent + ' class="player_icon_placeholder"><a href="#" onclick="return false"'
  2314. txt += 'title="Stats Xente" class="player_icon"><span class="player_icon_wrapper">'
  2315. 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;'
  2316. txt += 'z-index: 0;"></span><span class="player_icon_text"></span></span></a></span>'
  2317. elementos_[0].innerHTML += txt;
  2318. (function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
  2319. document.getElementById("but" + currentId).addEventListener('click', function () {
  2320. var link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
  2321. + "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
  2322. "&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
  2323. openWindow(link, 0.95, 1.25);
  2324. });
  2325. })(ids[0].textContent, tid, window.sport, window.lang, "[undefined]", playerName);
  2326. }
  2327.  
  2328. async function playersPage() {
  2329. setTimeout(function () {
  2330. var elementos = document.getElementsByClassName('playerContainer');
  2331.  
  2332. var player_values = {}
  2333. var tactics_list = []
  2334.  
  2335. var urlParams = new URLSearchParams(window.location.search);
  2336. var flagStats = true
  2337. if (urlParams.has('tid')) {
  2338. flagStats = false
  2339. }
  2340.  
  2341. if (flagStats) {
  2342. var habil_container = elementos[0].getElementsByClassName("player_skills")
  2343. var habil = habil_container[0].getElementsByClassName("clippable")
  2344.  
  2345. if (window.sport == "hockey") {
  2346. for (var q = 1; q < habil.length; q++) {
  2347. skills_names.push(habil[q].textContent)
  2348. }
  2349. } else {
  2350.  
  2351. for (q = 0; q < habil.length - 1; q++) {
  2352. skills_names.push(habil[q].textContent)
  2353. }
  2354.  
  2355. var player_images = document.getElementsByClassName("player-image soccer")
  2356.  
  2357. }
  2358. }
  2359.  
  2360. var ids_ = []
  2361.  
  2362. for (var i = 0; i < elementos.length; i++) {
  2363. var ids = elementos[i].getElementsByClassName('player_id_span');
  2364.  
  2365. var elementos_ = elementos[i].getElementsByClassName('p_sublinks');
  2366.  
  2367. var subheaders = elementos[i].getElementsByClassName('subheader clearfix');
  2368.  
  2369.  
  2370. var enlace = subheaders[0].querySelector('.subheader a');
  2371. var urlObj = new URL("https://www.managerzone.com/" + enlace.getAttribute('href'));
  2372. var params = new URLSearchParams(urlObj.search);
  2373. var tid = params.get('tid');
  2374. var playerName = enlace.querySelector('.player_name').textContent
  2375.  
  2376. ids_.push({ "id": ids[0].textContent, "name": playerName });
  2377.  
  2378.  
  2379. var txt = '<span id=but' + ids[0].textContent + ' class="player_icon_placeholder"><a href="#" onclick="return false"'
  2380. txt += 'title="Stats Xente" class="player_icon"><span class="player_icon_wrapper">'
  2381. 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;'
  2382. txt += 'z-index: 0;"></span><span class="player_icon_text"></span></span></a></span>'
  2383.  
  2384. elementos_[0].innerHTML += txt;
  2385.  
  2386. if (flagStats) {
  2387. var flag_gk = false;
  2388. var age_div = elementos[i].getElementsByClassName('dg_playerview_info');
  2389. var age_table = age_div[0].getElementsByTagName('table')[0];
  2390.  
  2391. var ini_age = age_table.getElementsByTagName('td')[0].textContent.indexOf(":")
  2392. var age = age_table.getElementsByTagName('td')[0].textContent.substring(ini_age + 2, ini_age + 4);
  2393.  
  2394.  
  2395. if ((window.sport == "soccer") && (player_images[i].innerHTML.includes("gk=1"))) {
  2396. flag_gk = true
  2397. }
  2398.  
  2399. var tactics = elementos[i].getElementsByClassName('player_tactic gradientSunriseIcon');
  2400.  
  2401. player_values = {
  2402. "id": ids[0].textContent,
  2403. "skills": [],
  2404. "lines": [],
  2405. "tactics-position": {},
  2406. "tactics": [],
  2407. "age": parseInt(age)
  2408. }
  2409.  
  2410. for (var j = 0; j < tactics.length; j++) {
  2411. var fin = 0;
  2412. var line = ""
  2413. var ini = tactics[j].textContent.indexOf('(');
  2414. var tactic = tactics[j].textContent.substring(0, ini - 1);
  2415.  
  2416. if (window.sport == "hockey") {
  2417.  
  2418. if (!tactics[j].textContent.includes(":")) {
  2419. ini = tactics[j].textContent.indexOf('(');
  2420. fin = tactics[j].textContent.indexOf(')');
  2421. line = tactics[j].textContent.substring(ini + 2, fin - 1);
  2422. gk_line = line;
  2423. } else {
  2424. ini = tactics[j].textContent.indexOf('(');
  2425. fin = tactics[j].textContent.indexOf(':');
  2426. line = tactics[j].textContent.substring(ini + 2, fin);
  2427. }
  2428.  
  2429. } else {
  2430. ini = tactics[j].textContent.indexOf('(');
  2431. fin = tactics[j].textContent.indexOf(')');
  2432. line = tactics[j].textContent.substring(ini + 2, fin - 1);
  2433. if (flag_gk) {
  2434. gk_line = line;
  2435. }
  2436. if (tactics[j].textContent.includes(",")) {
  2437. ini = tactics[j].textContent.indexOf('(');
  2438. fin = tactics[j].textContent.indexOf(',');
  2439. su_line = tactics[j].textContent.substring(ini + 2, fin);
  2440. }
  2441. }
  2442.  
  2443. if (!player_values['lines'].includes(line)) {
  2444. player_values['lines'].push(line);
  2445. }
  2446. if (!player_values['tactics'].includes(tactic)) {
  2447. player_values['tactics'].push(tactic);
  2448. }
  2449.  
  2450. player_values['tactics-position'][tactic] = line
  2451.  
  2452. if ((!lines.includes(line))) {
  2453. lines.push(line);
  2454. }
  2455.  
  2456. if (!tactics_list.includes(tactic)) {
  2457. tactics_list.push(tactic);
  2458. }
  2459.  
  2460.  
  2461. }
  2462. var skills = elementos[i].getElementsByClassName('skillval');
  2463. if (window.sport == "hockey") {
  2464.  
  2465. for (j = 1; j < skills.length; j++) {
  2466. var cleanedText = skills[j].textContent.replace(')', '');
  2467. cleanedText = cleanedText.replace('(', '');
  2468. let number = parseInt(cleanedText, 10);
  2469. player_values['skills'].push(number);
  2470. }
  2471.  
  2472. } else {
  2473. for (j = 0; j < skills.length - 1; j++) {
  2474. cleanedText = skills[j].textContent.replace(')', '');
  2475. cleanedText = cleanedText.replace('(', '');
  2476. let number = parseInt(cleanedText, 10);
  2477. player_values['skills'].push(number);
  2478. }
  2479. }
  2480. players.push(player_values)
  2481. }
  2482. }
  2483.  
  2484. if (flagStats) {
  2485. const container = document.getElementById("squad_tabs")
  2486. var contenidoNuevo = "<div id='containerTactics' style='background-color: #e3e3e3;'></br><center>"
  2487. contenidoNuevo += "<div id=selectDiv>Choose Tactic: <select id=tactics_select>"
  2488. contenidoNuevo += "<option value='All Team'>All Team</option>"
  2489. for (var x = 0; x < tactics_list.length; x++) {
  2490. var selected = ""
  2491. if (x == 0) {
  2492. selected = "selected=''";
  2493. }
  2494. contenidoNuevo += "<option " + selected + " value='" + tactics_list[x] + "'>" + tactics_list[x] + "</option>"
  2495. }
  2496. contenidoNuevo += "</select></div></br><div id=divMenu></div></center></div>"
  2497. container.innerHTML = contenidoNuevo + container.innerHTML;
  2498. skillDistrib(tactics_list[0]);
  2499. document.getElementById("tactics_select").addEventListener('change', function () {
  2500. var select = document.getElementById('tactics_select');
  2501. var valorSeleccionado = select.value;
  2502. document.getElementById("divMenu").innerHTML = ""
  2503. skillDistrib(valorSeleccionado)
  2504. });
  2505. }
  2506.  
  2507.  
  2508.  
  2509.  
  2510. for (i = 0; i < ids_.length; i++) {
  2511. (function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
  2512. document.getElementById("but" + currentId).addEventListener('click', function () {
  2513. var link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
  2514. + "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
  2515. "&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
  2516. openWindow(link, 0.95, 1.25);
  2517. });
  2518. })(ids_[i]['id'], tid, window.sport, window.lang, "[undefined]", ids_[i]['name'],);
  2519. }
  2520.  
  2521.  
  2522.  
  2523. }, 1000);
  2524. }
  2525.  
  2526. function skillDistrib(tactic) {
  2527. var t = tactic
  2528. if (window.sport == "hockey") {
  2529. var l = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  2530. } else {
  2531. l = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  2532. }
  2533.  
  2534. var li_t = {}
  2535. for (var i = 0; i < lines.length; i++) {
  2536. li_t[lines[i]] = [...l];
  2537. }
  2538.  
  2539. var no_gk_line = "Tactic -(" + gk_line + ")"
  2540. li_t["Team"] = [...l];
  2541. li_t["U23"] = [...l];
  2542. li_t["U21"] = [...l];
  2543. li_t["U18"] = [...l];
  2544. li_t["Tactic"] = [...l];
  2545. li_t[no_gk_line] = [...l];
  2546.  
  2547.  
  2548.  
  2549. for (i = 0; i < players.length; i++) {
  2550. if (players[i]['tactics'].includes(t)) {
  2551. for (var j = 0; j < players[i]['skills'].length; j++) {
  2552. li_t[players[i]['tactics-position'][t]][j] += players[i]['skills'][j]
  2553. li_t['Tactic'][j] += players[i]['skills'][j]
  2554. if (players[i]['tactics-position'][t] != "Po") {
  2555. li_t[no_gk_line][j] += players[i]['skills'][j]
  2556. }
  2557. }
  2558. li_t[players[i]['tactics-position'][t]][j] += 1
  2559. li_t['Tactic'][j] += 1
  2560. if (players[i]['tactics-position'][t] != "Po") {
  2561. li_t[no_gk_line][j] += 1
  2562. }
  2563. } else {
  2564.  
  2565. for (j = 0; j < players[i]['skills'].length; j++) {
  2566. if (players[i]['age'] <= 23) {
  2567. li_t['U23'][j] += players[i]['skills'][j]
  2568. }
  2569. if (players[i]['age'] <= 23) {
  2570. li_t['U21'][j] += players[i]['skills'][j]
  2571. }
  2572. if (players[i]['age'] <= 23) {
  2573. li_t['U18'][j] += players[i]['skills'][j]
  2574. }
  2575. li_t['Team'][j] += players[i]['skills'][j]
  2576. }
  2577.  
  2578. if (players[i]['age'] <= 23) {
  2579. li_t['U23'][li_t["U23"].length - 1] += 1
  2580. }
  2581.  
  2582. if (players[i]['age'] <= 21) {
  2583. li_t['U21'][li_t["U21"].length - 1] += 1
  2584. }
  2585. if (players[i]['age'] <= 18) {
  2586. li_t['U18'][li_t["U18"].length - 1] += 1
  2587. }
  2588. li_t['Team'][li_t["Team"].length - 1] += 1
  2589. }
  2590. }
  2591.  
  2592.  
  2593.  
  2594. const container = document.getElementById("divMenu")
  2595. 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>";
  2596. contenidoNuevo += '<th align=center style="padding:4px;">Line</th>'
  2597. for (var q = 0; q < skills_names.length; q++) {
  2598. contenidoNuevo += '<th align=center style="padding:4px;">' + skills_names[q] + '</th>'
  2599. }
  2600. contenidoNuevo += '</tr></thead>';
  2601. var l_aux = lines
  2602. l_aux = l_aux.filter(item => item !== gk_line);
  2603. l_aux.sort((a, b) => {
  2604. let numA = parseInt(a.substring(1), 10);
  2605. let numB = parseInt(b.substring(1), 10);
  2606. return numA - numB;
  2607. });
  2608.  
  2609. l_aux.unshift(gk_line);
  2610. l_aux.push("Tactic");
  2611. l_aux.push(no_gk_line);
  2612.  
  2613. if (window.sport == "hockey") {
  2614. if (li_t["L4"][10] == 0) {
  2615. let index = l_aux.indexOf('L4');
  2616. if (index !== -1) {
  2617. l_aux.splice(index, 1);
  2618. }
  2619. }
  2620. }
  2621.  
  2622. if (t == "All Team") {
  2623. l_aux = ["Team", "U23", "U21", "U18"]
  2624. }
  2625.  
  2626. l_aux = l_aux.filter(item => !item.includes(su_line));
  2627.  
  2628. for (var w = 0; w < l_aux.length; w++) {
  2629. var key = l_aux[w]
  2630. if (li_t.hasOwnProperty(key)) {
  2631. contenidoNuevo += "<tr>";
  2632. contenidoNuevo += "<td align=center style='padding:2px;'><strong>" + key + "</strong></td>";
  2633. for (var x = 0; x < li_t[key].length - 1; x++) {
  2634. contenidoNuevo += "<td align=center style='padding:2px;'>" + Math.round(li_t[key][x] / li_t[key][li_t[key].length - 1] * 100) / 100 + "</td>";
  2635. }
  2636. contenidoNuevo += "</tr>";
  2637.  
  2638. }
  2639. }
  2640. container.innerHTML += contenidoNuevo;
  2641. }
  2642.  
  2643. function countryRank() {
  2644. var table_values = ["players", "age", "value", "top11", "salary", "elo", "elo21", "lm", "lmu21"]
  2645. var newContent = "<center><div>";
  2646. newContent += '<label><input class="statsxente" type="checkbox" checked id="value" value="Value">Value</label>';
  2647. if (window.sport == "soccer") {
  2648. newContent += '<label><input class="statsxente" type="checkbox" id="top11" value="TOP 11">TOP 11</label>';
  2649. } else {
  2650. newContent += '<label><input class="statsxente" type="checkbox" id="top11" value="TOP 21">TOP 21</label>';
  2651. }
  2652.  
  2653. newContent += '<label><input class="statsxente" type="checkbox" id="players" value="Players">Players</label>';
  2654. newContent += '<label><input class="statsxente" type="checkbox" id="salary" value="Salary">Salary</label>';
  2655. newContent += '<label><input class="statsxente" type="checkbox" id="age" value="Age">Age</label>';
  2656. newContent += '<label><input class="statsxente" type="checkbox" checked id="elo" value="Elo">ELO</label>';
  2657. newContent += '<label><input class="statsxente" type="checkbox" checked id="elo21" value="U21 ELO">U21 ELO</label>';
  2658. newContent += '<label><input class="statsxente" type="checkbox" checked id="lm" value="LM">LM</label>';
  2659. newContent += '<label><input class="statsxente" type="checkbox" checked id="lmu21" value="U21 LM">U21 LM</label>';
  2660.  
  2661. var contenedor = document.getElementById('countryRankTable');
  2662. contenedor.insertAdjacentHTML('beforebegin', newContent);
  2663.  
  2664. GM_xmlhttpRequest({
  2665. method: "GET",
  2666. url: "https://statsxente.com/MZ1/Functions/tamper_national_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport,
  2667. headers: {
  2668. "Content-Type": "application/json"
  2669. },
  2670. onload: function (response) {
  2671. var jsonResponse = JSON.parse(response.responseText);
  2672. var data = jsonResponse;
  2673.  
  2674. var type = 1;
  2675. if (window.sport == "soccer") {
  2676. type = 2
  2677. }
  2678. var table = document.getElementById('countryRankTable');
  2679. for (var i = 0; i < table.rows.length; i++) {
  2680. var row = table.rows[i];
  2681. var insertIndex = row.cells.length - 1;
  2682. var raw_str = row.cells[3].innerHTML
  2683. row.deleteCell(3);
  2684. var cell_name = row.cells[2]
  2685. if (i > 0) {
  2686. cell_name.innerHTML = raw_str + " " + cell_name.innerHTML
  2687. }
  2688. var index = 0;
  2689. var cell0 = row.insertCell(insertIndex + index);
  2690. index++;
  2691. var cell1 = row.insertCell(insertIndex + index);
  2692. index++;
  2693. var cell2 = row.insertCell(insertIndex + index);
  2694. index++;
  2695. var cell3 = row.insertCell(insertIndex + index);
  2696. index++;
  2697. var cell4 = row.insertCell(insertIndex + index);
  2698. index++;
  2699. var cell5 = row.insertCell(insertIndex + index);
  2700. index++;
  2701. var cell6 = row.insertCell(insertIndex + index);
  2702. index++;
  2703. var cell7 = row.insertCell(insertIndex + index);
  2704. index++;
  2705. var cell8 = row.insertCell(insertIndex + index);
  2706. index++;
  2707. var cell9 = row.insertCell(insertIndex + index);
  2708.  
  2709.  
  2710.  
  2711. if (i === 0) {
  2712. cell0.outerHTML = "<th id='players_th' style='display:none;' class='header'><a href='#'>Players</a></th>";
  2713. cell1.outerHTML = "<th id='age_th' class='header' style='display:none;'><a href='#'>Age</a></th>";
  2714. cell2.outerHTML = "<th id='value_th' class='header' style='display:table-cell;'><a href='#'>Value</a></th>";
  2715. cell3.outerHTML = "<th id='top11_th' class='header' style='display:none;'><a href='#'>Top11</a></th>";
  2716. cell4.outerHTML = "<th id='salary_th' class='header' style='display:none;'><a href='#'>Salary</a></th>";
  2717. cell5.outerHTML = "<th id='elo_th' class='header' style='display:table-cell;'><a href='#'>ELO</a></th>";
  2718. cell6.outerHTML = "<th id='elo21_th' class='header' style='display:table-cell;'><a href='#'>U21 ELO</a></th>";
  2719. cell7.outerHTML = "<th id='lm_th' class='header' style='display:table-cell;'><a href='#'>LM</a></th>";
  2720. cell8.outerHTML = "<th id='lmu21_th' class='header' style='display:table-cell;'><a href='#'>U21 LM</a></th>";
  2721. cell9.outerHTML = "<th id='image' class='header' style='display:table-cell;'><a href='#'></a></th>";
  2722. } else {
  2723. var ini = raw_str.indexOf("s_");
  2724. var fin = raw_str.indexOf(".", ini + 1);
  2725. var c_code = raw_str.substring(ini + 2, fin)
  2726. cell0.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["numJugadores"]))
  2727. cell0.className = "players"
  2728. cell0.style.display = "none"
  2729.  
  2730. cell1.innerHTML = new Intl.NumberFormat(window.userLocal, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(data[c_code]["edad"])
  2731. cell1.className = "age"
  2732. cell1.style.display = "none"
  2733.  
  2734. cell2.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valor"]))
  2735. cell2.className = "value"
  2736. cell2.style.display = "table-cell"
  2737.  
  2738. cell3.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valor11"]))
  2739. cell3.className = "top11"
  2740. cell3.style.display = "none"
  2741.  
  2742. cell4.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["salario"]))
  2743. cell4.className = "salary"
  2744. cell4.style.display = "none"
  2745.  
  2746. cell5.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["elo"]))
  2747. cell5.className = "elo"
  2748. cell5.style.display = "table-cell"
  2749.  
  2750. cell6.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["elo21"]))
  2751. cell6.className = "elo21"
  2752. cell6.style.display = "table-cell"
  2753.  
  2754. cell7.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valorLM"]))
  2755. cell7.className = "lm"
  2756. cell7.style.display = "table-cell"
  2757.  
  2758. cell8.innerHTML = new Intl.NumberFormat(window.userLocal).format(Math.round(data[c_code]["valorLM21"]))
  2759. cell8.className = "lmu21"
  2760. cell8.style.display = "table-cell"
  2761.  
  2762. cell9.innerHTML = '<img style="cursor:pointer;" src="https://statsxente.com/MZ1/View/Images/calendar.png" width="20" height="20">'
  2763. var actual_id = "image" + i
  2764. cell9.id = actual_id
  2765. cell9.style.display = "table-cell";
  2766.  
  2767.  
  2768. (function (id, code, type_) {
  2769. document.getElementById(id).addEventListener('click', function () {
  2770. var link = "https://www.statsxente.com/MZ1/Graficos/graficoRachaEquipoELONT.php?tamper=yes&team_id=" + data[code]["idSenior"] +
  2771. "&team_id_u21=" + data[code]["idSub21"] + "&idioma=" + window.lang + "&type=" + type_ + "&cat=SENIOR&sport=" + window.sport;
  2772. openWindow(link, 0.95, 1.25);
  2773. });
  2774. })(actual_id, c_code, type);
  2775. }
  2776. }
  2777.  
  2778. setTimeout(function () {
  2779. for (var f = 0; f < table_values.length; f++) {
  2780.  
  2781. (function (actual_value, f) {
  2782.  
  2783. document.getElementById(actual_value + "_th").addEventListener('click', function () {
  2784. if (document.getElementById(actual_value + "_th").className == "header") {
  2785. document.getElementById(actual_value + "_th").className = "header headerSortDown";
  2786. } else {
  2787.  
  2788. if (document.getElementById(actual_value + "_th").className == "header headerSortDown") {
  2789. document.getElementById(actual_value + "_th").className = "header headerSortUp";
  2790. } else {
  2791. document.getElementById(actual_value + "_th").className = "header headerSortDown";
  2792. }
  2793.  
  2794. }
  2795. var index_ = 3 + f
  2796. ordenarTabla(index_, false, "countryRankTable",false)
  2797. });
  2798. document.getElementById(actual_value).addEventListener('click', function () {
  2799. var display = "table-cell"
  2800. if (document.getElementById(actual_value + "_th").style.display == "table-cell") {
  2801. display = "none"
  2802. }
  2803. var elementos = document.getElementsByClassName(actual_value)
  2804. Array.prototype.forEach.call(elementos, function (elemento) {
  2805. var aux_display = "table-cell"
  2806. if (document.getElementById(actual_value + "_th").style.display == "table-cell") {
  2807. aux_display = "none"
  2808. }
  2809. elemento.style.display = aux_display;
  2810. });
  2811. document.getElementById(actual_value + "_th").style.display = display
  2812. });
  2813. })(table_values[f], f);
  2814. }
  2815. }, 1000);
  2816. }
  2817. });
  2818. }
  2819.  
  2820. function nextMatchesClubhouse() {
  2821. var h1Elements = document.querySelectorAll('h1.box_dark');
  2822. var team_name = h1Elements[0].innerText
  2823. var team_id = document.getElementById("tid1").value;
  2824.  
  2825. GM_xmlhttpRequest({
  2826. method: "GET",
  2827. url: "https://statsxente.com/MZ1/Functions/tamper_user_next_matches.php?team_id=" + team_id,
  2828. headers: {
  2829. "Content-Type": "application/json"
  2830. },
  2831. onload: function (response) {
  2832. var jsonResponse = JSON.parse(response.responseText);
  2833. var data = jsonResponse;
  2834. if (data.length > 0) {
  2835. GM_xmlhttpRequest({
  2836. method: "GET",
  2837. url: "http://www.managerzone.com/xml/team_matchlist.php?sport_id=" + window.sport_id + "&team_id=" + team_id + "&match_status=2&limit=100",
  2838. headers: {
  2839. "Content-Type": "application/json"
  2840. },
  2841. onload: function (response) {
  2842.  
  2843. var matchesDate = []
  2844. var parser = new DOMParser();
  2845. var xmlDoc = parser.parseFromString(response.responseText, "text/xml");
  2846. var matches = xmlDoc.getElementsByTagName("Match");
  2847.  
  2848. var last_date = ""
  2849.  
  2850.  
  2851. for (var i = 0; i < matches.length; i++) {
  2852. var dateOnly = matches[i].getAttribute("date").split(" ")[0];
  2853. last_date = dateOnly
  2854. var teams = matches[i].getElementsByTagName("Team");
  2855.  
  2856. for (var j = 0; j < teams.length; j++) {
  2857. if (teams[j].getAttribute("teamId") != team_id) {
  2858. matchesDate.push(teams[j].getAttribute("teamId") + "-" + dateOnly)
  2859.  
  2860. }
  2861. }
  2862.  
  2863.  
  2864. }
  2865.  
  2866.  
  2867.  
  2868.  
  2869. var newContent = `
  2870. <div id="tour-container" class="widgets-container">
  2871. <div class="flex-wrap hub-widget-container">
  2872. <div class="flex-grow-1 box_dark">
  2873. <div id="clubhouse-widget-tour" class="widget-content clearfix">
  2874. <i class="fa minimize-button fa-minus-square" aria-hidden="true" data-time="1722549599"></i>
  2875. <span class="fa fa-stack fa-2x floatRight">
  2876. <i class="fa fa-circle fa-stack-2x fa-inverse"></i>
  2877. <i class="fa fa-thumbs-up fa-stack-1x green" aria-hidden="true"></i>
  2878. </span>
  2879. <h3 style="background-image: url('https://www.statsxente.com/MZ1/View/Images/etiqueta_bota.png');">Stats Xente</h3>
  2880. <div class="widget-content-wrapper">
  2881. <div class="flex-wrap" style="margin-bottom: 35px;">
  2882. <div class="flex-grow-0" style="margin: 0 auto">
  2883. <img src="https://www.statsxente.com/MZ1/View/Images/etiqueta_bota.png" alt="" width="114" height="127">
  2884. </div>
  2885. <div class="flex-grow-1 textLeft">`
  2886.  
  2887. data.forEach(function (match_data) {
  2888.  
  2889. var dateObj1 = new Date(last_date);
  2890. var dateObj2 = new Date(match_data['fecha']);
  2891.  
  2892.  
  2893. var icon_ = "fa-check-square"
  2894. var style_ = ""
  2895. var flagFriendly = false;
  2896. if (dateObj1 < dateObj2) {
  2897. icon_ = "fa-calendar-minus-o"
  2898. style_ = "style='color:#e5ac00;'"
  2899. flagFriendly = true;
  2900. } else {
  2901.  
  2902. if (matchesDate.includes(match_data['rival_id'] + "-" + match_data['fecha'])) {
  2903. if (window.sport == "hockey") {
  2904. style_ = "style='color:#6d93fd;'"
  2905. }
  2906. } else {
  2907. icon_ = "fa-times-square"
  2908. style_ = "style='color:#AD4039;'"
  2909. flagFriendly = true;
  2910.  
  2911.  
  2912. }
  2913.  
  2914. }
  2915.  
  2916.  
  2917. var match = '<img src="https://www.managerzone.com/dynimg/badge.php?team_id=' + match_data['idEquipoLocal'] + '&sport="' + window.sport + ' width="15px" height="15px"/> '
  2918. + 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"/>'
  2919. if (match_data['field'] == "away") {
  2920. match = '<img src="https://www.managerzone.com/dynimg/badge.php?team_id=' + match_data['idEquipoLocal'] + '&sport="' + window.sport + ' width="15px" height="15px"/> '
  2921. + 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"/>'
  2922. }
  2923.  
  2924.  
  2925. newContent += '<fieldset class="grouping self box_light_on_dark flex-nowrap" style="max-width: 555px; margin-left: 10px;">'
  2926. newContent += '<legend>' + match_data['clash_name'] + '</legend>'
  2927. newContent += '<div class="flex-grow-0 mission-icon">'
  2928. newContent += '<i class="fa ' + icon_ + ' green fa-2x t-checked" aria-hidden="true" ' + style_ + '></i>'
  2929. newContent += '</div>'
  2930. newContent += '<div class="flex-grow-1 mission">'
  2931.  
  2932. var link = "CompAmis_CALENDAR_View.php?" + 'id=' + match_data['idComp']
  2933. if (match_data['comp'] == "cup") {
  2934. link = 'CompAmis_Cup_CALENDAR_View.php?grupo=' + match_data['grupo'] + '&id=' + match_data['idComp']
  2935. }
  2936.  
  2937.  
  2938. newContent += '<p><b><a href="https://www.statsxente.com/MZ1/View/' + link + '" target="_blank">' + match + '</a></b>'
  2939. newContent += "</br></p>"
  2940. newContent += 'Date: ' + match_data['fecha']
  2941. if (flagFriendly) {
  2942. 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>"
  2943. }
  2944.  
  2945.  
  2946. newContent += '</p>'
  2947. newContent += '</div>'
  2948. newContent += '</fieldset>'
  2949. });
  2950.  
  2951.  
  2952.  
  2953.  
  2954. newContent += `</div>
  2955. </div>
  2956. </div>
  2957. </div>
  2958. </div>
  2959. </div>
  2960. </div>`;
  2961.  
  2962.  
  2963.  
  2964.  
  2965. var contenedor = document.getElementById('tour-container');
  2966. if (data.length > 0) {
  2967. contenedor.insertAdjacentHTML('beforebegin', newContent);
  2968.  
  2969. }
  2970.  
  2971.  
  2972. }
  2973.  
  2974. });
  2975.  
  2976. }
  2977.  
  2978.  
  2979. }
  2980. });
  2981.  
  2982. }
  2983.  
  2984. function checkClassNameExists(element, className) {
  2985.  
  2986. if (className == "") {
  2987. return true;
  2988. } else {
  2989. return element.classList.contains(className);
  2990. }
  2991. return false;
  2992.  
  2993. }
  2994.  
  2995. function fetchAgeRestriction(url) {
  2996. return new Promise((resolve, reject) => {
  2997.  
  2998. GM_xmlhttpRequest({
  2999. method: "GET",
  3000. url: url,
  3001. headers: {
  3002. "Content-Type": "application/json"
  3003. },
  3004. onload: function (response) {
  3005. var parser = new DOMParser();
  3006. var doc = parser.parseFromString(response.responseText, "text/html");
  3007. var strongElements = doc.getElementsByTagName("b");
  3008. var nextElement = strongElements[1].nextElementSibling;
  3009. var nextSibling = strongElements[1].nextSibling;
  3010. try {
  3011. while (nextSibling && nextSibling.nodeName === "BR") {
  3012. nextSibling = nextSibling.nextSibling;
  3013. }
  3014.  
  3015. if (nextSibling && nextSibling.nodeType === Node.TEXT_NODE) {
  3016. var age_restriction = nextSibling.textContent.trim();
  3017. resolve(age_restriction);
  3018. } else {
  3019. resolve("none");
  3020. }
  3021. } catch (error) {
  3022. reject("none");
  3023. }
  3024. },
  3025. onerror: function (error) {
  3026. reject("none");
  3027. }
  3028. });
  3029. });
  3030. }
  3031.  
  3032. function fetchCupAgeRestriction(url) {
  3033. return new Promise((resolve, reject) => {
  3034.  
  3035. GM_xmlhttpRequest({
  3036. method: "GET",
  3037. url: url,
  3038. headers: {
  3039. "Content-Type": "application/json"
  3040. },
  3041. onload: function (response) {
  3042. var parser = new DOMParser();
  3043. try {
  3044. var doc = parser.parseFromString(response.responseText, "text/html")
  3045. var tables = doc.getElementsByTagName("table");
  3046. var table = tables[1]
  3047. var tds = table.getElementsByTagName("td");
  3048. resolve(tds[5].innerHTML)
  3049. } catch (error) {
  3050. reject("none");
  3051. }
  3052. },
  3053. onerror: function (error) {
  3054. reject("none");
  3055. }
  3056. });
  3057. });
  3058. }
  3059.  
  3060. async function friendlyCupsAndLeagues() {
  3061. var urlParams = new URLSearchParams(window.location.search);
  3062. var age_restriction = "none"
  3063. var link = "https://www.managerzone.com" + document.getElementById("ui-id-1").getAttribute('href')
  3064. if (urlParams.get('fsid')) {
  3065. age_restriction = await fetchAgeRestriction(link);
  3066. } else {
  3067. age_restriction = await fetchCupAgeRestriction(link);
  3068. }
  3069.  
  3070. var detected_cat = "senior"
  3071.  
  3072. if (age_restriction !== "none") {
  3073.  
  3074.  
  3075. switch (age_restriction) {
  3076. case "U23":
  3077. detected_cat = "u23"
  3078. break;
  3079. case "U21":
  3080. detected_cat = "u21"
  3081. break;
  3082. case "U18":
  3083. detected_cat = "u18"
  3084. break;
  3085. }
  3086.  
  3087. }
  3088.  
  3089.  
  3090.  
  3091. var initialValues = {};
  3092. initialValues["senior"] = GM_getValue("league_default_senior");
  3093. initialValues["world"] = GM_getValue("league_default_senior");
  3094. initialValues["u23"] = GM_getValue("league_default_u23");
  3095. initialValues["u21"] = GM_getValue("league_default_u21");
  3096. initialValues["u18"] = GM_getValue("league_default_u18");
  3097. initialValues["u23_world"] = GM_getValue("league_default_u23");
  3098. initialValues["u21_world"] = GM_getValue("league_default_u21");
  3099. initialValues["u18_world"] = GM_getValue("league_default_u18");;
  3100.  
  3101. var linkIds = ""
  3102. var elems = document.getElementsByClassName("nice_table");
  3103. var tabla = elems[0]
  3104. var thSegundo = tabla.querySelector("thead th:nth-child(2)");
  3105. thSegundo.style.width = "250px";
  3106.  
  3107.  
  3108. var values = new Map();
  3109. values.set('valor23', 'U23 Value');
  3110. values.set('valor21', 'U21 Value');
  3111. values.set('valor18', 'U18 Value');
  3112. values.set('salario', 'Salary');
  3113. values.set('valorUPSenior', 'LM Value');
  3114. values.set('valorUPSUB23', 'U23 LM Value');
  3115. values.set('valorUPSUB21', 'U21 LM Value');
  3116. values.set('valorUPSUB18', 'U18 LM Value');
  3117. values.set('edad', 'Age');
  3118. if (window.sport == "soccer") {
  3119. values.set('valor11', 'TOP 11');
  3120. values.set('valor11_23', 'U23 TOP 11');
  3121. values.set('valor11_21', 'U21 TOP 11');
  3122. values.set('valor11_18', 'U18 TOP 11');
  3123. } else {
  3124. values.set('valor11', 'TOP 21');
  3125. values.set('valor11_23', 'U23 TOP 21');
  3126. values.set('valor11_21', 'U21 TOP 21');
  3127. values.set('valor11_18', 'U18 TOP 21');
  3128. }
  3129.  
  3130. values.set('noNac', 'Foreigners');
  3131. values.set('elo', 'ELO Score');
  3132. values.set('elo23', 'U23 ELO Score');
  3133. values.set('elo21', 'U21 ELO Score');
  3134. values.set('elo18', 'U18 ELO Score');
  3135. values.set('numJugadores', 'Number of players');
  3136. values.set('leagues', 'Leagues');
  3137. values.set('world_leagues_all', 'World Leagues');
  3138. values.set('youth_leagues_all', 'Youth Leagues');
  3139. values.set('world_youth_leagues_all', 'Youth World Leagues');
  3140. values.set('federation_leagues', 'Federation Leagues');
  3141. values.set('cup', 'Cups');
  3142. values.set('cup_u23', 'U23 Cups');
  3143. values.set('cup_u21', 'U21 Cups');
  3144. values.set('cup_u18', 'U18 Cups');
  3145. values.set('special_cup', 'Special Cups');
  3146.  
  3147. var contenidoNuevo = '<div id=testClick><center>'
  3148.  
  3149.  
  3150. getNativeTableStyles();
  3151.  
  3152. var idProgress = "noProgress";
  3153. if (urlParams.get('type') == "senior") {
  3154. idProgress = "divProgress"
  3155. }
  3156.  
  3157.  
  3158. var widthTable = "1.5em"
  3159. ///MENU TABLE
  3160. contenidoNuevo += "<center><table id=showMenu border=0><thead style='background-color:" + GM_getValue("bg_native") + "; color:" + GM_getValue("color_native") + ";'><tr>";
  3161. contenidoNuevo += '<th align=center style="padding:4px;" colspan="4">Stats Xente</th>';
  3162. contenidoNuevo += "</tr></thead>";
  3163. var styleTable = " style='display:none;'";
  3164. var styleIcon = ""
  3165. var styleSep = "style='padding-top:5px;'";
  3166.  
  3167. if (GM_getValue("show_league_selects") == true) {
  3168. styleTable = "";
  3169. styleIcon = " active"
  3170. styleSep = " style='display:none;'";
  3171.  
  3172. }
  3173.  
  3174.  
  3175. contenidoNuevo += "<tr><td></td><td style='padding-top:5px' colspan='2'>";
  3176.  
  3177. 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>';
  3178.  
  3179. contenidoNuevo += "</td><td></td></tr>";
  3180.  
  3181. contenidoNuevo += "<tr><td colspan='5' id='separatorTd'" + styleSep + "></td></tr>";
  3182.  
  3183.  
  3184.  
  3185. contenidoNuevo += "</table></center>";
  3186.  
  3187.  
  3188.  
  3189. contenidoNuevo += '<table id=show3 border="0"' + styleTable + '><tr><td><label>';
  3190.  
  3191. if ((urlParams.get('type') == 'senior') || (urlParams.get('type') == 'world')) {
  3192. if ("valor" == initialValues[detected_cat]) {
  3193. contenidoNuevo += '<input class="statsxente" type="checkbox" checked id="valor" value="Value">Value</label></td>';
  3194. } else {
  3195. contenidoNuevo += '<input class="statsxente" type="checkbox" id="valor" value="Value">Value</label></td>';
  3196. }
  3197. } else {
  3198. contenidoNuevo += '<input class="statsxente" type="checkbox" id="valor" value="Value">Value</label></td>';
  3199. }
  3200.  
  3201. values.forEach(function (valor, clave) {
  3202.  
  3203. if (clave == "valorUPSenior") {
  3204. contenidoNuevo += "</tr><tr>";
  3205. }
  3206.  
  3207. if (clave == "valor11") {
  3208. contenidoNuevo += "</tr><tr>";
  3209. }
  3210. if (clave == "elo") {
  3211. contenidoNuevo += "</tr><tr>";
  3212. }
  3213.  
  3214. if (clave == "leagues") {
  3215. contenidoNuevo += "</tr><tr>";
  3216. }
  3217.  
  3218. if (clave == "leagues_all") {
  3219. contenidoNuevo += "</tr><tr>";
  3220. }
  3221.  
  3222. if (clave == "cup") {
  3223. contenidoNuevo += "</tr><tr>";
  3224. }
  3225.  
  3226. if (clave == initialValues[detected_cat]) {
  3227. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" checked value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  3228. } else {
  3229. contenidoNuevo += '<td><label><input class="statsxente" type="checkbox" value="' + valor + '" id="' + clave + '">' + valor + '</label></td>';
  3230. }
  3231. });
  3232. contenidoNuevo += "</tr></table></center>"
  3233. contenidoNuevo += "</div></br>";
  3234.  
  3235.  
  3236. values.set('valor', 'Value');
  3237.  
  3238. elems = document.getElementsByClassName("nice_table");
  3239. tabla = elems[0]
  3240.  
  3241.  
  3242. tabla.insertAdjacentHTML('beforebegin', contenidoNuevo);
  3243.  
  3244. if (GM_getValue("show_league_selects") == true) {
  3245.  
  3246. document.getElementById("line2").style.transform = 'rotateZ(0deg)';
  3247. document.getElementById("line1").style.transform = 'rotateZ(180deg)';
  3248. document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
  3249. }
  3250.  
  3251.  
  3252. values.forEach(function (valor, clave) {
  3253.  
  3254. var elemento = document.getElementById(clave);
  3255. elemento.addEventListener('click', handleClick);
  3256.  
  3257. });
  3258. var nuevaCeldaEncabezado = document.createElement("th");
  3259. nuevaCeldaEncabezado.textContent = values.get(initialValues[detected_cat]);
  3260. nuevaCeldaEncabezado.style.textAlign = 'center';
  3261. nuevaCeldaEncabezado.style.maxWidth = '7.5em';
  3262. nuevaCeldaEncabezado.style.width = '7.5em';
  3263. nuevaCeldaEncabezado.style.whiteSpace = 'nowrap';
  3264. nuevaCeldaEncabezado.style.overflow = 'hidden';
  3265. nuevaCeldaEncabezado.style.textOverflow = 'ellipsis';
  3266.  
  3267. var ser = document.getElementsByClassName("seriesHeader")
  3268.  
  3269.  
  3270. var table_index = 0;
  3271. for (var kl = 0; kl < ser.length; kl++) {
  3272. if (document.getElementsByClassName("seriesHeader")[kl].parentNode.parentNode.className == "nice_table") {
  3273. table_index = kl
  3274. }
  3275.  
  3276.  
  3277. }
  3278.  
  3279. document.getElementsByClassName("seriesHeader")[table_index].cells[1].style.width = "180px"
  3280. document.getElementsByClassName("seriesHeader")[table_index].appendChild(nuevaCeldaEncabezado);
  3281.  
  3282. nuevaCeldaEncabezado = document.createElement("th");
  3283. nuevaCeldaEncabezado.textContent = "Stats Xente";
  3284. nuevaCeldaEncabezado.style.textAlign = 'center';
  3285. ser = document.getElementsByClassName("seriesHeader")
  3286. document.getElementsByClassName("seriesHeader")[table_index].appendChild(nuevaCeldaEncabezado);
  3287.  
  3288.  
  3289. if (tabla.getElementsByTagName("tbody")[0].innerHTML.includes("mazyar")) {
  3290. searchClassName = "responsive-hide"
  3291. }
  3292.  
  3293. var contIds = 0
  3294. var filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  3295. for (var i = 0; i < filasDatos.length; i++) {
  3296. if (checkClassNameExists(tabla.rows[i + 1], searchClassName)) {
  3297. var celda = tabla.rows[i + 1].cells[1];
  3298. var equipo = celda.textContent.trim()
  3299. var iniIndex = celda.innerHTML.indexOf("tid=");
  3300. var lastIndex = celda.innerHTML.indexOf("\">", iniIndex + 4);
  3301. var data = String(celda.innerHTML)
  3302. var id = data.substring(iniIndex + 4, lastIndex)
  3303. linkIds += "&idEquipo" + contIds + "=" + id
  3304. contIds++
  3305. celda.innerHTML += "<input type='hidden' id='team_" + id + "' value='" + equipo + "'/>"
  3306. }
  3307.  
  3308. }
  3309.  
  3310.  
  3311.  
  3312. ///DIV PROGRESS
  3313. setTimeout(function () {
  3314.  
  3315.  
  3316. (function () {
  3317. document.getElementById("moreInfo").addEventListener('click', function () {
  3318. document.getElementById("moreInfo").classList.toggle('active');
  3319.  
  3320. if (document.getElementById("moreInfo").classList.contains("active")) {
  3321. document.getElementById("line2").style.transform = 'rotateZ(0deg)';
  3322. document.getElementById("line1").style.transform = 'rotateZ(180deg)';
  3323. document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
  3324. $('#separatorTd').fadeOut(1);
  3325. document.getElementById("separatorTd").style.paddingTop = "5px";
  3326. $('#show3').fadeIn('slow');
  3327. } else {
  3328. document.getElementById("line2").style.transform = 'rotateZ(45deg)';
  3329. document.getElementById("line1").style.transform = 'rotateZ(-45deg)';
  3330. document.getElementById("moreInfo").style.transform = 'rotateZ(45deg)';
  3331. $('#separatorTd').fadeIn(1);
  3332. $('#show3').fadeOut('slow');
  3333. }
  3334.  
  3335.  
  3336.  
  3337. });
  3338. })();
  3339.  
  3340. }, 200);
  3341.  
  3342. GM_xmlhttpRequest({
  3343. method: "GET",
  3344. url: "https://statsxente.com/MZ1/Functions/tamper_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + linkIds,
  3345. headers: {
  3346. "Content-Type": "application/json"
  3347. },
  3348. onload: function (response) {
  3349. var jsonResponse = JSON.parse(response.responseText);
  3350. teams_data = jsonResponse;
  3351. var filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  3352. for (var i = 0; i < filasDatos.length; i++) {
  3353. if (checkClassNameExists(filasDatos[i], searchClassName)) {
  3354. var celda = filasDatos[i].cells[1]
  3355. var equipo = celda.textContent.trim()
  3356. var iniIndex = celda.innerHTML.indexOf("tid=");
  3357. var lastIndex = celda.innerHTML.indexOf("\">", iniIndex + 4);
  3358. var data = String(celda.innerHTML)
  3359. var id = data.substring(iniIndex + 4, lastIndex)
  3360. var nuevaColumna = document.createElement("td");
  3361. var valor = 0;
  3362.  
  3363. if (jsonResponse[id] && jsonResponse[id][initialValues[detected_cat]] !== undefined) {
  3364. valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[id][initialValues[detected_cat]]))
  3365. }
  3366. nuevaColumna.innerHTML = valor
  3367. nuevaColumna.style.textAlign = 'center';
  3368. filasDatos[i].appendChild(nuevaColumna);
  3369.  
  3370. var eloType = 1
  3371. if (window.sport == "soccer") { eloType = 2 }
  3372. var cats_elo = {}
  3373. cats_elo["senior"] = "SENIOR";
  3374. cats_elo["seniorw"] = "SENIOR";
  3375. cats_elo["SUB23"] = "U23";
  3376. cats_elo["SUB21"] = "U21";
  3377. cats_elo["SUB18"] = "U18";
  3378. cats_elo["SUB23w"] = "U23";
  3379. cats_elo["SUB21w"] = "U21";
  3380. cats_elo["SUB18w"] = "U18";
  3381.  
  3382. var cat = cats[detected_cat]
  3383.  
  3384.  
  3385. var flagSenior = 0, flagSub23 = 0, flagSub21 = 0, flagSub18 = 0;
  3386. if (jsonResponse[id]["elo"] > 0) { flagSenior = 1 }
  3387. if (jsonResponse[id]["elo23"] > 0) { flagSub23 = 1 }
  3388. if (jsonResponse[id]["elo21"] > 0) { flagSub21 = 1 }
  3389. if (jsonResponse[id]["elo18"] > 0) { flagSub18 = 1 }
  3390.  
  3391. var buttonDisplay = "display:block;";
  3392. nuevaColumna = document.createElement("td");
  3393. 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;'/>";
  3394. if (GM_getValue("league_graph_button") == "checked") {
  3395. buttonDisplay = ""
  3396. } else {
  3397. buttonDisplay = "display:none;";
  3398. }
  3399. 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 + "'/>";
  3400.  
  3401. if (GM_getValue("league_report_button") == "checked") {
  3402. buttonDisplay = ""
  3403. } else {
  3404. buttonDisplay = "display:none;";
  3405. }
  3406. 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 + "'/>";
  3407.  
  3408. if (GM_getValue("league_calendar_button") == "checked") {
  3409. buttonDisplay = ""
  3410. } else {
  3411. buttonDisplay = "display:none;";
  3412. }
  3413. 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 + "'/>";
  3414. iner += "</center>";
  3415.  
  3416. nuevaColumna.innerHTML = iner
  3417. filasDatos[i].appendChild(nuevaColumna);
  3418. nuevaColumna = document.createElement("td");
  3419. (function (currentId, currentLSport, lang) {
  3420. document.getElementById("but1" + currentId).addEventListener('click', function () {
  3421. var link = "https://statsxente.com/MZ1/Graficos/graficoProgresoEquipo.php?idEquipo=" + currentId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") + "&deporte=" + currentLSport;
  3422. openWindow(link, 0.95, 1.25);
  3423. });
  3424. })(id, window.lsport, window.lang);
  3425.  
  3426.  
  3427. (function (currentId, currentLSport, lang, currentCat) {
  3428. document.getElementById("but2" + currentId).addEventListener('click', function () {
  3429. var src = "filtroGraficoEquiposHistoricoHockey";
  3430. if (currentLSport == "F") {
  3431. src = "filtroGraficoLinealEquiposHistorico";
  3432. }
  3433.  
  3434. 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=-"
  3435. openWindow(link, 0.95, 1.25);
  3436. });
  3437. })(id, window.lsport, window.lang, cat);
  3438.  
  3439.  
  3440. (function (currentId, currentEquipo, currentCat, currentSport, lang) {
  3441. document.getElementById("but" + currentId).addEventListener('click', function () {
  3442. 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";
  3443. openWindow(link, 0.95, 1.25);
  3444. });
  3445. })(id, equipo, cat, window.sport, window.lang);
  3446.  
  3447.  
  3448.  
  3449.  
  3450. (function (currentId, type, currentCat, currentSport, lang, flagS, flagS23, flagS21, flagS18) {
  3451. document.getElementById("but3" + currentId).addEventListener('click', function () {
  3452. var link = "https://statsxente.com/MZ1/Graficos/graficoRachaEquipoELO.php?tamper=yes&team_id=" + currentId + "&idioma=" + lang + "&deporte=" + currentSport + "&type=" + type + "&cat=" + currentCat + "&flagSenior=" +
  3453. flagS + "&flagSub23=" + flagS23 + "&flagSub21=" + flagS21 + "&flagSub18=" + flagS18;
  3454. openWindow(link, 0.95, 1.25);
  3455. });
  3456. })(id, eloType, cats_elo[cat], window.sport, window.lang, flagSenior, flagSub23, flagSub21, flagSub18);
  3457.  
  3458. }
  3459.  
  3460. }
  3461. var thead = document.getElementsByClassName("seriesHeader")[table_index]
  3462. var ths = thead.querySelectorAll("th");
  3463. ths.forEach(function (th, index) {
  3464. th.addEventListener("click", function () {
  3465. ordenarTabla(index, true, "nice_table",true);
  3466. });
  3467. });
  3468. }
  3469. });
  3470.  
  3471.  
  3472. }
  3473.  
  3474. })();