// ==UserScript== // @name TM Skill Index Calculator // @namespace https://trophymanager.com // @version 1.0 // @description TrophyManager: Calculate future skill index (SI) & skill sum // @author UNITE eM (Club ID: 551050) // @namespace https://trophymanager.com // @match https://trophymanager.com/players/* // @exclude https://trophymanager.com/players/ // @exclude https://trophymanager.com/players/compare/* // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function () { "use strict"; let skillIndexCalculator = "
" + "
" + "

Skill Index Calculator

" + "
" + "
" + "
" + "
" + "
" + "" + "
"; $(".column3_a").prepend(skillIndexCalculator); var gettr = document.getElementsByClassName("float_left info_table zebra")[0].getElementsByTagName("tr"); for (let i = 0; i < gettr.length; i++) { if (gettr[i].getElementsByTagName("th").length > 0) { if (gettr[i].getElementsByTagName("th")[0].innerHTML == global_content["skill_index"]) { var SI = gettr[i].getElementsByTagName("td")[0].innerHTML; break; } } } for (let i = 0; i < gettr.length; i++) { if (gettr[i].getElementsByTagName("th").length > 0) { if (gettr[i].getElementsByTagName("th")[0].innerHTML == global_content["age"]) { var ageMonth = parseInt(gettr[i].getElementsByTagName("td")[0].innerHTML.split(" ")[2]); break; } } } let trainingInputTable = "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
Current Skill Index (SI)Training SessionsTraining Intensity (TI)
"; $("#skillIndexCalculator_content").append(trainingInputTable); document.getElementById("addRow_button").addEventListener("click", (e) => { addRow(); }); document.getElementById("doCalculate_button").addEventListener("click", (e) => { doCalculate(); }); function addRow() { var trainingInputRow = "" + "" + "" + "" + "" + ""; $("#trainingInput_table").append(trainingInputRow); } function doCalculate() { var MR = Math.round; var MP = Math.pow; var ML = Math.log; var elem = document.getElementById("skillIndexCalculator_content"); while (elem.childElementCount > 1) { elem.removeChild(elem.lastChild); } var notGK = document.getElementsByClassName("favposition long")[0].innerText != global_content["goalkeeper"] ? true: false; var currentSI = document.getElementsByName("currentSkillIndex")[0].value.replace(/,/g, ""); var currentSkillSum = ""; if (notGK) { currentSkillSum = MR(MP(currentSI * MP(2, 9) * MP(5, 4) * MP(7, 7), 1 / 7) * 10) / 10; } else { currentSkillSum = MR((MP(currentSI * MP(2, 9) * MP(5, 4) * MP(7, 7), 1 / 7) / 14) * 11 * 10) / 10; } var futureSkillSum = currentSkillSum; for (let i = 0; i < document.getElementsByName("trainingSession").length; i++) { var session = document.getElementsByName("trainingSession")[i].value; if (session > 0) { var TI = document.getElementsByName("trainingIntensity")[i].value; futureSkillSum = MR((futureSkillSum + (TI / 10) * session) * 10) / 10; } } var futureSI = ""; if (notGK) { futureSI = MR(MP(futureSkillSum, 7) / (MP(2, 9) * MP(5, 4) * MP(7, 7))); } else { futureSI = MR(MP((futureSkillSum / 11) * 14, 7) / (MP(2, 9) * MP(5, 4) * MP(7, 7))); } let trainingOutputTable = "
"; let currentSkillSumRow = "Current Skill Sum" + currentSkillSum.toFixed(1) + ""; let futureSkillSumRow = "Future Skill Sum" + futureSkillSum.toFixed(1) + ""; let futureSIRow = "Future Skill Index (SI)" + addCommas(futureSI) + ""; $("#skillIndexCalculator_content").append(trainingOutputTable); $("#trainingOutput_table").append(currentSkillSumRow, futureSkillSumRow, futureSIRow); } function addCommas(num) { var numParts = num.toString().split("."); numParts[0] = numParts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); return numParts.join("."); } })();