MouseHunt - Birthday Map Color Coder 2020

Color codes mice on birthday maps according to decorations // & cheese. Based off tsitu's work.

当前为 2020-03-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MouseHunt - Birthday Map Color Coder 2020
  3. // @author Vinnie, Blende & Tran Situ (tsitu)
  4. // @version 1.0.4
  5. // @description Color codes mice on birthday maps according to decorations // & cheese. Based off tsitu's work.
  6. // @match http://www.mousehuntgame.com/*
  7. // @match https://www.mousehuntgame.com/*
  8. // @namespace https://greasyfork.org/en/scripts/397287-mousehunt-birthday-map-color-coder-2020
  9. // ==/UserScript==
  10.  
  11. const mixingMice = [
  12. "Force Fighter Blue",
  13. "Force Fighter Green",
  14. "Force Fighter Pink",
  15. "Force Fighter Red",
  16. "Force Fighter Yellow",
  17. "Super FighterBot MegaSupreme",
  18. ];
  19.  
  20. const breakMice = [
  21. "Breakdancer",
  22. "Fete Fromager",
  23. "Dance Party",
  24. "El Flamenco",
  25. "Para Para Dancer"
  26. ];
  27.  
  28. const pumpMice = [
  29. "Reality Restitch",
  30. "Time Punk",
  31. "Time Tailor",
  32. "Time Thief"
  33. ];
  34.  
  35. const qaMice = [
  36. "Cupcake Candle Thief",
  37. "Cupcake Cutie",
  38. "Sprinkly Sweet Cupcake Cook",
  39. "Cupcake Camo",
  40. "Cupcake Runner"
  41. ];
  42.  
  43. const bossMice = [
  44. "Vincent, The Magnificent"
  45. ];
  46.  
  47. const sbMice = [
  48. "Cheese Party"
  49. ];
  50.  
  51. const standardMice = [
  52. "Birthday",
  53. "Buckethead",
  54. "Present",
  55. "Pintail",
  56. "Dinosuit",
  57. "Sleepwalker",
  58. "Terrible Twos"
  59. ];
  60.  
  61. const birthdayMaps = [
  62. "Rare Birthday Event Map",
  63. "Birthday Event Map",
  64. "Rare Gilded Birthday Event Map",
  65. "Gilded Birthday Event Map",
  66. ];
  67.  
  68. function colorize() {
  69. let mixingColor = "#c97c49"; // brown-ish
  70. let mixingCount = 0;
  71. let breakColor = "#f06a60"; // red
  72. let breakCount = 0;
  73. let pumpColor = "#5ae031"; // green
  74. let pumpCount = 0;
  75. let qaColor = "#4fcaf0"; // blue
  76. let qaCount = 0;
  77. let bossColor = "#cd87ff"; // light purple
  78. let bossCount = 0;
  79. let sbColor = "#66ffff"; // teal-ish
  80. let sbCount = 0;
  81. let standardColor = "#afa500"; // mountain dew-ish
  82. let standardCount = 0;
  83. const greyColor = "#949494";
  84.  
  85. const isChecked =
  86. localStorage.getItem("highlightPref") === "uncaught-only" ? true : false;
  87. const isCheckedStr = isChecked ? "checked" : "";
  88.  
  89. if (
  90. document.querySelectorAll(".treasureMapView-goals-group-goal").length === 0
  91. ) {
  92. return;
  93. }
  94.  
  95. document.querySelectorAll(".treasureMapView-goals-group-goal").forEach(el => {
  96. el.querySelector("span").style = "color: black; font-size: 11px;";
  97.  
  98. const mouseName = el.querySelector(".treasureMapView-goals-group-goal-name")
  99. .textContent;
  100.  
  101. if (mixingMice.indexOf(mouseName) > -1) {
  102. el.style.backgroundColor = mixingColor;
  103. if (el.className.indexOf(" complete ") < 0) {
  104. mixingCount++;
  105. } else {
  106. if (isChecked) el.style.backgroundColor = "white";
  107. }
  108. } else if (breakMice.indexOf(mouseName) > -1) {
  109. el.style.backgroundColor = breakColor;
  110. if (el.className.indexOf(" complete ") < 0) {
  111. breakCount++;
  112. } else {
  113. if (isChecked) el.style.backgroundColor = "white";
  114. }
  115. } else if (pumpMice.indexOf(mouseName) > -1) {
  116. el.style.backgroundColor = pumpColor;
  117. if (el.className.indexOf(" complete ") < 0) {
  118. pumpCount++;
  119. } else {
  120. if (isChecked) el.style.backgroundColor = "white";
  121. }
  122. } else if (qaMice.indexOf(mouseName) > -1) {
  123. el.style.backgroundColor = qaColor;
  124. if (el.className.indexOf(" complete ") < 0) {
  125. qaCount++;
  126. } else {
  127. if (isChecked) el.style.backgroundColor = "white";
  128. }
  129. } else if (bossMice.indexOf(mouseName) > -1) {
  130. el.style.backgroundColor = bossColor;
  131. if (el.className.indexOf(" complete ") < 0) {
  132. bossCount++;
  133. } else {
  134. if (isChecked) el.style.backgroundColor = "white";
  135. }
  136. } else if (sbMice.indexOf(mouseName) > -1) {
  137. el.style.backgroundColor = sbColor;
  138. if (el.className.indexOf(" complete ") < 0) {
  139. sbCount++;
  140. } else {
  141. if (isChecked) el.style.backgroundColor = "white";
  142. }
  143. } else if (standardMice.indexOf(mouseName) > -1) {
  144. el.style.backgroundColor = standardColor;
  145. if (el.className.indexOf(" complete ") < 0) {
  146. standardCount++;
  147. } else {
  148. if (isChecked) el.style.backgroundColor = "white";
  149. }
  150. }
  151. });
  152.  
  153. pumpColor = pumpCount > 0 ? pumpColor : greyColor;
  154. breakColor = breakCount > 0 ? breakColor : greyColor;
  155. pumpColor = pumpCount > 0 ? pumpColor : greyColor;
  156. qaColor = qaCount > 0 ? qaColor : greyColor;
  157. bossColor = bossCount > 0 ? bossColor : greyColor;
  158. sbColor = sbCount > 0 ? sbColor : greyColor;
  159. standardColor = standardCount > 0 ? standardColor : greyColor;
  160.  
  161. // Remove existing birthday Map related elements before proceeding
  162. document.querySelectorAll(".tsitu-birthday-map").forEach(el => el.remove());
  163.  
  164. const masterDiv = document.createElement("div");
  165. masterDiv.className = "tsitu-birthday-map";
  166. masterDiv.style =
  167. "display: inline-flex; margin-bottom: 10px; width: 100%; text-align: center; line-height: 1.5; overflow: hidden";
  168. const spanStyle =
  169. "; width: auto; padding: 5px; font-weight: bold; font-size: 12.5px";
  170.  
  171. const mixingSpan = document.createElement("span");
  172. mixingSpan.style = "background-color: " + mixingColor + spanStyle;
  173. mixingSpan.innerHTML = "Mixing<br>" + mixingCount;
  174.  
  175. const breakSpan = document.createElement("span");
  176. breakSpan.style = "background-color: " + breakColor + spanStyle;
  177. breakSpan.innerHTML = "Break<br>" + breakCount;
  178.  
  179. const pumpSpan = document.createElement("span");
  180. pumpSpan.style = "background-color: " + pumpColor + spanStyle;
  181. pumpSpan.innerHTML = "Pump<br>" + pumpCount;
  182.  
  183. const qaSpan = document.createElement("span");
  184. qaSpan.style = "background-color: " + qaColor + spanStyle;
  185. qaSpan.innerHTML = "QA<br>" + qaCount;
  186.  
  187. const vinnieSpan = document.createElement("span");
  188. vinnieSpan.style = "background-color: " + bossColor + spanStyle;
  189. vinnieSpan.innerHTML = "Vinnie<br>" + bossCount;
  190.  
  191. const sbSpan = document.createElement("span");
  192. sbSpan.style = "background-color: " + sbColor + spanStyle;
  193. sbSpan.innerHTML = "SB+<br>" + sbCount;
  194.  
  195. const standardSpan = document.createElement("span");
  196. standardSpan.style = "background-color: " + standardColor + spanStyle;
  197. standardSpan.innerHTML = "Standard<br>" + standardCount;
  198.  
  199. // Highlight uncaught only feature
  200. const highlightLabel = document.createElement("label");
  201. highlightLabel.htmlFor = "tsitu-highlight-box";
  202. highlightLabel.innerText = "Highlight uncaught mice only";
  203.  
  204. const highlightBox = document.createElement("input");
  205. highlightBox.type = "checkbox";
  206. highlightBox.name = "tsitu-highlight-box";
  207. highlightBox.style.verticalAlign = "middle";
  208. highlightBox.checked = isChecked;
  209. highlightBox.addEventListener("click", function() {
  210. if (highlightBox.checked) {
  211. localStorage.setItem("highlightPref", "uncaught-only");
  212. } else {
  213. localStorage.setItem("highlightPref", "all");
  214. }
  215. colorize();
  216. });
  217.  
  218. const highlightDiv = document.createElement("div");
  219. highlightDiv.className = "tsitu-birthday-map";
  220. highlightDiv.style =
  221. "margin-bottom: 5px; width: 35%; border: 1px dotted black";
  222. highlightDiv.appendChild(highlightBox);
  223. highlightDiv.appendChild(highlightLabel);
  224.  
  225. // Assemble masterDiv
  226. masterDiv.appendChild(mixingSpan);
  227. masterDiv.appendChild(breakSpan);
  228. masterDiv.appendChild(pumpSpan);
  229. masterDiv.appendChild(qaSpan);
  230. masterDiv.appendChild(vinnieSpan);
  231. // masterDiv.appendChild(glazySpan);
  232. // masterDiv.appendChild(pecanSpan);
  233. masterDiv.appendChild(sbSpan);
  234. masterDiv.appendChild(standardSpan);
  235.  
  236. // Inject into DOM
  237. const insertEl = document.querySelector(
  238. ".treasureMapView-leftBlock .treasureMapView-block-content"
  239. );
  240. if (
  241. insertEl &&
  242. document.querySelector(
  243. ".treasureMapManagerView-header-navigation-item.tasks.active"
  244. )
  245. ) {
  246. insertEl.insertAdjacentElement("afterbegin", highlightDiv);
  247. insertEl.insertAdjacentElement("afterbegin", masterDiv);
  248. }
  249.  
  250. // "Goals" button
  251. document.querySelector("[data-type='show_goals']").onclick = function() {
  252. colorize();
  253. };
  254. }
  255.  
  256. // Listen to XHRs, opening a map always at least triggers board.php
  257. const originalOpen = XMLHttpRequest.prototype.open;
  258. XMLHttpRequest.prototype.open = function() {
  259. this.addEventListener("load", function() {
  260. const mapEl = document.querySelector(
  261. ".treasureMapManagerView-task.active .treasureMapManagerView-task-name"
  262. );
  263. if (mapEl) {
  264. const mapName = mapEl.textContent;
  265. if (mapName && birthdayMaps.indexOf(mapName) > -1) {
  266. colorize();
  267. }
  268. }
  269. });
  270. originalOpen.apply(this, arguments);
  271. };