NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Pmanager.org AT and GS counter v3 - default // @namespace http://tampermonkey.net/ // @description Work with ONLY Hungarian language // @include https://www.pmanager.org/titulares_v3.asp* // @include https://pmanager.org/titulares_v3.asp* // @version 1.4.2 // @license MIT // @grant none // ==/UserScript== let $ = window.$; function roundToDec(value, dec = 2) { const helper = Math.pow(10, dec); return Math.round(value * helper) / helper; } class Player { static MAIN_PERC = 0.61; static SECOND_PERC = 0.2; static OTHER_PERC = 0.03; static PHY_PERC = 0.15; static MAX_SKILL = 20; static WRONG_SIDE_GS_MULTIPLIER = 0.95; static POSITIONS = { KEEPER: 0, DEFENDER: 1, MIDFIELDER: 2, ATTACKER: 3, UNKNOWN: 4}; static SIDES = {L: 0, C: 1, R: 2, LR: 3, LC: 4, RC: 5, LRC: 6, UNKNOWN: 7}; static Skills = class { constructor(handling = 0, crossing = 0, reflex = 0, agility = 0, tackling = 0, heading = 0, passing = 0, positioning = 0, finishing = 0, technique = 0, speed = 0, strength = 0) { this.handling = handling; this.crossing = crossing; this.reflex = reflex; this.agility = agility; this.tackling = tackling; this.heading = heading; this.passing = passing; this.positioning = positioning; this.finishing = finishing; this.technique = technique; this.speed = speed; this.strength = strength; } }; constructor(name = "", id = 0, pos = Player.POSITIONS.UNKNOWN, side = Player.SIDES.UNKNOWN, fitness = 0, form = 0, experience = 0, skills = new Player.Skills(), curr_pos = Player.POSITIONS.UNKNOWN, curr_side = Player.SIDES.UNKNOWN, on_bench = false) { this.name = name; this.id = id; this.pos = pos; this.side = side; this.curr_pos = curr_pos; this.curr_side = curr_side; this.fitness = fitness; this.form = form; this.experience = experience; this.skills = skills; this.on_bench = on_bench; } TotalGS() { let main = 0, sec = 0, oth = 0; const phy = this.skills.speed + this.skills.strength; const pos_for_gs = this.on_bench ? this.pos : this.curr_pos; if(pos_for_gs == Player.POSITIONS.KEEPER) { main = this.skills.handling + this.skills.crossing sec = this.skills.reflex + this.skills.agility; oth = this.skills.tackling + this.skills.heading + this.skills.passing + this.skills.positioning + this.skills.finishing + this.skills.technique; } else if(pos_for_gs == Player.POSITIONS.DEFENDER) { main = this.skills.tackling + this.skills.heading; sec = this.skills.passing + this.skills.positioning; oth = this.skills.finishing + this.skills.technique + this.skills.handling + this.skills.crossing + this.skills.reflex + this.skills.agility; } else if(pos_for_gs == Player.POSITIONS.MIDFIELDER) { main = this.skills.passing + this.skills.positioning; sec = this.skills.tackling + this.skills.technique; oth = this.skills.finishing + this.skills.heading + this.skills.handling + this.skills.crossing + this.skills.reflex + this.skills.agility; } else if(pos_for_gs == Player.POSITIONS.ATTACKER) { main = this.skills.finishing + this.skills.technique; sec = this.skills.heading + this.skills.positioning; oth = this.skills.passing + this.skills.tackling + this.skills.handling + this.skills.crossing + this.skills.reflex + this.skills.agility; } return (main / (Player.MAX_SKILL * 2) * Player.MAIN_PERC) + (sec / (Player.MAX_SKILL * 2) * Player.SECOND_PERC) + (oth / (Player.MAX_SKILL * 6) * Player.OTHER_PERC) + (phy / (Player.MAX_SKILL * 2) * Player.PHY_PERC); } ReducedGS() { // Reduced GS based on form, experience, fittness -> Magic let b, c, d, e, f; b = this.TotalGS() * (1 + (this.form - 2) * 0.1) / 100; c = 1 + (this.experience - 1) * 0.02 / 3 * 2; d = 1 + 2 * 0.1; e = b * c / d; f = 1 + 6 * 0.02; return (e / f * this.fitness * 1.012); } RealGSforPos() { // check if he used on the wrong side let gs = this.ReducedGS(); let wrong_side = false; //static SIDES = {L: 0, C: 1, R: 2, LR: 3, LC: 4, RC: 5, LRC: 6, UNKNOWN: 7}; switch(this.side){ case Player.SIDES.L: if (this.curr_side == Player.SIDES.C || this.curr_side == Player.SIDES.R || this.curr_side == Player.SIDES.RC) wrong_side = true; break; case Player.SIDES.C: if (this.curr_side == Player.SIDES.L || this.curr_side == Player.SIDES.R || this.curr_side == Player.SIDES.LR) wrong_side = true; break; case Player.SIDES.R: if (this.curr_side == Player.SIDES.L || this.curr_side == Player.SIDES.C || this.curr_side == Player.SIDES.LC) wrong_side = true; break; case Player.SIDES.LR: if (this.curr_side == Player.SIDES.C) wrong_side = true; break; case Player.SIDES.LC: if (this.curr_side == Player.SIDES.R) wrong_side = true; break; case Player.SIDES.RC: if (this.curr_side == Player.SIDES.L) wrong_side = true; break; } if (wrong_side) gs *= Player.WRONG_SIDE_GS_MULTIPLIER; return [gs,wrong_side]; } }; class Team { static TACTICS = { ATTACKING: 0, DEFENDING: 1}; constructor(starting_eleven, bench) { this.starting_eleven = starting_eleven; this.bench = bench; console.log("Team filled! Starting eleven: " + starting_eleven.length + " players. Bench: " + bench.length + " players.") } // helpers getGS(playerId) { for (let player of this.starting_eleven) if (player.id == playerId) return player.RealGSforPos(); for (let player of this.bench) if (player.id == playerId) return player.RealGSforPos(); return 0; } countForPosition(position) { let ret = 0; for (let player of this.starting_eleven) if (position == player.curr_pos) ++ret; return ret; } countForPositionAndSide(position, side) { let ret = 0; for (let player of this.starting_eleven) if (position == player.curr_pos && side == player.curr_side) ++ret; return ret; } full_from_attribute(type) { let ret = 0; for (let player of this.starting_eleven) { switch(type){ case "speed": ret += player.skills.speed; break; case "strength": ret += player.skills.strength; break; case "passing": ret += player.skills.passing; break; case "heading": ret += player.skills.heading; break; case "tackling": ret += player.skills.tackling; break; default: break; } } return ret; } full_speed() { return roundToDec(this.full_from_attribute("speed")); } full_strength() { return roundToDec(this.full_from_attribute("strength")); } full_passing() { return roundToDec(this.full_from_attribute("passing")); } full_heading() { return roundToDec(this.full_from_attribute("heading")); } full_tackling() { return roundToDec(this.full_from_attribute("tackling")); } // tactics offside(tactic) { let r_speed = 0, r_pos = 0, count = 0; for (let player of this.starting_eleven) { if ((tactic == Team.TACTICS.ATTACKING && player.curr_pos == Player.POSITIONS.DEFENDER) || (tactic == Team.TACTICS.DEFENDING && player.curr_pos == Player.POSITIONS.ATTACKER)) { r_speed += player.skills.speed; r_pos += player.skills.positioning; ++count; } } return [roundToDec(r_speed / count), roundToDec(r_pos / count)]; } one_on_one(tactic) { let ret = 0, count = 0; for (let player of this.starting_eleven) { if (tactic == Team.TACTICS.ATTACKING && (player.curr_pos == Player.POSITIONS.ATTACKER || player.curr_pos == Player.POSITIONS.MIDFIELDER)) { ret += player.skills.strength + player.skills.technique; ++count; } else if (tactic == Team.TACTICS.DEFENDING && (player.curr_pos == Player.POSITIONS.DEFENDER || player.curr_pos == Player.POSITIONS.MIDFIELDER)) { ret += player.skills.strength + player.skills.tackling; ++count; } } return roundToDec(ret / (count * 2)); } keeping_style_rushing_out(tactic) { let ret = 0, count = 0; for (let player of this.starting_eleven) { if (tactic == Team.TACTICS.ATTACKING && player.curr_pos == Player.POSITIONS.KEEPER) { ret += player.skills.crossing + player.skills.agility; ++count; } else if (tactic == Team.TACTICS.DEFENDING && player.curr_pos == Player.POSITIONS.ATTACKER) { ret += player.skills.heading + player.skills.technique; ++count; } } return roundToDec(ret / (count * 2)); } keeping_style_stand_in(tactic) { let ret = 0, count = 0; for (let player of this.starting_eleven) { if (tactic == Team.TACTICS.ATTACKING && player.curr_pos == Player.POSITIONS.KEEPER) { ret += player.skills.handling + player.skills.reflex; ++count; } else if (tactic == Team.TACTICS.DEFENDING && player.curr_pos == Player.POSITIONS.ATTACKER) { ret += player.skills.heading + player.skills.finishing; ++count; } } return roundToDec(ret / (count * 2)); } marking_man_to_man(tactic) { let ret = 0, count = 0; for (let player of this.starting_eleven) { if (tactic == Team.TACTICS.ATTACKING && (player.curr_pos == Player.POSITIONS.DEFENDER || player.curr_pos == Player.POSITIONS.MIDFIELDER)) { ret += player.skills.tackling + player.skills.strength; ++count; } else if (tactic == Team.TACTICS.DEFENDING && (player.curr_pos == Player.POSITIONS.ATTACKER || player.curr_pos == Player.POSITIONS.MIDFIELDER)) { ret += player.skills.positioning + player.skills.strength; ++count; } } return roundToDec(ret / (count * 2)); } marking_zonal(tactic) { let ret = 0, count = 0; for (let player of this.starting_eleven) { if (tactic == Team.TACTICS.ATTACKING && (player.curr_pos == Player.POSITIONS.DEFENDER || player.curr_pos == Player.POSITIONS.MIDFIELDER)) { ret += player.skills.tackling + player.skills.speed; ++count; } else if (tactic == Team.TACTICS.DEFENDING && (player.curr_pos == Player.POSITIONS.ATTACKER || player.curr_pos == Player.POSITIONS.MIDFIELDER)) { ret += player.skills.positioning + player.skills.speed; ++count; } } return roundToDec(ret / (count * 2)); } long_shots(tactic) { let ret = 0, count = 0; for (let player of this.starting_eleven) { if (tactic == Team.TACTICS.ATTACKING && (player.curr_pos == Player.POSITIONS.ATTACKER || player.curr_pos == Player.POSITIONS.MIDFIELDER)) { ret += (player.skills.finishing + player.skills.technique) / 2; ++count; } else if (tactic == Team.TACTICS.DEFENDING) { if (player.curr_pos == Player.POSITIONS.DEFENDER) { ret += player.skills.positioning; ++count; } else if (player.curr_pos == Player.POSITIONS.KEEPER) { ret += player.skills.agility; ++count; } } } return roundToDec(ret / count); } first_time_shots(tactic) { let ret = 0, count = 0; for (let player of this.starting_eleven) { if (tactic == Team.TACTICS.ATTACKING && player.curr_pos == Player.POSITIONS.ATTACKER) { ret += (player.skills.finishing + player.skills.heading) / 2; ++count; } else if (tactic == Team.TACTICS.DEFENDING) { if (player.curr_pos == Player.POSITIONS.DEFENDER) { ret += player.skills.heading; ++count; } else if (player.curr_pos == Player.POSITIONS.KEEPER) { ret += player.skills.reflex; ++count; } } } return roundToDec(ret / count); } }; class Parser { static starting_eleven = []; static bench = []; static load() { $("#starting_eleven").find(".player-row").each(function(index){ Parser.starting_eleven.push(Parser.parsePlayer($(this))); }); $("#bench").find(".player-row").each(function(index){ let p = Parser.parsePlayer($(this)); p.on_bench = true; Parser.bench.push(p); }); } static getCurrentPosition(data_pos) { switch(data_pos.charAt(0)){ case 'g': return Player.POSITIONS.KEEPER; case 'd': return Player.POSITIONS.DEFENDER; case 'm': return Player.POSITIONS.MIDFIELDER; case 'a': return Player.POSITIONS.ATTACKER; } return Player.POSITIONS.UNKNOWN; } static getCurrentSide(data_pos) { switch(data_pos.charAt(1)){ case 'r': case 'c': return Player.SIDES.C; case 'd': return Player.SIDES.R; case 'e': return Player.SIDES.L; } return Player.SIDES.UNKNOWN; } static getOriginalPosition(text) { switch(text.split(" ")[0]){ case 'GK': return Player.POSITIONS.KEEPER; case 'V': return Player.POSITIONS.DEFENDER; case 'KP': return Player.POSITIONS.MIDFIELDER; case 'T': return Player.POSITIONS.ATTACKER; } return Player.POSITIONS.UNKNOWN; } static getOriginalSide(text) { switch(text.split(" ")[1]){ case 'K': return Player.SIDES.C; case 'J': return Player.SIDES.R; case 'B': return Player.SIDES.L; case 'BK': return Player.SIDES.LC; case 'JB': return Player.SIDES.LR; case 'JK': return Player.SIDES.RC; case 'JBK': return Player.SIDES.LRC; } return Player.SIDES.UNKNOWN; } static getForm(text) { switch(text.trim()){ case 'Csapnivaló': return 0; case 'Nagyon gyenge': return 1; case 'Átlagos': return 2; case 'Jó': return 3; case 'Nagyon jó': return 4; } return -1; } static getExperience(text) { switch(text.trim()){ case 'Pocsék': return 0; case 'Csapnivaló': return 1; case 'Nagyon gyenge': return 2; case 'Gyenge': return 3; case 'Megfelelő': return 4; case 'Jó': return 5; case 'Nagyon jó': return 6; case 'Remek': return 7; case 'Nagyszerű': return 8; case 'Világklasszis': return 9; } return -1; } static getSkills(player_info) { let s = new Player.Skills(); s.handling = parseInt(player_info.find("div.hand").text()); s.crossing = parseInt(player_info.find("div.outa").text()); s.reflex = parseInt(player_info.find("div.refl").text()); s.agility = parseInt(player_info.find("div.agil").text()); s.tackling = parseInt(player_info.find("div.tack").text()); s.heading = parseInt(player_info.find("div.head").text()); s.passing = parseInt(player_info.find("div.shps").text()); s.positioning = parseInt(player_info.find("div.posi").text()); s.finishing = parseInt(player_info.find("div.fini").text()); s.technique = parseInt(player_info.find("div.tecn").text()); s.speed = parseInt(player_info.find("div.spee").text()); s.strength = parseInt(player_info.find("div.stam").text()); return s; } static parsePlayer(player_row_div) { let p = new Player(); // position and side const current_pos_and_side = player_row_div.attr("data-pos"); p.curr_pos = Parser.getCurrentPosition(current_pos_and_side); p.curr_side = Parser.getCurrentSide(current_pos_and_side); // player info const info = player_row_div.find("div.player-info"); p.id = parseInt(info.attr("id")); p.name = info.find("div.Name").text().trim(); const pos_side_text = info.find("div.pos span").text(); p.pos = Parser.getOriginalPosition(pos_side_text); p.side = Parser.getOriginalSide(pos_side_text); p.fitness = parseInt(info.find("div.fitnS div.progressbar").attr("data-sortvalue")); p.form = Parser.getForm(info.find("div.form span").text()); p.experience = Parser.getExperience(info.find("div.exper div.progressbar").attr("title")); p.skills = Parser.getSkills(info); return p; } }; class Printer { constructor(team) { this.resizeWindow(); this.addHintAbove(); this.fillPlayerTab(team); this.fillAdvancedOptions(team); this.colorAdvancedOptions(); } resizeWindow() { $("div#managerDiv").css("width", "680px"); } addHintAbove() { let commentar = $("form[name='jogos'] td.comentarios"); commentar.text("A színezés, a GS és a figyelmeztetések csak oldal újratöltés után frissülnek!"); commentar.css({"color": "gray", "font-weight": "Bold"}); } fillPlayerTab(team) { let player_table = $("div#managerTabs div.players-table-div"); // Change Adottság to A player_table.find("div#table_header div#talt").text("A"); // Add GS column player_table.find("div#table_header div#stam").after( '<div id="rgs" title="GS" class="field-col rgs" data-group="flskill" style="width: 15px; display: inline-block;" ' + 'data-sorttype="numeric" data-sort="true">GS</div>' ); player_table.find("div.stam:not(#stam)").each(function(index){ let gs_array = team.getGS($(this).parent().attr('id')) let real_gs = Math.round(gs_array[0] * 100); let gs_reduced = gs_array[1]; $(this).after( '<div class="rgs field-col" style="width: 20px; display: inline-block; ' + 'color: ' + (gs_reduced ? 'darksalmon' : 'white') + '; background-color: black;" data-group="flskill">' + '<span data-sortvalue="' + real_gs +'"><font style="font-weight: bold;">' + real_gs + '</font></span></div>' ); }); } fillAdvancedOptions(team) { function createLabel(text){ return "<label>" + text + "</label>";} function createGrayFont(text){ return "<font style='color: gray;'>" + text + "</font>";} let advancedOptions = $("div#managerTabs div#adv_options"); let offsideDiv = advancedOptions.find("div[data-groupid='Offside_Trap']"); const offsideAtt = team.offside(Team.TACTICS.ATTACKING); const offsideDef = team.offside(Team.TACTICS.DEFENDING); offsideDiv.find("label").replaceWith(createLabel("<u>Gyorsaság:</u> " + offsideAtt[0] + " " + createGrayFont("(" + offsideDef[0] + ")"))); offsideDiv.find("label").after(createLabel("<u>Helyezkedés:</u> " + offsideAtt[1] + " " + createGrayFont("(" + offsideDef[1] + ")"))); let pressingDiv = advancedOptions.find("div[data-groupid='Pressing']"); pressingDiv.find("label").replaceWith(createLabel("<u>Gyorsaság:</u> " + team.full_speed())); pressingDiv.find("label").after(createLabel("<u>Szerelés:</u> " + team.full_tackling()) + createLabel("<u>Passz:</u> " + team.full_passing())); let counterDiv = advancedOptions.find("div[data-groupid='Counter_Attack']"); counterDiv.find("label").replaceWith(createLabel("<u>Gyorsaság:</u> " + team.full_speed())); counterDiv.find("label").after(createLabel("<u>Passz:</u> " + team.full_passing()) + createLabel("<u>Felállás</u>")); let highballsDiv = advancedOptions.find("div[data-groupid='High_Balls']"); highballsDiv.find("label").replaceWith(createLabel("<u>Fej:</u> " + team.full_heading() + " | <u>Erő:</u> " + team.full_strength())); let one_on_oneDiv = advancedOptions.find("div[data-groupid='One_on_Ones']"); one_on_oneDiv.find("label").replaceWith(createLabel("" + team.one_on_one(Team.TACTICS.ATTACKING) + " " + createGrayFont("(" + team.one_on_one(Team.TACTICS.DEFENDING) + ")"))); let keepingstyleDiv = advancedOptions.find("div[data-groupid='Keeping_Style']"); keepingstyleDiv.find("label").replaceWith(createLabel("<u>Vonal:</u> " + team.keeping_style_stand_in(Team.TACTICS.ATTACKING) + " " + createGrayFont("(" + team.keeping_style_stand_in(Team.TACTICS.DEFENDING) + ")"))); keepingstyleDiv.find("label").after(createLabel("<u>Kifut:</u> " + team.keeping_style_rushing_out(Team.TACTICS.ATTACKING) + " " + createGrayFont("(" + team.keeping_style_rushing_out(Team.TACTICS.DEFENDING) + ")"))); let markingDiv = advancedOptions.find("div[data-groupid='Marking']"); markingDiv.find("label").replaceWith(createLabel("<u>Ember:</u> " + team.marking_man_to_man(Team.TACTICS.ATTACKING) + " " + createGrayFont("(" + team.marking_man_to_man(Team.TACTICS.DEFENDING) + ")"))); markingDiv.find("label").after(createLabel("<u>Terület:</u> " + team.marking_zonal(Team.TACTICS.ATTACKING) + " " + createGrayFont("(" + team.marking_zonal(Team.TACTICS.DEFENDING) + ")"))); let longshotsDiv = advancedOptions.find("div[data-groupid='RematesLonge']"); longshotsDiv.find("label").replaceWith(createLabel("" + team.long_shots(Team.TACTICS.ATTACKING) + " " + createGrayFont("(" + team.long_shots(Team.TACTICS.DEFENDING) + ")"))); let ftsDiv = advancedOptions.find("div[data-groupid='RematesPrimeira']"); ftsDiv.find("label").replaceWith(createLabel("" + team.first_time_shots(Team.TACTICS.ATTACKING) + " " + createGrayFont("(" + team.first_time_shots(Team.TACTICS.DEFENDING) + ")"))); } colorAdvancedOptions() { function highlightElementIfSet(element) { const useGreen = element.find("span.ui-selectmenu-text").text() != element.parent().find("option[value='0']").text(); element.css({"font-weight": "Bold", "color": (useGreen ? "Green" : "Red")}); } // hint let advancedOptions = $("div#managerTabs div#adv_options"); let hint = advancedOptions.find("div[data-groupid='estilo_jogo']"); hint.before('<div class="adv-header-label" style="color: lightgray; font-weight: Bold">Értékek: Támadó ' + '<font style="color: #E7E7E7;">(Védekező)</font></div>'); // highlight selected options highlightElementIfSet(advancedOptions.find("span#Offside_Trap-button")); highlightElementIfSet(advancedOptions.find("span#Pressing-button")); highlightElementIfSet(advancedOptions.find("span#Counter_Attack-button")); highlightElementIfSet(advancedOptions.find("span#High_Balls-button")); highlightElementIfSet(advancedOptions.find("span#One_on_Ones-button")); highlightElementIfSet(advancedOptions.find("span#Keeping_Style-button")); highlightElementIfSet(advancedOptions.find("span#Marking-button")); highlightElementIfSet(advancedOptions.find("span#RematesLonge-button")); highlightElementIfSet(advancedOptions.find("span#RematesPrimeira-button")); highlightElementIfSet(advancedOptions.find("span#Preferred_Side-button")); highlightElementIfSet(advancedOptions.find("span#Team_Captain-button")); highlightElementIfSet(advancedOptions.find("span#pk1-button")); highlightElementIfSet(advancedOptions.find("span#Team_attitude-button")); } }; class Warnings { constructor(team) { let warningStr = ""; warningStr += Warnings.checkLaziness(); warningStr += Warnings.checkWrongSide(team); warningStr += Warnings.checkFtsSureFall(team); warningStr += Warnings.checkStaminaAbove80(team); if (warningStr.length) alert("Oldal betöltés utáni ellenőrzés:\n" + warningStr); } static checkLaziness() { const attitudeSpan = $("span#Team_attitude-button"); if (attitudeSpan.find("span.ui-selectmenu-text").text() == attitudeSpan.parent().find("option[value='1']").text()) return " - Laza játékot játszol!\n"; return ""; } static checkWrongSide(team) { function FilledMidAndAttSide(team, side) { return team.countForPositionAndSide(Player.POSITIONS.MIDFIELDER, side) > 0 && team.countForPositionAndSide(Player.POSITIONS.ATTACKER , side) > 0; } const sideSpan = $("span#Preferred_Side-button"); const sideNum = parseInt(sideSpan.parent().find("option").filter(function() { return $(this).text() === sideSpan.find("span.ui-selectmenu-text").text(); }).attr("value")); // check the sides - ALL should be filled let sideFilled = true; /* <option value="0">Átlagos</option> <option value="1">Bal</option> <option value="2">Közép</option> <option value="3">Jobb</option> <option value="4">Széleken támadás</option> <option value="5">Közép/Jobb</option> <option value="6">Közép/Bal</option> */ // sideNum == 0 -> All side, so ok if (sideNum == 1 || sideNum == 4 || sideNum == 6) // left sideFilled &= FilledMidAndAttSide(team, Player.SIDES.L); if (sideNum == 2 || sideNum == 5 || sideNum == 6) // middle sideFilled &= FilledMidAndAttSide(team, Player.SIDES.C); if (sideNum == 3 || sideNum == 4 || sideNum == 5) // right sideFilled &= FilledMidAndAttSide(team, Player.SIDES.R); if (!sideFilled) return " - Úgy tünik nem megfelelő oldalt használsz! Szándékos?\n"; return ""; } static checkFtsSureFall(team) { const ftsSpan = $("span#RematesPrimeira-button"); if (ftsSpan.find("span.ui-selectmenu-text").text() == ftsSpan.parent().find("option[value='1']").text() && team.countForPosition(Player.POSITIONS.ATTACKER) < 3) return " - Kapáslövést mindenképpen bukni fogod, mert nincs 3 csatárod!\n"; return ""; } static checkStaminaAbove80(team) { const error = " - Legalább egy játékosodnak 80% alatt van a fitnessze! Sose engedd 80 alá!\n"; for (let player of team.starting_eleven) if (player.fitness < 80) return error; for (let player of team.bench) if (player.fitness < 80) return error; return ""; } }; var loaded = false; function start() { if (loaded) return; loaded = true; Parser.load(); let team = new Team(Parser.starting_eleven, Parser.bench); let printer = new Printer(team); let warner = new Warnings(team); } $(window).load(function(){ start(); }); // workaround for $(window).load(function() function myTimer() { const starting_eleven = $("div#starting_eleven a"); if (starting_eleven.size () > 0 && starting_eleven.first().text().length > 0) { start(); console.log("The page is loaded, try to load the script!"); clearInterval(timer); } } var timer = setInterval(myTimer, 500);