// ==UserScript== // @name MouseHunt - Birthday Map Color Coder 2020 // @author Vinnie & Tran Situ (tsitu) // @version 0.1 // @description Color codes mice on birthday maps according to decorations & cheese. Based off tsitu's work. // @match http://www.mousehuntgame.com/* // @match https://www.mousehuntgame.com/* // @namespace https://greasyfork.org/users/439904 // @downloadURL none // ==/UserScript== const mixingMice = [ "Force Fighter Blue", "Force Fighter Green", "Force Fighter Pink", "Force Fighter Red", "Force Fighter Yellow", "Super FighterBot MegaSupreme", ]; const breakMice = [ "Breakdancer", "Fete Fromager", "Dance Party", "El Flamenco", "Para Para Dancer" ]; const pumpMice = [ "Reality Restitch", "Time Punk", "Time Tailor", "Time Thief" ]; const qaMice = [ "Cupcake Candle Thief", "Cupcake Cutie", "Sprinkly Sweet Cupcake Cook", "Cupcake Camo", "Cupcake Runner" ]; const bossMice = [ "Vincent, The Magnificent" ]; const sbMice = [ "Cheese Party" ]; const standardMice = [ "Birthday", "Buckethead", "Present", "Pintail", "Dinosuit", "Sleepwalker", "Terrible Twos" ]; const birthdayMaps = [ "Nice List", "Rare Nice List", "Naughty List", "Rare Gilded Birthday Event Map" ]; function colorize() { let mixingColor = "#c97c49"; // brown-ish let mixingCount = 0; let breakColor = "#f06a60"; // red let breakCount = 0; let pumpColor = "#5ae031"; // green let pumpCount = 0; let qaColor = "#4fcaf0"; // blue let qaCount = 0; let bossColor = "#cd87ff"; // light purple let bossCount = 0; let sbColor = "#66ffff"; // teal-ish let sbCount = 0; let standardColor = "#afa500"; // mountain dew-ish let standardCount = 0; const greyColor = "#949494"; const isChecked = localStorage.getItem("highlightPref") === "uncaught-only" ? true : false; const isCheckedStr = isChecked ? "checked" : ""; if ( document.querySelectorAll(".treasureMapView-goals-group-goal").length === 0 ) { return; } document.querySelectorAll(".treasureMapView-goals-group-goal").forEach(el => { el.querySelector("span").style = "color: black; font-size: 11px;"; const mouseName = el.querySelector(".treasureMapView-goals-group-goal-name") .textContent; if (mixingMice.indexOf(mouseName) > -1) { el.style.backgroundColor = mixingColor; if (el.className.indexOf(" complete ") < 0) { mixingCount++; } else { if (isChecked) el.style.backgroundColor = "white"; } } else if (breakMice.indexOf(mouseName) > -1) { el.style.backgroundColor = breakColor; if (el.className.indexOf(" complete ") < 0) { breakCount++; } else { if (isChecked) el.style.backgroundColor = "white"; } } else if (pumpMice.indexOf(mouseName) > -1) { el.style.backgroundColor = pumpColor; if (el.className.indexOf(" complete ") < 0) { pumpCount++; } else { if (isChecked) el.style.backgroundColor = "white"; } } else if (qaMice.indexOf(mouseName) > -1) { el.style.backgroundColor = qaColor; if (el.className.indexOf(" complete ") < 0) { qaCount++; } else { if (isChecked) el.style.backgroundColor = "white"; } } else if (bossMice.indexOf(mouseName) > -1) { el.style.backgroundColor = bossColor; if (el.className.indexOf(" complete ") < 0) { bossCount++; } else { if (isChecked) el.style.backgroundColor = "white"; } } else if (sbMice.indexOf(mouseName) > -1) { el.style.backgroundColor = sbColor; if (el.className.indexOf(" complete ") < 0) { sbCount++; } else { if (isChecked) el.style.backgroundColor = "white"; } } else if (standardMice.indexOf(mouseName) > -1) { el.style.backgroundColor = standardColor; if (el.className.indexOf(" complete ") < 0) { standardCount++; } else { if (isChecked) el.style.backgroundColor = "white"; } } }); pumpColor = pumpCount > 0 ? pumpColor : greyColor; breakColor = breakCount > 0 ? breakColor : greyColor; pumpColor = pumpCount > 0 ? pumpColor : greyColor; qaColor = qaCount > 0 ? qaColor : greyColor; bossColor = bossCount > 0 ? bossColor : greyColor; sbColor = sbCount > 0 ? sbColor : greyColor; standardColor = standardCount > 0 ? standardColor : greyColor; // Remove existing birthday Map related elements before proceeding document.querySelectorAll(".tsitu-birthday-map").forEach(el => el.remove()); const masterDiv = document.createElement("div"); masterDiv.className = "tsitu-birthday-map"; masterDiv.style = "display: inline-flex; margin-bottom: 10px; width: 100%; text-align: center; line-height: 1.5; overflow: hidden"; const spanStyle = "; width: auto; padding: 5px; font-weight: bold; font-size: 12.5px"; const sportSpan = document.createElement("span"); sportSpan.style = "background-color: " + pumpColor + spanStyle; sportSpan.innerHTML = "Mixing
" + pumpCount; const toySpan = document.createElement("span"); toySpan.style = "background-color: " + breakColor + spanStyle; toySpan.innerHTML = "Break
" + breakCount; const ornamentalSpan = document.createElement("span"); ornamentalSpan.style = "background-color: " + pumpColor + spanStyle; ornamentalSpan.innerHTML = "Pump
" + pumpCount; const snowSpan = document.createElement("span"); snowSpan.style = "background-color: " + qaColor + spanStyle; snowSpan.innerHTML = "QA
" + qaCount; const fireworksSpan = document.createElement("span"); fireworksSpan.style = "background-color: " + bossColor + spanStyle; fireworksSpan.innerHTML = "Vinnie
" + bossCount; const sbSpan = document.createElement("span"); sbSpan.style = "background-color: " + sbColor + spanStyle; sbSpan.innerHTML = "SB+
" + sbCount; const standardSpan = document.createElement("span"); standardSpan.style = "background-color: " + standardColor + spanStyle; standardSpan.innerHTML = "Standard
" + standardCount; // Highlight uncaught only feature const highlightLabel = document.createElement("label"); highlightLabel.htmlFor = "tsitu-highlight-box"; highlightLabel.innerText = "Highlight uncaught mice only"; const highlightBox = document.createElement("input"); highlightBox.type = "checkbox"; highlightBox.name = "tsitu-highlight-box"; highlightBox.style.verticalAlign = "middle"; highlightBox.checked = isChecked; highlightBox.addEventListener("click", function() { if (highlightBox.checked) { localStorage.setItem("highlightPref", "uncaught-only"); } else { localStorage.setItem("highlightPref", "all"); } colorize(); }); const highlightDiv = document.createElement("div"); highlightDiv.className = "tsitu-birthday-map"; highlightDiv.style = "margin-bottom: 5px; width: 35%; border: 1px dotted black"; highlightDiv.appendChild(highlightBox); highlightDiv.appendChild(highlightLabel); // Assemble masterDiv masterDiv.appendChild(sportSpan); masterDiv.appendChild(toySpan); masterDiv.appendChild(ornamentalSpan); masterDiv.appendChild(snowSpan); masterDiv.appendChild(fireworksSpan); // masterDiv.appendChild(glazySpan); // masterDiv.appendChild(pecanSpan); masterDiv.appendChild(sbSpan); masterDiv.appendChild(standardSpan); // Inject into DOM const insertEl = document.querySelector( ".treasureMapView-leftBlock .treasureMapView-block-content" ); if ( insertEl && document.querySelector( ".treasureMapManagerView-header-navigation-item.tasks.active" ) ) { insertEl.insertAdjacentElement("afterbegin", highlightDiv); insertEl.insertAdjacentElement("afterbegin", masterDiv); } // "Goals" button document.querySelector("[data-type='show_goals']").onclick = function() { colorize(); }; } // Listen to XHRs, opening a map always at least triggers board.php const originalOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function() { this.addEventListener("load", function() { const mapEl = document.querySelector( ".treasureMapManagerView-task.active .treasureMapManagerView-task-name" ); if (mapEl) { const mapName = mapEl.textContent; if (mapName && birthdayMaps.indexOf(mapName) > -1) { colorize(); } } }); originalOpen.apply(this, arguments); };