TMVN InternationalCup Champion

Trophymanager: count the number of championships by teams in current tournament, to see successful teams on the continental arena.

  1. // ==UserScript==
  2. // @name TMVN InternationalCup Champion
  3. // @namespace https://trophymanager.com
  4. // @version 5
  5. // @description Trophymanager: count the number of championships by teams in current tournament, to see successful teams on the continental arena.
  6. // @include /https://trophymanager.com/international-cup/\d/
  7. // @match https://trophymanager.com/international-cup/
  8. // @match https://trophymanager.com/international-cup
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. const LEAGUE_CHAM_TEXT = ['Champion of UETA Champions Cup', 'Champion of FITA RoW League', 'Champion of FATA Liberty League'];
  16. const CUP_CHAM_TEXT = ['Champion of UETA Cup', 'Champion of FITA RoW Cup', 'Champion of FATA Copa Americana'];
  17.  
  18. var clubLeagueMap = new Map();
  19. var clubCupMap = new Map();
  20. var clubFlagMap = new Map();
  21. var clubMap = new Map();
  22. var sortMap = new Map();
  23.  
  24. $('a[club_link]').each(function () {
  25. let clubId = this.getAttribute("club_link");
  26. if (!clubMap.has(clubId)) {
  27. clubMap.set(clubId, this.innerText);
  28. }
  29. });
  30.  
  31. var clubCount = clubMap.size;
  32.  
  33. clubMap.forEach((value, key) => {
  34. $.ajax('https://trophymanager.com/club/' + key, {
  35. type: "GET",
  36. dataType: 'html',
  37. crossDomain: true,
  38. success: function (response) {
  39. var hasPro = $('.column2_a a img[class="pro_icon"]', response).length == 0 ? false : true;
  40. let leagueCount = 0;
  41. let cupCount = 0;
  42. if (hasPro) { //search by image will be more accurate
  43. let divArr = $('.column3_a .box_body .std .clearfix', response);
  44. for (let i = 0; i < divArr.length; i++) {
  45. let style = divArr[i].children[0].getAttribute("style");
  46. if (style.indexOf('/1_75pct.png') > -1 || style.indexOf('/1_40pct.png') > -1) {
  47. leagueCount++;
  48. } else if (style.indexOf('/4_75pct.png') > -1 || style.indexOf('/4_40pct.png') > -1) {
  49. cupCount++;
  50. }
  51. }
  52. } else {
  53. let liArr = $('.zebra.nopro_list li', response);
  54. for (let i = 0; i < liArr.length; i++) {
  55. let liText = liArr[i].innerText;
  56. if (LEAGUE_CHAM_TEXT.includes(liText)) {
  57. leagueCount++;
  58. } else if (CUP_CHAM_TEXT.includes(liText)) {
  59. cupCount++;
  60. }
  61. }
  62. }
  63.  
  64. let flagHTML = $('.country_link:first', response)[0].innerHTML;
  65. clubFlagMap.set(key, flagHTML);
  66. clubLeagueMap.set(key, leagueCount);
  67. clubCupMap.set(key, cupCount);
  68.  
  69. if (leagueCount * 1000 + cupCount > 0) {
  70. sortMap.set(key, leagueCount * 1000 + cupCount);
  71. }
  72. },
  73. error: function (e) {}
  74. });
  75. });
  76.  
  77. var myInterval = setInterval(append, 1000);
  78.  
  79. function append() {
  80. if (clubLeagueMap.size < clubCount || clubCupMap.size < clubCount) {
  81. return;
  82. }
  83. clearInterval(myInterval);
  84.  
  85. sortMap[Symbol.iterator] = function * () {
  86. yield * [...this.entries()].sort((a, b) => b[1] - a[1]);
  87. }
  88.  
  89. /*APPEND CHAMPION HISTORY TABLE*/
  90. let champion =
  91. "<div class=\"box\">" +
  92. "<div class=\"box_head\">" +
  93. "<h2 class=\"std\">ACTIVE CHAMPION</h2>" +
  94. "</div>" +
  95. "<div class=\"box_body\">" +
  96. "<div class=\"box_shadow\"></div>" +
  97. "<div id=\"champion_content\" class=\"content_menu\"></div>" +
  98. "</div>" +
  99. "<div class=\"box_footer\">" +
  100. "<div></div>" +
  101. "</div>" +
  102. "</div>";
  103. $(".column3_a .box")[0].innerHTML = champion + $(".column3_a .box")[0].innerHTML;
  104.  
  105. let champion_content = "<table>" +
  106. "<tr><th>#</th><th></th><th>Club</th><th align='right'>League</th><th align='right'>Cup</th></tr>";
  107. let rowCount = 0;
  108. for (let[key, value]of sortMap) {
  109. rowCount++;
  110. let classOdd = "";
  111. if ((rowCount % 2) == 1) {
  112. classOdd = "class='odd'";
  113. }
  114. let flagHTML = clubFlagMap.get(key);
  115. let clubName = clubMap.get(key);
  116. let leagueCount = clubLeagueMap.get(key);
  117. let cupCount = clubCupMap.get(key);
  118.  
  119. champion_content += "<tr " + classOdd + ">" +
  120. "<td>" + rowCount + "</td>" +
  121. "<td>" + flagHTML + "</td>" +
  122. "<td><span onclick = \"window.open(\'https:\/\/trophymanager.com\/club\/" + key + "\')\">" + clubName + "</td>" +
  123. "<td align='right'>" + (leagueCount > 0 ? leagueCount : "") + "</td>" +
  124. "<td align='right'>" + (cupCount > 0 ? cupCount : "") + "</td>" +
  125. "</tr>";
  126. }
  127. champion_content += "</table>";
  128. $("#champion_content").append(champion_content);
  129. }
  130. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址