MouseHunt - Birthday Map Color Coder 2021

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

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