您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
Trophymanager: calculate ALI (Average League Indicator) and the number of championships by teams. ALI show the average rank/division of the team. The smaller the ALI, the better the team's league record.
当前为
// ==UserScript== // @name TMVN League ALI // @namespace https://trophymanager.com // @version 3 // @description Trophymanager: calculate ALI (Average League Indicator) and the number of championships by teams. ALI show the average rank/division of the team. The smaller the ALI, the better the team's league record. // @match https://trophymanager.com/league/* // @grant none // ==/UserScript== (function () { 'use strict'; const APP_COLOR = { LEVEL_1: "Darkred", LEVEL_2: "Black", LEVEL_3: "Yellow", LEVEL_4: "Blue", LEVEL_5: "Aqua", LEVEL_6: "White" }; var clubLeagueMap = new Map(); var clubMap = new Map(); $('#overall_table td').each(function () { let clubId = $(this).children('a').attr('club_link'); if (clubId) { let clubName = $(this).children('a')[0].innerHTML; clubMap.set(clubId, clubName); } }); clubMap.forEach((value, key) => { $.ajax('https://trophymanager.com/history/club/league/' + key, { type: "GET", dataType: 'html', crossDomain: true, success: function (response) { var trArr = $('.zebra.hover.sortable tr', response); var totalAli = 0; var seasonCount = 0; var championMap = new Map(); for (var i = 1; i < trArr.length; i++) { var rank = trArr[i].lastElementChild.innerText; if (rank !== "") { seasonCount++; var division = trArr[i].children[1].innerText.substring(0, 1); if (rank == 1) { if (championMap.has(division)) { var championCount = championMap.get(division); championCount++; championMap.set(division, championCount); } else { championMap.set(division, 1); } } totalAli = totalAli + 18 * (parseInt(division) - 1) + parseInt(rank); } } var champion = ""; if (championMap.size > 0) { var championDivision = [...championMap.keys()].sort(); championDivision.forEach((div) => { if (div == 1) { champion += ("<span style = 'color: " + APP_COLOR.LEVEL_1 + ";'>" + div + "." + championMap.get(div) + " </span>"); } else if (div == 2) { champion += ("<span style = 'color: " + APP_COLOR.LEVEL_2 + ";'>" + div + "." + championMap.get(div) + " </span>"); } else if (div == 3) { champion += ("<span style = 'color: " + APP_COLOR.LEVEL_3 + ";'>" + div + "." + championMap.get(div) + " </span>"); } else if (div == 4) { champion += ("<span style = 'color: " + APP_COLOR.LEVEL_4 + ";'>" + div + "." + championMap.get(div) + " </span>"); } else if (div == 5) { champion += ("<span style = 'color: " + APP_COLOR.LEVEL_5 + ";'>" + div + "." + championMap.get(div) + " </span>"); } else { champion += ("<span style = 'color: " + APP_COLOR.LEVEL_6 + ";'>" + div + "." + championMap.get(div) + " </span>"); } }); } var ali = ""; if (seasonCount > 0) { var aliAverage = Math.round(totalAli / seasonCount); var divisionAverage = Math.ceil(aliAverage / 18); var rankAverage = aliAverage - (18 * (divisionAverage - 1)); if (divisionAverage == 1) { ali = ("<span style = 'color: " + APP_COLOR.LEVEL_1 + ";'>" + aliAverage + " (" + divisionAverage + "." + rankAverage + ") </span>"); } else if (divisionAverage == 2) { ali = ("<span style = 'color: " + APP_COLOR.LEVEL_2 + ";'>" + aliAverage + " (" + divisionAverage + "." + rankAverage + ") </span>"); } else if (divisionAverage == 3) { ali = ("<span style = 'color: " + APP_COLOR.LEVEL_3 + ";'>" + aliAverage + " (" + divisionAverage + "." + rankAverage + ") </span>"); } else if (divisionAverage == 4) { ali = ("<span style = 'color: " + APP_COLOR.LEVEL_4 + ";'>" + aliAverage + " (" + divisionAverage + "." + rankAverage + ") </span>"); } else if (divisionAverage == 5) { ali = ("<span style = 'color: " + APP_COLOR.LEVEL_5 + ";'>" + aliAverage + " (" + divisionAverage + "." + rankAverage + ") </span>"); } else { ali = ("<span style = 'color: " + APP_COLOR.LEVEL_6 + ";'>" + aliAverage + " (" + divisionAverage + "." + rankAverage + ") </span>"); } } clubLeagueMap.set(key, { "ALI": ali, "Champion": champion, "SeasonCount": seasonCount }); }, error: function (e) {} }); }); var myInterval = setInterval(append, 1000); function append() { if (clubLeagueMap.size < 18) { return; } clearInterval(myInterval); /*APPEND ALI TABLE*/ let ali = "<div class=\"box\">" + "<div class=\"box_head\">" + "<h2 class=\"std\">Average League Indicator</h2>" + "</div>" + "<div class=\"box_body\">" + "<div class=\"box_shadow\"></div>" + "<div id=\"ali_content\" class=\"content_menu\"></div>" + "</div>" + "<div class=\"box_footer\">" + "<div></div>" + "</div>" + "</div>"; $(".column3_a").append(ali); let ali_content = "<table>" + "<tr><th>Club</th><th align='right'>ALI</th><th align='right'>Champion</th></tr>"; let rowCount = 0; clubMap.forEach((value, key) => { rowCount++; let classOdd = ""; if ((rowCount % 2) == 1) { classOdd = "class='odd'"; } if (clubLeagueMap.has(key)) { let clubLeague = clubLeagueMap.get(key); value = '<span style="color:Orange;">' + clubLeague.SeasonCount + '.</span>' + value; ali_content += "<tr " + classOdd + "><td><span onclick = \"window.open(\'https:\/\/trophymanager.com\/history\/club\/league\/" + key + "\')\">" + value + "</span></td><td align='right'>" + clubLeague.ALI + "</td><td align='right'><span style='color:Orange;'>" + clubLeague.Champion + "</span></td></tr>"; } else { ali_content += "<tr " + classOdd + "><td><span onclick = \"window.open(\'https:\/\/trophymanager.com\/history\/club\/league\/" + key + "\')\">" + value + "</span></td><td></td><td></td><td></td></tr>"; } }); ali_content += "</table>"; $("#ali_content").append(ali_content); } })();