// ==UserScript==
// @name Stats Xente Script
// @namespace http://tampermonkey.net/
// @version 0.108
// @description Stats Xente script for inject own data on Managerzone site
// @author xente
// @match https://www.managerzone.com/*
// @icon https://statsxente.com/MZ1/View/Images/main_icon.png
// @license GNU
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @grant GM_listValues
// @require https://code.jquery.com/jquery-3.7.1.js
// @downloadURL none
// ==/UserScript==
(function () {
'use strict';
/*let keys = GM_listValues();
keys.forEach(function(key) {
console.log(key+" "+GM_getValue(key))
});*/
/*let actual_version="0.9666"
console.log(GM_info.script.version)
if(GM_info.script.version!=actual_version){
console.log("here")
keys = GM_listValues();
keys.forEach(function (key) {
GM_deleteValue(key);
});
}*/
setCSSStyles()
createModalMenu()
waitToDOMById(createModalEventListeners,"saveButton",5000)
setLangSportCats()
getUsernameData()
checkScriptVersion()
/// FUNCTIONS MENU
setTimeout(function () {
const urlParams = new URLSearchParams(window.location.search);
if ((urlParams.has('p')) && (urlParams.get('p') === 'league') && (GM_getValue("leagueFlag"))) {
waitToDOM(leagues, ".nice_table", 0,7000)
}
if ((urlParams.has('p')) && (urlParams.get('p') === 'federations')
&& (urlParams.get('sub') === 'league') && (GM_getValue("federationFlag"))) {
waitToDOM(clashLeagues, ".nice_table", 0,7000)
}
if ((urlParams.has('p')) && (urlParams.get('p') === 'federations')
&& (urlParams.get('sub') === 'clash') && (GM_getValue("federationFlag"))) {
waitToDOM(clash, ".fed_badge", 0,7000)
}
if ((urlParams.has('p')) && (urlParams.get('p') === 'match')
&& (urlParams.get('sub') === 'result') && (GM_getValue("matchFlag"))) {
setTimeout(function () {
waitToDOM(match, ".hitlist.statsLite.marker", 0,7000)
}, 2000);
}
if ((urlParams.has('p')) && (urlParams.get('p') === 'players') && (!urlParams.has('pid'))
&& (GM_getValue("playersFlag"))) {
waitToDOM(playersPage, ".playerContainer", 0,7000)
}
if ((urlParams.has('p')) && (urlParams.get('p') === 'players') && (urlParams.has('pid'))) {
waitToDOM(playersPageStats, ".player_name", 0,7000)
}
if ((urlParams.has('p')) && (urlParams.get('p') === 'rank') && (urlParams.get('sub') === 'countryrank')
&& (GM_getValue("countryRankFlag"))) {
countryRank();
}
if ((urlParams.has('p')) && (urlParams.get('p') === 'clubhouse')) {
StatsXenteNextMatchesClubhouse()
}
if ((urlParams.has('p')) && (urlParams.get('p') === 'friendlyseries')
&& (urlParams.get('sub') === 'standings')) {
waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0,7000)
}
if ((urlParams.has('p')) && (urlParams.get('p') === 'cup') && (urlParams.get('sub') === 'groupplay')) {
waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0,7000)
}
if ((urlParams.has('p')) && (urlParams.get('p') === 'private_cup') && (urlParams.get('sub') === 'groupplay')) {
waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0,7000)
}
if ((urlParams.has('p')) && (urlParams.get('p') === 'match') && (urlParams.get('sub') === 'played')) {
if(GM_getValue("eloNextMatchesFlag")){
waitToDOM(nextMatches, ".group", 0,7000)
}
if(GM_getValue("eloPlayedMatchesFlag")){
waitToDOM(lastMatchesELO, ".group", 0,7000)
}
}
if ((urlParams.has('p')) && (urlParams.get('p') === 'match') && (urlParams.get('sub') === 'scheduled')) {
if(GM_getValue("eloNextMatchesFlag")){
waitToDOM(nextMatches, ".group", 0,7000)
}
}
if ((urlParams.has('p')) && (urlParams.get('p') === 'team') && (GM_getValue("teamPageFlag"))) {
teamPage()
}
const elementos = document.querySelectorAll('.player_link'); //Adds stats icon in players page, when click on player info
elementos.forEach(function (elemento) {
elemento.addEventListener('click', function () {
waitToDOM(playersPageStats, ".player_name", 0,7000)
});
});
}, 1000);
let teams_data = "";
let searchClassName = ""
let players = []
let lines = []
let gk_line = ""
let skills_names = []
let su_line = "unsetted";
//BUTTONS EVENTS LISTENERS
const urlParams = new URLSearchParams(window.location.search);
if ((urlParams.get('p') === 'friendlyseries')||(urlParams.get('p') === 'federations')){
console.log("here")
waitToDOMById(tableFLAndClashEventListener,"ui-id-2",5000)
}
if (urlParams.get('p') === 'cup'){
console.log("here1")
waitToDOMById(tableCupsEventListener,"ui-id-4",5000)
}
waitToDOMById(tableLeaguesEventListener,"league_tab_table",5000)
function tableLeaguesEventListener(){
document.getElementById("league_tab_table").addEventListener('click', function () {
if (document.getElementById("showMenu") === null) {
waitToDOM(leagues, ".nice_table", 0,7000)
}
});
}
function tableCupsEventListener(){
document.getElementById("ui-id-4").parentNode.addEventListener('click', function () {
if (document.getElementById("showMenu") === null) {
waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0,7000)
}
viewButtonCupsEventListener()
});
}
function viewButtonCupsEventListener(){
document.addEventListener('click', function(event) {
if ((event.target) &&((event.target.parentNode.id === 'view_btn')||(event.target.parentNode.parentNode.id === 'view_btn'))) {
setTimeout(function () {
if (document.getElementById("showMenu") === null) {
waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0,7000)
}
}, 1000);
}
});
}
function tableFLAndClashEventListener(){
document.getElementById("ui-id-2").parentNode.addEventListener('click', function () {
if (document.getElementById("showMenu") === null) {
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.get('fsid')) {
waitToDOM(friendlyCupsAndLeagues, ".nice_table", 0,7000)
} else {
waitToDOM(clashLeagues, ".nice_table", 0,7000)
}
}
});
}
//Next matches page
function nextMatches(){
let team_id=""
let urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('tid')){
team_id=urlParams.get("tid")
}else{
if(window.sport==="soccer"){
team_id=GM_getValue("soccer_team_id")
}else{
team_id=GM_getValue("hockey_team_id")
}
}
let team_ids=[]
let linkIds=""
let contIds=0
let cIds=""
let contCIds=0
let comps=[]
let comp_ids=[]
let elements0 = document.querySelectorAll('.odd');
elements0.forEach(element0 => {
let cat=element0.getElementsByClassName("responsive-hide match-reference-text-wrapper flex-grow-0");
if(cat.length>0){
let links = cat[0].querySelectorAll('a');
if(links.length>0){
let urlObj = new URL("https://www.managerzone.com/" + links[0].getAttribute('href'));
let params = new URLSearchParams(urlObj.search);
let type = params.get('type');
if(type===null){
if((params.get('p')==="cup")||(params.get('p')==="private_cup")){
if(links[0].textContent.includes("U23")){
comps[params.get('cid')]="U23"
}else{
if(links[0].textContent.includes("U21")){
comps[params.get('cid')]="U21"
}else{
if(links[0].textContent.includes("U18")){
comps[params.get('cid')]="U18"
}else{
comps[params.get('cid')]="SENIOR";
}
}
}
}else{
let id=0;
switch(params.get('p')){
case "cup":
id=params.get('cid');
break;
case "private_cup":
id=params.get('cid');
break;
case "friendly_series":
id=params.get('fsid');
break;
}
if (!comp_ids.includes(id)) {
comp_ids.push(id);
cIds += "&idComp" + contCIds + "=" + id
contCIds++;
}
}
}
}
}
let elements1 = element0.querySelectorAll('.teams-wrapper .flex-grow-1');
elements1.forEach(element1 => {
let elements2 = element1.querySelectorAll('.clippable');
elements2.forEach(element2 => {
let urlObj = new URL("https://www.managerzone.com/" + element2.getAttribute('href'));
let params = new URLSearchParams(urlObj.search);
let tidValue = params.get('tid');
if(tidValue!==null){
if (!team_ids.includes(tidValue)) {
team_ids.push(tidValue);
linkIds += "&idEquipo" + contIds + "=" + tidValue
contIds++;
}
}
});
});
});
if (!team_ids.includes(team_id)) {
linkIds += "&idEquipo" + contIds + "=" + team_id
}
GM_xmlhttpRequest({
method: "GET",
url: "https://statsxente.com/MZ1/Functions/tamper_elo_values.php?sport=" + window.sport + linkIds+cIds,
headers: {
"Content-Type": "application/json"
},
onload: function (response) {
let rawJSON = JSON.parse(response.responseText);
let jsonResponse=rawJSON["teams"]
for (let key in rawJSON["comps"]) {
comps[key]=rawJSON["comps"][key]['restriction']
}
let elements0 = document.querySelectorAll('.odd:not(.uxx)');
elements0.forEach(element0 => {
let elements1 = element0.querySelectorAll('.teams-wrapper .flex-grow-1');
elements1.forEach(element1 => {
let elements2 = element1.querySelectorAll('.clippable');
elements2.forEach(element2 => {
let urlObj = new URL("https://www.managerzone.com/" + element2.getAttribute('href'));
let params = new URLSearchParams(urlObj.search);
let tidValue = params.get('tid');
if(tidValue!==null){
tidValue=parseInt(tidValue)
let valor=0;
if (jsonResponse[tidValue]?.SENIOR) {
valor = new Intl.NumberFormat(window.userLocal).format(Number.parseFloat(jsonResponse[tidValue]["SENIOR"]).toFixed(0))
}
element1.innerHTML+=""+valor;
}else{
tidValue=parseInt(team_id)
let valor=0;
if (jsonResponse[tidValue]?.SENIOR) {
valor = new Intl.NumberFormat(window.userLocal).format(Number.parseFloat(jsonResponse[tidValue]["SENIOR"]).toFixed(0))
}
element1.innerHTML+=""+valor;
}
});
});
});
let temp_cats=[]
temp_cats["u23"] = "U23";
temp_cats["u21"] = "U21";
temp_cats["u18"] = "U18";
temp_cats["u23_world"] = "U23";
temp_cats["u21_world"] = "U21";
temp_cats["u18_world"] = "U18";
elements0 = document.querySelectorAll('.odd.uxx');
elements0.forEach(element0 => {
let cat=element0.getElementsByClassName("responsive-hide match-reference-text-wrapper flex-grow-0");
let links = cat[0].querySelectorAll('a');
let urlObj = new URL("https://www.managerzone.com/" + links[0].getAttribute('href'));
let params = new URLSearchParams(urlObj.search);
let type = params.get('type');
let elo_type="SENIOR"
if(type==null){
if(params.get('cid')!=null){
elo_type=comps[params.get('cid')]
}
if(params.get('fsid')!=null){
elo_type=comps[params.get('fsid')]
}
}else{
elo_type=temp_cats[type]
}
let elements1 = element0.querySelectorAll('.teams-wrapper .flex-grow-1');
elements1.forEach(element1 => {
let elements2 = element1.querySelectorAll('.clippable');
elements2.forEach(element2 => {
let urlObj = new URL("https://www.managerzone.com/" + element2.getAttribute('href'));
let params = new URLSearchParams(urlObj.search);
let tidValue = params.get('tid');
if(tidValue!==null){
tidValue=parseInt(tidValue)
let valor=0;
if(jsonResponse[tidValue] && jsonResponse[tidValue][elo_type] !== undefined) {
valor = new Intl.NumberFormat(window.userLocal).format(Number.parseFloat(jsonResponse[tidValue][elo_type]).toFixed(0))
}
element1.innerHTML+=""+valor;
}else{
tidValue=parseInt(team_id)
let valor=0;
if(jsonResponse[tidValue] && jsonResponse[tidValue][elo_type] !== undefined){
valor = new Intl.NumberFormat(window.userLocal).format(Number.parseFloat(jsonResponse[tidValue][elo_type]).toFixed(0))
}
element1.innerHTML+=""+valor;
}
});
});
});
}
});
}
//Team page
function teamPage(){
let u23_type="",u21_type="",u18_type=""
let team_name_div=document.getElementsByClassName("teamDataText clippable");
const team_name=encodeURI(team_name_div[0].textContent)
let team_id=""
let urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('tid')){
team_id=urlParams.get("tid")
}else{
if(window.sport==="soccer"){
team_id=GM_getValue("soccer_team_id")
}else{
team_id=GM_getValue("hockey_team_id")
}
}
let main_div=document.getElementById("infoAboutTeam")
let dds = main_div.querySelectorAll('dd');
dds.forEach(dd => {
let as = dd.querySelectorAll('a');
if(as.length>0){
let href = as[0].getAttribute('href');
let urlParams = new URLSearchParams(href.split('?')[1]);
let type = urlParams.get('type');
if(type.includes("u23")){
u23_type=window.cats[type]
}
if(type.includes("u21")){
u21_type=window.cats[type]
}
if(type.includes("u18")){
u18_type=window.cats[type]
}
}
});
GM_xmlhttpRequest({
method: "GET",
url: "https://statsxente.com/MZ1/Functions/tamper_detailed_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + "&idEquipo="+team_id,
headers: {
"Content-Type": "application/json"
},
onload: function (response) {
let jsonResponse = JSON.parse(response.responseText);
let aux=team_id
let top="TOP 11"
if(window.sport==="hockey"){
top="TOP 21"
}
let teamTable='
'
teamTable+='
'
teamTable+='
'
teamTable+='
Value
LM Value
'
teamTable+='
'+top+'
ELO
'
teamTable+='
Age
'
teamTable+='
Salary
'
teamTable+='
Players
'
teamTable+='
'
teamTable+='
'
let valor=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor']))
let valorLM=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valorUPSenior']))
let valor11=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor11']))
let elo=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['elo']))
let edad= Number.parseFloat(jsonResponse[aux]['edad']).toFixed(2)
let salario=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['salario']))
let numJugs=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['numJugadores']))
teamTable+='
";
}
if (clave === "valor11") {
contenidoNuevo += "
";
}
if (clave === "elo") {
contenidoNuevo += "
";
}
if (clave === "leagues") {
contenidoNuevo += "
";
}
if (clave === "leagues_all") {
contenidoNuevo += "
";
}
if (clave === "cup") {
contenidoNuevo += "
";
}
if (clave === initialValues[detected_cat]) {
contenidoNuevo += '
';
} else {
contenidoNuevo += '
';
}
});
contenidoNuevo += "
"
contenidoNuevo += "
";
if(idComp!=="null"){
contenidoNuevo +="
"
let color=GM_getValue("bg_native")
contenidoNuevo +='
'
contenidoNuevo += '
'
contenidoNuevo += '
'
contenidoNuevo +="
"
contenidoNuevo += '
'
contenidoNuevo += '
'
contenidoNuevo +="
"
contenidoNuevo +="
"
let darkerColor = darkenColor(color, 25);
document.styleSheets[0].insertRule(
'.btn-comp-fed:hover { background-color: '+darkerColor+' !important; }',
document.styleSheets[0].cssRules.length
);
values.set('valor', 'Value');
elems = document.getElementsByClassName("nice_table");
tabla = elems[0]
tabla.insertAdjacentHTML('beforebegin', contenidoNuevo);
///COM FED BUTTONS
document.getElementById("todos").addEventListener('click', function () {
let link = "https://statsxente.com/MZ1/View/FEDCOMP_ContraTodos_VIEW.php?tamper=yes&id="+idComp+"&idioma="+ window.lang
openWindow(link, 0.75, 1.1);
});
document.getElementById("directosSIN").addEventListener('click', function () {
let link = "https://statsxente.com/MZ1/View/FEDCOMP_Directos_VIEW.php?tamper=yes&id="+idComp+"&idioma="+ window.lang
openWindow(link, 0.75, 1.1);
});
document.getElementById("directosCON").addEventListener('click', function () {
let link = "https://statsxente.com/MZ1/View/FEDCOMP_DirectosEmpates_VIEW.php?tamper=yes&id="+idComp+"&idioma="+ window.lang
openWindow(link, 0.75, 1.1);
});
document.getElementById("desgloseSIN").addEventListener('click', function () {
let link = "https://statsxente.com/MZ1/Lecturas/getDesglosePuntosFede.php?tamper=yes&idComp="+idComp+"&idioma="+ window.lang+"&idLiga="+urlParams.get('fsid')
openWindow(link, 0.75, 1.1);
});
document.getElementById("desgloseCON").addEventListener('click', function () {
let link = "https://statsxente.com/MZ1/Lecturas/getDesglosePuntosFedeEmpates.php?tamper=yes&idComp="+idComp+"&idioma="+ window.lang+"&idLiga="+urlParams.get('fsid')
openWindow(link, 0.75, 1.1);
});
}else{
values.set('valor', 'Value');
elems = document.getElementsByClassName("nice_table");
tabla = elems[0]
tabla.insertAdjacentHTML('beforebegin', contenidoNuevo);
}
if (GM_getValue("show_league_selects") === true) {
document.getElementById("line2").style.transform = 'rotateZ(0deg)';
document.getElementById("line1").style.transform = 'rotateZ(180deg)';
document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
}
values.forEach(function (valor, clave) {
let elemento = document.getElementById(clave);
elemento.addEventListener('click', handleClick);
});
let thWidth="7.5em"
if(idComp!=="null"){
thWidth="5.5em"
}
let nuevaCeldaEncabezado = document.createElement("th");
nuevaCeldaEncabezado.textContent = values.get(initialValues[detected_cat]);
nuevaCeldaEncabezado.style.textAlign = 'center';
nuevaCeldaEncabezado.style.maxWidth = thWidth;
nuevaCeldaEncabezado.style.width = thWidth;
nuevaCeldaEncabezado.style.whiteSpace = 'nowrap';
nuevaCeldaEncabezado.style.overflow = 'hidden';
nuevaCeldaEncabezado.style.textOverflow = 'ellipsis';
let ser = document.getElementsByClassName("seriesHeader")
let table_index = 0;
for (let kl = 0; kl < ser.length; kl++) {
if (document.getElementsByClassName("seriesHeader")[kl].parentNode.parentNode.className === "nice_table") {
table_index = kl
}
}
var widthTeam="180px"
if(idComp!=="null"){
widthTeam="150px";
}
document.getElementsByClassName("seriesHeader")[table_index].cells[1].style.width = widthTeam
document.getElementsByClassName("seriesHeader")[table_index].appendChild(nuevaCeldaEncabezado);
if(idComp!=="null"){
let nuevaColumna1 = document.getElementsByClassName("seriesHeader")[table_index].insertCell(2);
nuevaColumna1.outerHTML = "
Federation
"
nuevaColumna1.style.textAlign = 'center';
let tds = document.querySelectorAll('.nice_table td');
let ths = document.querySelectorAll('.nice_table th');
tds.forEach(td => {
td.style.paddingLeft = "3px";
td.style.paddingRight = "3px";
});
ths.forEach(th => {
th.style.paddingLeft = "3px";
th.style.paddingRight = "3px";
});
}
nuevaCeldaEncabezado = document.createElement("th");
nuevaCeldaEncabezado.textContent = "Stats Xente";
nuevaCeldaEncabezado.style.textAlign = 'center';
document.getElementsByClassName("seriesHeader")[table_index].appendChild(nuevaCeldaEncabezado);
if (tabla.getElementsByTagName("tbody")[0].innerHTML.includes("mazyar")) {
searchClassName = "responsive-hide"
}
let contIds = 0
let filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
for (let i = 0; i < filasDatos.length; i++) {
if (checkClassNameExists(tabla.rows[i + 1], searchClassName)) {
let celda = tabla.rows[i + 1].cells[1];
let equipo = celda.textContent.trim()
let iniIndex = celda.innerHTML.indexOf("tid=");
let lastIndex = celda.innerHTML.indexOf("\">", iniIndex + 4);
let data = String(celda.innerHTML)
let id = data.substring(iniIndex + 4, lastIndex)
linkIds += "&idEquipo" + contIds + "=" + id
contIds++
celda.innerHTML += ""
}
}
///DIV PROGRESS
setTimeout(function () {
(function () {
document.getElementById("moreInfo").addEventListener('click', function () {
document.getElementById("moreInfo").classList.toggle('active');
if (document.getElementById("moreInfo").classList.contains("active")) {
document.getElementById("line2").style.transform = 'rotateZ(0deg)';
document.getElementById("line1").style.transform = 'rotateZ(180deg)';
document.getElementById("moreInfo").style.transform = 'rotateZ(0deg)';
$('#separatorTd').fadeOut(1);
document.getElementById("separatorTd").style.paddingTop = "5px";
$('#show3').fadeIn('slow');
} else {
document.getElementById("line2").style.transform = 'rotateZ(45deg)';
document.getElementById("line1").style.transform = 'rotateZ(-45deg)';
document.getElementById("moreInfo").style.transform = 'rotateZ(45deg)';
$('#separatorTd').fadeIn(1);
$('#show3').fadeOut('slow');
}
});
})();
}, 200);
GM_xmlhttpRequest({
method: "GET",
url: "https://statsxente.com/MZ1/Functions/tamper_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + linkIds,
headers: {
"Content-Type": "application/json"
},
onload: function (response) {
let jsonResponse = JSON.parse(response.responseText);
teams_data = jsonResponse;
let filasDatos = tabla.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
for (let i = 0; i < filasDatos.length; i++) {
if (checkClassNameExists(filasDatos[i], searchClassName)) {
let celda = filasDatos[i].cells[1]
let equipo = celda.textContent.trim()
let iniIndex = celda.innerHTML.indexOf("tid=");
let lastIndex = celda.innerHTML.indexOf("\">", iniIndex + 4);
let data = String(celda.innerHTML)
let id = data.substring(iniIndex + 4, lastIndex)
let nuevaColumna = document.createElement("td");
let valor = 0;
if (jsonResponse[id] && jsonResponse[id][initialValues[detected_cat]] !== undefined) {
valor = new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[id][initialValues[detected_cat]]))
}
nuevaColumna.innerHTML = valor
nuevaColumna.style.textAlign = 'center';
filasDatos[i].appendChild(nuevaColumna);
if(idComp!=="null"){
let nuevaColumna1 = filasDatos[i].insertCell(2);
nuevaColumna1.innerHTML = ""+fl_data['teams'][id]['nombreFede']+"";
nuevaColumna1.style.textAlign = 'left';
}
let eloType = 1
if (window.sport === "soccer") { eloType = 2 }
let cats_elo = {}
cats_elo["senior"] = "SENIOR";
cats_elo["seniorw"] = "SENIOR";
cats_elo["SUB23"] = "U23";
cats_elo["SUB21"] = "U21";
cats_elo["SUB18"] = "U18";
cats_elo["SUB23w"] = "U23";
cats_elo["SUB21w"] = "U21";
cats_elo["SUB18w"] = "U18";
let cat = cats[detected_cat]
let flagSenior = 0, flagSub23 = 0, flagSub21 = 0, flagSub18 = 0;
if (jsonResponse[id]["elo"] > 0) { flagSenior = 1 }
if (jsonResponse[id]["elo23"] > 0) { flagSub23 = 1 }
if (jsonResponse[id]["elo21"] > 0) { flagSub21 = 1 }
if (jsonResponse[id]["elo18"] > 0) { flagSub18 = 1 }
let buttonDisplay = "display:block;";
nuevaColumna = document.createElement("td");
nuevaColumna.style.margin = '0 auto';
nuevaColumna.style.textAlign = 'center';
let iner = "";
if (GM_getValue("league_graph_button") === "checked") {
buttonDisplay = ""
} else {
buttonDisplay = "display:none;";
}
iner += "";
if (GM_getValue("league_report_button") === "checked") {
buttonDisplay = ""
} else {
buttonDisplay = "display:none;";
}
iner += "";
if (GM_getValue("league_calendar_button") === "checked") {
buttonDisplay = ""
} else {
buttonDisplay = "display:none;";
}
iner += " ";
iner += "";
nuevaColumna.innerHTML = iner
filasDatos[i].appendChild(nuevaColumna);
nuevaColumna = document.createElement("td");
(function (currentId, currentLSport, lang) {
document.getElementById("but1" + currentId).addEventListener('click', function () {
let link = "https://statsxente.com/MZ1/Graficos/graficoProgresoEquipo.php?idEquipo=" + currentId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") + "&deporte=" + currentLSport;
openWindow(link, 0.95, 1.25);
});
})(id, window.lsport, window.lang);
(function (currentId, currentLSport, lang, currentCat) {
document.getElementById("but2" + currentId).addEventListener('click', function () {
let src = "filtroGraficoEquiposHistoricoHockey";
if (currentLSport === "F") {
src = "filtroGraficoLinealEquiposHistorico";
}
let 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=-"
openWindow(link, 0.95, 1.25);
});
})(id, window.lsport, window.lang, cat);
(function (currentId, currentEquipo, currentCat, currentSport, lang) {
document.getElementById("but" + currentId).addEventListener('click', function () {
let 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";
openWindow(link, 0.95, 1.25);
});
})(id, equipo, cat, window.sport, window.lang);
(function (currentId, type, currentCat, currentSport, lang, flagS, flagS23, flagS21, flagS18) {
document.getElementById("but3" + currentId).addEventListener('click', function () {
let link = "https://statsxente.com/MZ1/Graficos/graficoRachaEquipoELO.php?tamper=yes&team_id=" + currentId + "&idioma=" + lang + "&deporte=" + currentSport + "&type=" + type + "&cat=" + currentCat + "&flagSenior=" +
flagS + "&flagSub23=" + flagS23 + "&flagSub21=" + flagS21 + "&flagSub18=" + flagS18;
openWindow(link, 0.95, 1.25);
});
})(id, eloType, cats_elo[cat], window.sport, window.lang, flagSenior, flagSub23, flagSub21, flagSub18);
}
}
let thead = document.getElementsByClassName("seriesHeader")[table_index]
let ths = thead.querySelectorAll("th");
ths.forEach(function (th, index) {
th.addEventListener("click", function () {
ordenarTabla(index, true, "nice_table",true);
});
});
}
});
}
//Match page
async function match() {
let team_div = document.getElementsByClassName("flex-grow-0 textCenter team-table block")
if (team_div.length===0){
team_div = document.getElementsByClassName("flex-grow-0 textCenter team-table no-match-buttons block")
}
let teams_ = []
let linkIds=""
let contIds=0
for (let x = 0; x < 2; x++) {
let as = team_div[x].getElementsByTagName("a")
let urlObj = new URL("https://www.managerzone.com/" + as[0].getAttribute('href'));
let params = new URLSearchParams(urlObj.search);
let tidValue = params.get('tid');
teams_[x] = { "team_name": as[0].innerHTML, "team_id": tidValue, "inserted": "" }
linkIds += "&idEquipo" + contIds + "=" + tidValue
contIds++
}
GM_xmlhttpRequest({
method: "GET",
url: "https://statsxente.com/MZ1/Functions/tamper_teams.php?currency=" + GM_getValue("currency") + "&sport=" + window.sport + linkIds,
headers: {
"Content-Type": "application/json"
},
onload: function (response) {
let jsonResponse = JSON.parse(response.responseText);
const divs = document.querySelectorAll('div'); // Selecciona todos los divs
const divsConAltura15px = Array.from(divs).filter(div => {
const computedStyle = window.getComputedStyle(div);
return computedStyle.height === '15px' && div.innerHTML === "";
});
for(let m=0;m<2;m++){
let aux=teams_[m]['team_id']
let top="TOP 11"
if(window.sport==="hockey"){
top="TOP 21"
}
let teamTable='
'
teamTable+='
'
teamTable+='
'
teamTable+='
Value
LM Value
'
teamTable+='
'+top+'
ELO
'
let valor=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor']))
let valorLM=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valorUPSenior']))
let valor11=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['valor11']))
let elo=new Intl.NumberFormat(window.userLocal).format(Math.round(jsonResponse[aux]['elo']))
teamTable+='
'
divsConAltura15px[m].insertAdjacentHTML('afterend',teamTable)
}
const thElements = document.querySelectorAll('table.matchValuesTable th');
// Cambia el color de fondo de cada
thElements.forEach(th => {
th.style.backgroundColor = GM_getValue("bg_native");
th.style.color = GM_getValue("color_native");
});
document.getElementById("thTransparent0").style.backgroundColor="transparent";
document.getElementById("thTransparent1").style.backgroundColor="transparent";
}
});
let elems = document.getElementsByClassName("hitlist " + window.sport + " statsLite marker tablesorter");
for (let x = 0; x < 2; x++) {
let linkIds = ""
let contIds = 0;
let tabla = elems[x]
let filas = tabla.getElementsByTagName("tr");
let fila = filas[1];
for (let i = 2; i < filas.length - 1; i++) {
fila = filas[i];
let tds = fila.getElementsByTagName("td");
let as_ = tds[2].getElementsByTagName("a");
let urlObj = new URL("https://www.managerzone.com/" + as_[0].getAttribute("href"));
let params = new URLSearchParams(urlObj.search);
let pid = params.get('pid');
linkIds += "&id" + contIds + "=" + pid
contIds++;
}
let link = "http://statsxente.com/MZ1/Functions/tamper_check_stats_player.php?sport=" + window.sport + linkIds
teams_[x]["inserted"]= await fetchExistPlayers(link);
}
elems = document.getElementsByClassName("hitlist " + window.sport + " statsLite marker tablesorter");
for (let x = 0; x < 2; x++) {
if (teams_[x]['inserted']['total'] > 0) {
let tabla = elems[x]
let firstTrThead = tabla.querySelector('thead td');
let currentColspan = firstTrThead.getAttribute('colspan');
currentColspan = parseInt(currentColspan, 10) + 1;
firstTrThead.setAttribute('colspan', currentColspan);
let secondTrThead = tabla.querySelector('thead tr:nth-of-type(2)')
let newTd = document.createElement('td');
newTd.textContent = '';
secondTrThead.appendChild(newTd);
let filas = tabla.getElementsByTagName("tr");
let dato = document.createElement("td");
let tfoot = tabla.querySelector("tfoot");
let primeraFilaTfoot = tfoot.querySelector("tr");
let primerTDTfoot = primeraFilaTfoot.querySelector("td");
primerTDTfoot.setAttribute("colspan", "9");
let elems2 = document.getElementsByClassName("listHeadColor");
let lista = elems2[0]
let nuevoElementoDD = document.createElement("dd");
nuevoElementoDD.textContent = "Nuevo elemento";
nuevoElementoDD.className = "c6"
lista.appendChild(nuevoElementoDD);
for (let i = 2; i < filas.length - 1; i++) {
let fila = filas[i];
let tds = fila.getElementsByTagName("td");
let as_ = tds[2].getElementsByTagName("a");
let urlObj = new URL("https://www.managerzone.com/" + as_[0].getAttribute("href"));
let params = new URLSearchParams(urlObj.search);
let pid = params.get('pid');
if (teams_[x]['inserted'][pid] === "yes") {
dato = document.createElement("td");
dato.innerHTML = ""
fila.appendChild(dato);
(function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
document.getElementById("but" + currentId).addEventListener('click', function () {
let link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
+ "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
"&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
openWindow(link, 0.95, 1.25);
});
})(pid, teams_[x]['team_id'], window.sport, window.lang, teams_[x]['team_name'], as_[0].innerHTML);
}else{
dato = document.createElement("td");
fila.appendChild(dato);
}
}
}
}
}
//Players page
async function playersPage() {
setTimeout(function () {
let player_images
let elementos = document.getElementsByClassName('playerContainer');
let player_values = {}
let tactics_list = []
let urlParams = new URLSearchParams(window.location.search);
let flagStats = true
if (urlParams.has('tid')) {
flagStats = false
}
if (flagStats) {
let habil_container = elementos[0].getElementsByClassName("player_skills")
let habil = habil_container[0].getElementsByClassName("clippable")
if (window.sport === "hockey") {
for (let q = 1; q < habil.length; q++) {
skills_names.push(habil[q].textContent)
}
} else {
for (let q = 0; q < habil.length - 1; q++) {
skills_names.push(habil[q].textContent)
}
player_images = document.getElementsByClassName("player-image soccer")
}
}
let ids_ = []
for (let i = 0; i < elementos.length; i++) {
let ids = elementos[i].getElementsByClassName('player_id_span');
let elementos_ = elementos[i].getElementsByClassName('p_sublinks');
let subheaders = elementos[i].getElementsByClassName('subheader clearfix');
let enlace = subheaders[0].querySelector('.subheader a');
let playerName = enlace.querySelector('.player_name').textContent
ids_.push({ "id": ids[0].textContent, "name": playerName });
let txt = ''
txt += ''
elementos_[0].innerHTML += txt;
if (flagStats) {
let flag_gk = false;
let age_div = elementos[i].getElementsByClassName('dg_playerview_info');
let age_table = age_div[0].getElementsByTagName('table')[0];
let ini_age = age_table.getElementsByTagName('td')[0].textContent.indexOf(":")
let age = age_table.getElementsByTagName('td')[0].textContent.substring(ini_age + 2, ini_age + 4);
if ((window.sport === "soccer") && (player_images[i].innerHTML.includes("gk=1"))) {
flag_gk = true
}
let tactics = elementos[i].getElementsByClassName('player_tactic gradientSunriseIcon');
player_values = {
"id": ids[0].textContent,
"skills": [],
"lines": [],
"tactics-position": {},
"tactics": [],
"age": parseInt(age)
}
for (let j = 0; j < tactics.length; j++) {
let fin = 0;
let line = ""
let ini = tactics[j].textContent.indexOf('(');
let tactic = tactics[j].textContent.substring(0, ini - 1);
if (window.sport === "hockey") {
if (!tactics[j].textContent.includes(":")) {
ini = tactics[j].textContent.indexOf('(');
fin = tactics[j].textContent.indexOf(')');
line = tactics[j].textContent.substring(ini + 2, fin - 1);
gk_line = line;
} else {
ini = tactics[j].textContent.indexOf('(');
fin = tactics[j].textContent.indexOf(':');
line = tactics[j].textContent.substring(ini + 2, fin);
}
} else {
ini = tactics[j].textContent.indexOf('(');
fin = tactics[j].textContent.indexOf(')');
line = tactics[j].textContent.substring(ini + 2, fin - 1);
if (flag_gk) {
gk_line = line;
}
if (tactics[j].textContent.includes(",")) {
ini = tactics[j].textContent.indexOf('(');
fin = tactics[j].textContent.indexOf(',');
su_line = tactics[j].textContent.substring(ini + 2, fin);
}
}
if (!player_values['lines'].includes(line)) {
player_values['lines'].push(line);
}
if (!player_values['tactics'].includes(tactic)) {
player_values['tactics'].push(tactic);
}
player_values['tactics-position'][tactic] = line
if ((!lines.includes(line))) {
lines.push(line);
}
if (!tactics_list.includes(tactic)) {
tactics_list.push(tactic);
}
}
let skills = elementos[i].getElementsByClassName('skillval');
if (window.sport === "hockey") {
for (let j = 1; j < skills.length; j++) {
let cleanedText = skills[j].textContent.replace(')', '');
cleanedText = cleanedText.replace('(', '');
let number = parseInt(cleanedText, 10);
player_values['skills'].push(number);
}
} else {
for (let j = 0; j < skills.length - 1; j++) {
let cleanedText = skills[j].textContent.replace(')', '');
cleanedText = cleanedText.replace('(', '');
let number = parseInt(cleanedText, 10);
player_values['skills'].push(number);
}
}
players.push(player_values)
}
}
if (flagStats) {
const container = document.getElementById("squad-search-toggle")
let contenidoNuevo = "
"
contenidoNuevo += "
Choose Tactic:
"
container.innerHTML = contenidoNuevo + container.innerHTML;
skillDistrib(tactics_list[0]);
document.getElementById("tactics_select").addEventListener('change', function () {
let select = document.getElementById('tactics_select');
let valorSeleccionado = select.value;
document.getElementById("divMenu").innerHTML = ""
skillDistrib(valorSeleccionado)
});
}
let team_id
if(window.sport==="soccer"){
team_id=GM_getValue("soccer_team_id")
}else{
team_id=GM_getValue("hockey_team_id")
}
for (let i = 0; i < ids_.length; i++) {
(function (currentId, currentTeamId, currentSport, lang, team_name, player_name) {
document.getElementById("but" + currentId).addEventListener('click', function () {
let link = "http://statsxente.com/MZ1/Functions/tamper_player_stats.php?sport=" + currentSport
+ "&player_id=" + currentId + "&team_id=" + currentTeamId + "&idioma=" + lang + "&divisa=" + GM_getValue("currency") +
"&team_name=" + encodeURIComponent(team_name) + "&player_name=" + encodeURIComponent(player_name)
openWindow(link, 0.95, 1.25);
});
})(ids_[i]['id'], team_id, window.sport, window.lang, "[undefined]", ids_[i]['name']);
}
}, 1000);
}
function skillDistrib(tactic) {
let t = tactic
let l=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
if (window.sport === "hockey") {
l = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
}
let li_t = {}
for (let i = 0; i < lines.length; i++) {
li_t[lines[i]] = [...l];
}
let no_gk_line = "Tactic -(" + gk_line + ")"
li_t["Team"] = [...l];
li_t["U23"] = [...l];
li_t["U21"] = [...l];
li_t["U18"] = [...l];
li_t["Tactic"] = [...l];
li_t[no_gk_line] = [...l];
let i,j
for (i = 0; i < players.length; i++) {
if (players[i]['tactics'].includes(t)) {
for (j = 0; j < players[i]['skills'].length; j++) {
li_t[players[i]['tactics-position'][t]][j] += players[i]['skills'][j]
li_t['Tactic'][j] += players[i]['skills'][j]
if (players[i]['tactics-position'][t] !== "Po") {
li_t[no_gk_line][j] += players[i]['skills'][j]
}
}
li_t[players[i]['tactics-position'][t]][j] += 1
li_t['Tactic'][j] += 1
if (players[i]['tactics-position'][t] !== "Po") {
li_t[no_gk_line][j] += 1
}
} else {
for (let j = 0; j < players[i]['skills'].length; j++) {
if (players[i]['age'] <= 23) {
li_t['U23'][j] += players[i]['skills'][j]
}
if (players[i]['age'] <= 23) {
li_t['U21'][j] += players[i]['skills'][j]
}
if (players[i]['age'] <= 23) {
li_t['U18'][j] += players[i]['skills'][j]
}
li_t['Team'][j] += players[i]['skills'][j]
}
if (players[i]['age'] <= 23) {
li_t['U23'][li_t["U23"].length - 1] += 1
}
if (players[i]['age'] <= 21) {
li_t['U21'][li_t["U21"].length - 1] += 1
}
if (players[i]['age'] <= 18) {
li_t['U18'][li_t["U18"].length - 1] += 1
}
li_t['Team'][li_t["Team"].length - 1] += 1
}
}
const container = document.getElementById("divMenu")
let contenidoNuevo = "
';
newElement.innerHTML=txtToInsert;
let body = document.body;
body.appendChild(newElement);
let newModalElement = document.createElement('div');
newModalElement.innerHTML = '
'
body.insertBefore(newModalElement, body.firstChild);
if (GM_getValue("leagueFlag") === undefined) {
GM_setValue("leagueFlag", true)
}
if (GM_getValue("matchFlag") === undefined) {
GM_setValue("matchFlag", true)
}
if (GM_getValue("federationFlag") === undefined) {
GM_setValue("federationFlag", true)
}
if (GM_getValue("playersFlag") === undefined) {
GM_setValue("playersFlag", true)
}
if (GM_getValue("countryRankFlag") === undefined) {
GM_setValue("countryRankFlag", true)
}
if (GM_getValue("league_graph_button") === undefined) {
GM_setValue("league_graph_button", "checked")
}
if (GM_getValue("league_report_button") === undefined) {
GM_setValue("league_report_button", "checked")
}
if (GM_getValue("league_calendar_button") === undefined) {
GM_setValue("league_calendar_button", "checked")
}
if (GM_getValue("windowsConfig") === undefined) {
GM_setValue("windowsConfig", true)
}
if (GM_getValue("tabsConfig") === undefined) {
GM_setValue("tabsConfig", false)
}
if (GM_getValue("show_league_selects") === undefined) {
GM_setValue("show_league_selects", true)
}
if (GM_getValue("league_image_size") === undefined) {
GM_setValue("league_image_size", 20)
}
if (GM_getValue("eloNextMatchesFlag") === undefined) {
GM_setValue("eloNextMatchesFlag", true)
}
if (GM_getValue("eloPlayedMatchesFlag") === undefined) {
GM_setValue("eloPlayedMatchesFlag", true)
}
if (GM_getValue("teamPageFlag") === undefined) {
GM_setValue("teamPageFlag", true)
}
let leagueFlag = "", matchFlag = "", federationFlag = "", playersFlag = "", countryRankFlag = "",eloNextMatchesFlag="",eloPlayedMatchesFlag="",teamFlag=""
if (GM_getValue("federationFlag")) federationFlag = "checked"
if (GM_getValue("matchFlag")) matchFlag = "checked"
if (GM_getValue("leagueFlag")) leagueFlag = "checked"
if (GM_getValue("playersFlag")) playersFlag = "checked"
if (GM_getValue("countryRankFlag")) countryRankFlag = "checked"
if (GM_getValue("eloNextMatchesFlag")) eloNextMatchesFlag = "checked"
if (GM_getValue("eloPlayedMatchesFlag")) eloPlayedMatchesFlag = "checked"
if (GM_getValue("teamPageFlag")) teamFlag = "checked"
let newContent = '
'
newContent += '
Config
'
newContent +='
';
newContent += '
'
newContent += '
'
newContent += '
'
newContent += '
'
newContent += '
'
newContent += '
'
newContent += '
'
newContent += '
'
newContent += '
'
newContent += "
"
newContent += ""
newContent += "
Leagues Config
"
newContent += "
"
newContent += "
Default Senior Param:
" + generateValuesSelect('senior') + "
";
newContent += "
Default U23 Param:
" + generateValuesSelect('u23') + "
";
newContent += "
Default U21 Param:
" + generateValuesSelect('u21') + "
";
newContent += "
Default U18 Param:
" + generateValuesSelect('u18') + "
";
newContent += "
"
let checked_graph = GM_getValue("league_graph_button")
let checked_report = GM_getValue("league_report_button")
let checked_calendar = GM_getValue("league_calendar_button")
newContent += "
"
newContent += "
"
newContent += "
"
newContent += '
';
newContent += '
'
let checkedLeagueSelects = ""
if (GM_getValue("show_league_selects")) {
checkedLeagueSelects = "checked"
}
newContent += '
'
newContent += "
"
newContent += ""
newContent += "
Tabs Config
"
newContent += "
"
let checkedTab = ""
if (GM_getValue("tabsConfig")) {
checkedTab = "checked"
}
let checkedWin = ""
if (GM_getValue("windowsConfig")) {
checkedWin = "checked"
}
newContent += "";
newContent += "";
newContent += "