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