// ==UserScript== // @name TMVN League ALI // @namespace https://trophymanager.com // @version 1 // @description Trophymanager: calculate ALI (Achievement League Index) and count the championships of teams. So you can easy find rich achievements teams in the countries. // @match https://trophymanager.com/league/* // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; const ALI_MAP = new Map() .set("1.1", 5508).set("1.2", 3564).set("1.3", 2355) .set("2.1", 510).set("2.2", 330).set("2.3", 218) .set("3.1", 68).set("3.2", 44).set("3.3", 29) .set("4.1", 14).set("4.2", 9).set("4.3", 6) .set("5.1", 5).set("5.2", 3).set("5.3", 2) .set("6.1", 4).set("6.2", 2).set("6.3", 1); var clubDatas = 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) { let trArr = $('.zebra.hover.sortable tr', response); var ali = 0; var champion = ""; 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); } } if (rank <= 3 && division <= 3) { ali += ALI_MAP.get(division + "." + rank); } } } if (championMap.size > 0) { var championDivision = [...championMap.keys()].sort(); championDivision.forEach((div) => { champion += (div + "." + championMap.get(div) + " "); }); } clubDatas.set(key, { "ALI": ali, "Champion": champion, "SeasonCount": seasonCount }); }, error: function (e) {} }); }); var myInterval = setInterval(append, 1000); function append() { if (clubDatas.size < 18) { return; } clearInterval(myInterval); /*APPEND ALI TABLE*/ let ali = "
Club | ALI | Champion |
---|---|---|
" + value + " | " + clubData.ALI.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " | " + clubData.Champion + " |
" + value + " |