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