NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name S49SklsRouCalcPlyr // @description In TrophyManager.com S49 Skills + Routine Calculator Player Page calculates routine contribution and adds it to player skills // @author Long Coast United // @include http://trophymanager.com/players/* // @include https://trophymanager.com/players/* // @exclude http://trophymanager.com/players/ // @exclude http://trophymanager.com/players/compare // @exclude http://trophymanager.com/players/compare/ // @exclude http://trophymanager.com/players/compare/* // @exclude https://trophymanager.com/players/ // @exclude https://trophymanager.com/players/compare // @exclude https://trophymanager.com/players/compare/ // @exclude https://trophymanager.com/players/compare/* // ==/UserScript== // save routine into variable and add routine toggle button: var routineTbl = document.getElementsByClassName("float_left info_table zebra")[0]; var tRows = routineTbl.getElementsByTagName("tr"); var tCells = routineTbl.getElementsByTagName("td"); var tRow, tcell, routine; for (var i = 0; i < tRows.length; i++) { tRow = tRows[i]; tCell = tCells[i]; if (tRow.innerHTML.includes("Routine")) { routine = tCell.innerHTML; tCell.innerHTML = tCell.innerHTML + " | " + "<span id='routineToggle' class='button'><span class='button_border' style='width: 90px; text-transform: none;'>Dodaj rutino</span></span>"; } } // add event to routine toggle button: document.getElementById("routineToggle").addEventListener("click", toggleRoutine, false); // save default documement object content to variable: var defaultSkillTbl = document.getElementsByClassName("skill_table zebra")[0].innerHTML; // apply routine to skills: var skillTbl = document.getElementsByClassName("skill_table zebra")[0]; function applyRoutine() { // calculate routine to skills: var tSkillCells = skillTbl.getElementsByClassName("align_center"); var tSkillCell; for (var i = 0; i < tSkillCells.length; i++) { tSkillCell = tSkillCells[i]; if (0 < parseInt(tSkillCell.innerHTML) && parseInt(tSkillCell.innerHTML) < 19) { tSkillCell.innerHTML = (Math.round((parseInt(tSkillCell.innerHTML) + routine / 16.666666667) * 100) / 100); } else { tSkillCell.innerHTML = (Math.round((parseInt(tSkillCell.innerHTML.replace(/(^.+\D)(\d+)(\D.+$)/i, '$2')) + routine / 16.666666667) * 100) / 100); } dyeSkills(tSkillCell); } } // colour skills depending on their value function dyeSkills(tSkillCell) { if (24 <= parseInt(tSkillCell.innerHTML)) tSkillCell.style.color = "#FF4500"; if (22 <= parseInt(tSkillCell.innerHTML) && parseInt(tSkillCell.innerHTML) < 24) tSkillCell.style.color = "#FFA500"; if (20 <= parseInt(tSkillCell.innerHTML) && parseInt(tSkillCell.innerHTML) < 22) tSkillCell.style.color = "#FFD700"; if (15 <= parseInt(tSkillCell.innerHTML) && parseInt(tSkillCell.innerHTML) < 20) tSkillCell.style.color = "#FFFF00"; if (5 <= parseInt(tSkillCell.innerHTML) && parseInt(tSkillCell.innerHTML) < 10) tSkillCell.style.opacity = "0.75"; if (1 <= parseInt(tSkillCell.innerHTML) && parseInt(tSkillCell.innerHTML) < 5) tSkillCell.style.opacity = "0.5"; } // add/remove routine to/from skills: function toggleRoutine() { if (document.getElementById("routineToggle").innerHTML.includes("Dodaj")) { applyRoutine(); document.getElementById("routineToggle").innerHTML = "<span class='button_border' style='width: 90px; text-transform: none;'>Odstrani rutino</span>"; } else if (document.getElementById("routineToggle").innerHTML.includes("Odstrani")) { skillTbl.innerHTML = defaultSkillTbl; document.getElementById("routineToggle").innerHTML = "<span class='button_border' style='width: 90px; text-transform: none;'>Dodaj rutino</span>"; } else { alert("POZOR: Skripta morda ne deluje pravilno!"); } }