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.3
  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. ];
  66.  
  67. function colorize() {
  68. let mixingColor = "#c97c49"; // brown-ish
  69. let mixingCount = 0;
  70. let breakColor = "#f06a60"; // red
  71. let breakCount = 0;
  72. let pumpColor = "#5ae031"; // green
  73. let pumpCount = 0;
  74. let qaColor = "#4fcaf0"; // blue
  75. let qaCount = 0;
  76. let bossColor = "#cd87ff"; // light purple
  77. let bossCount = 0;
  78. let sbColor = "#66ffff"; // teal-ish
  79. let sbCount = 0;
  80. let standardColor = "#afa500"; // mountain dew-ish
  81. let standardCount = 0;
  82. const greyColor = "#949494";
  83.  
  84. const isChecked =
  85. localStorage.getItem("highlightPref") === "uncaught-only" ? true : false;
  86. const isCheckedStr = isChecked ? "checked" : "";
  87.  
  88. if (
  89. document.querySelectorAll(".treasureMapView-goals-group-goal").length === 0
  90. ) {
  91. return;
  92. }
  93.  
  94. document.querySelectorAll(".treasureMapView-goals-group-goal").forEach(el => {
  95. el.querySelector("span").style = "color: black; font-size: 11px;";
  96.  
  97. const mouseName = el.querySelector(".treasureMapView-goals-group-goal-name")
  98. .textContent;
  99.  
  100. if (mixingMice.indexOf(mouseName) > -1) {
  101. el.style.backgroundColor = mixingColor;
  102. if (el.className.indexOf(" complete ") < 0) {
  103. mixingCount++;
  104. } else {
  105. if (isChecked) el.style.backgroundColor = "white";
  106. }
  107. } else if (breakMice.indexOf(mouseName) > -1) {
  108. el.style.backgroundColor = breakColor;
  109. if (el.className.indexOf(" complete ") < 0) {
  110. breakCount++;
  111. } else {
  112. if (isChecked) el.style.backgroundColor = "white";
  113. }
  114. } else if (pumpMice.indexOf(mouseName) > -1) {
  115. el.style.backgroundColor = pumpColor;
  116. if (el.className.indexOf(" complete ") < 0) {
  117. pumpCount++;
  118. } else {
  119. if (isChecked) el.style.backgroundColor = "white";
  120. }
  121. } else if (qaMice.indexOf(mouseName) > -1) {
  122. el.style.backgroundColor = qaColor;
  123. if (el.className.indexOf(" complete ") < 0) {
  124. qaCount++;
  125. } else {
  126. if (isChecked) el.style.backgroundColor = "white";
  127. }
  128. } else if (bossMice.indexOf(mouseName) > -1) {
  129. el.style.backgroundColor = bossColor;
  130. if (el.className.indexOf(" complete ") < 0) {
  131. bossCount++;
  132. } else {
  133. if (isChecked) el.style.backgroundColor = "white";
  134. }
  135. } else if (sbMice.indexOf(mouseName) > -1) {
  136. el.style.backgroundColor = sbColor;
  137. if (el.className.indexOf(" complete ") < 0) {
  138. sbCount++;
  139. } else {
  140. if (isChecked) el.style.backgroundColor = "white";
  141. }
  142. } else if (standardMice.indexOf(mouseName) > -1) {
  143. el.style.backgroundColor = standardColor;
  144. if (el.className.indexOf(" complete ") < 0) {
  145. standardCount++;
  146. } else {
  147. if (isChecked) el.style.backgroundColor = "white";
  148. }
  149. }
  150. });
  151.  
  152. pumpColor = pumpCount > 0 ? pumpColor : greyColor;
  153. breakColor = breakCount > 0 ? breakColor : greyColor;
  154. pumpColor = pumpCount > 0 ? pumpColor : greyColor;
  155. qaColor = qaCount > 0 ? qaColor : greyColor;
  156. bossColor = bossCount > 0 ? bossColor : greyColor;
  157. sbColor = sbCount > 0 ? sbColor : greyColor;
  158. standardColor = standardCount > 0 ? standardColor : greyColor;
  159.  
  160. // Remove existing birthday Map related elements before proceeding
  161. document.querySelectorAll(".tsitu-birthday-map").forEach(el => el.remove());
  162.  
  163. const masterDiv = document.createElement("div");
  164. masterDiv.className = "tsitu-birthday-map";
  165. masterDiv.style =
  166. "display: inline-flex; margin-bottom: 10px; width: 100%; text-align: center; line-height: 1.5; overflow: hidden";
  167. const spanStyle =
  168. "; width: auto; padding: 5px; font-weight: bold; font-size: 12.5px";
  169.  
  170. const sportSpan = document.createElement("span");
  171. sportSpan.style = "background-color: " + pumpColor + spanStyle;
  172. sportSpan.innerHTML = "Mixing<br>" + pumpCount;
  173.  
  174. const toySpan = document.createElement("span");
  175. toySpan.style = "background-color: " + breakColor + spanStyle;
  176. toySpan.innerHTML = "Break<br>" + breakCount;
  177.  
  178. const ornamentalSpan = document.createElement("span");
  179. ornamentalSpan.style = "background-color: " + pumpColor + spanStyle;
  180. ornamentalSpan.innerHTML = "Pump<br>" + pumpCount;
  181.  
  182. const snowSpan = document.createElement("span");
  183. snowSpan.style = "background-color: " + qaColor + spanStyle;
  184. snowSpan.innerHTML = "QA<br>" + qaCount;
  185.  
  186. const fireworksSpan = document.createElement("span");
  187. fireworksSpan.style = "background-color: " + bossColor + spanStyle;
  188. fireworksSpan.innerHTML = "Vinnie<br>" + bossCount;
  189.  
  190. const sbSpan = document.createElement("span");
  191. sbSpan.style = "background-color: " + sbColor + spanStyle;
  192. sbSpan.innerHTML = "SB+<br>" + sbCount;
  193.  
  194. const standardSpan = document.createElement("span");
  195. standardSpan.style = "background-color: " + standardColor + spanStyle;
  196. standardSpan.innerHTML = "Standard<br>" + standardCount;
  197.  
  198. // Highlight uncaught only feature
  199. const highlightLabel = document.createElement("label");
  200. highlightLabel.htmlFor = "tsitu-highlight-box";
  201. highlightLabel.innerText = "Highlight uncaught mice only";
  202.  
  203. const highlightBox = document.createElement("input");
  204. highlightBox.type = "checkbox";
  205. highlightBox.name = "tsitu-highlight-box";
  206. highlightBox.style.verticalAlign = "middle";
  207. highlightBox.checked = isChecked;
  208. highlightBox.addEventListener("click", function() {
  209. if (highlightBox.checked) {
  210. localStorage.setItem("highlightPref", "uncaught-only");
  211. } else {
  212. localStorage.setItem("highlightPref", "all");
  213. }
  214. colorize();
  215. });
  216.  
  217. const highlightDiv = document.createElement("div");
  218. highlightDiv.className = "tsitu-birthday-map";
  219. highlightDiv.style =
  220. "margin-bottom: 5px; width: 35%; border: 1px dotted black";
  221. highlightDiv.appendChild(highlightBox);
  222. highlightDiv.appendChild(highlightLabel);
  223.  
  224. // Assemble masterDiv
  225. masterDiv.appendChild(sportSpan);
  226. masterDiv.appendChild(toySpan);
  227. masterDiv.appendChild(ornamentalSpan);
  228. masterDiv.appendChild(snowSpan);
  229. masterDiv.appendChild(fireworksSpan);
  230. // masterDiv.appendChild(glazySpan);
  231. // masterDiv.appendChild(pecanSpan);
  232. masterDiv.appendChild(sbSpan);
  233. masterDiv.appendChild(standardSpan);
  234.  
  235. // Inject into DOM
  236. const insertEl = document.querySelector(
  237. ".treasureMapView-leftBlock .treasureMapView-block-content"
  238. );
  239. if (
  240. insertEl &&
  241. document.querySelector(
  242. ".treasureMapManagerView-header-navigation-item.tasks.active"
  243. )
  244. ) {
  245. insertEl.insertAdjacentElement("afterbegin", highlightDiv);
  246. insertEl.insertAdjacentElement("afterbegin", masterDiv);
  247. }
  248.  
  249. // "Goals" button
  250. document.querySelector("[data-type='show_goals']").onclick = function() {
  251. colorize();
  252. };
  253. }
  254.  
  255. // Listen to XHRs, opening a map always at least triggers board.php
  256. const originalOpen = XMLHttpRequest.prototype.open;
  257. XMLHttpRequest.prototype.open = function() {
  258. this.addEventListener("load", function() {
  259. const mapEl = document.querySelector(
  260. ".treasureMapManagerView-task.active .treasureMapManagerView-task-name"
  261. );
  262. if (mapEl) {
  263. const mapName = mapEl.textContent;
  264. if (mapName && birthdayMaps.indexOf(mapName) > -1) {
  265. colorize();
  266. }
  267. }
  268. });
  269. originalOpen.apply(this, arguments);
  270. };