MouseHunt - Birthday Map Color Coder 2020

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

当前为 2021-03-02 提交的版本,查看 最新版本

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