// ==UserScript== // @name MH - Map TEM Catch Stats // @version 1.1.2 // @description Adds catch/crown statistics next to mouse names on the map // @author Chromatical // @match https://www.mousehuntgame.com/camp.php // @icon https://www.google.com/s2/favicons?domain=mousehuntgame.com // @namespace https://greasyfork.org/users/748165 // @downloadURL none // ==/UserScript== var debug = false; //To prevent duplication var hasRendered = false; (function() { //Check for Tsitu's TEM /*var isitdownloaded = localStorage.getItem("mh-catch-stats"); if(isitdownloaded === null){ setInterval(function(){ alert("The MH: Map TEM Catch Stats require Tsitu's TEM Catch Stats to function./nDownload fromm https://greasyfork.org/en/scripts/376770-mousehunt-tem-catch-stats"); },5000); };*/ ///Listener const originalOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function (){ this.addEventListener("load",function(){ if (this.responseURL === "https://www.mousehuntgame.com/managers/ajax/board/board.php"){ if (debug){ console.log("Treasure map triggered") }; try { if (hasRendered){ resize(); } else { addCrown(); //Another listener listen(); }; } catch (error){ console.log("Map TEM Error") } } }); originalOpen.apply(this,arguments); } })(); function addCrown(){ //Tsitu's code - require tsitu's TEM Catch Stats' Script to work------------------------ // Render crown image and catch number next to mouse name const rawStore = localStorage.getItem("mh-catch-stats"); if (rawStore) { const stored = JSON.parse(rawStore); // Clean up ' Mouse' affixes const newStored = {}; const storedKeys = Object.keys(stored); storedKeys.forEach(key => { if (key.indexOf(" Mouse") >= 0) { // const newKey = key.split(" Mouse")[0]; const newKey = key.replace(/\ mouse$/i, ""); // Doesn't capture Dread Pirate Mousert newStored[newKey] = stored[key]; } else { newStored[key] = stored[key]; } }); document.querySelectorAll(".treasureMapView-goals-group-goal").forEach(el => { var span = el.querySelector("span") span.style = "width: auto; height: auto; font-size: 10px;"; const outer = document.createElement("span"); outer.className = "mousebox2"; //outer.style.border = "1px groove grey"; outer.style.width = "auto"; outer.style.height = "auto"; outer.style.margin = "0px"; outer.style.paddingRight = "8px"; outer.style.paddingLeft = "3px"; outer.style.float = "none"; const crownImg = document.createElement("img"); crownImg.style.width = "18px"; crownImg.style.height = "18px"; crownImg.style.paddingTop = "2px"; crownImg.style.paddingBottom = "1px"; crownImg.style.right = "-4px"; crownImg.style.position = "relative"; crownImg.style.float = "right"; const mouseName = el.querySelector(".treasureMapView-goals-group-goal-name").textContent; const catches = newStored[mouseName] function getCrownSrc(type) { return `https://www.mousehuntgame.com/images/ui/crowns/crown_${type}.png`; } if (!catches || catches < 10) { crownImg.src = getCrownSrc("none"); } else if (catches >= 10 && catches < 100) { crownImg.src = getCrownSrc("bronze"); } else if (catches >= 100 && catches < 500) { crownImg.src = getCrownSrc("silver"); } else if (catches >= 500 && catches < 1000) { crownImg.src = getCrownSrc("gold") } else if (catches >= 1000 && catches < 2500) { crownImg.src = getCrownSrc("platinum"); } else if (catches >= 2500) { crownImg.src = getCrownSrc("diamond"); } //outer.innerText = catches ||0 const text = document.createElement("div"); text.innerText = catches || 0 text.style = "text-align: center" text.style.float = "left"; text.style.paddingTop = "5px"; outer.appendChild(text); outer.appendChild(crownImg) span.appendChild(outer); const mainDiv = document.createElement("div"); mainDiv.className = "map-tem-stats"; hasRendered = true }); } } function listen(){ var clicked =$(".treasureMapRootView-subTab")[0] clicked.addEventListener("click",function(){ addCrown() }) } function resize (){ document.querySelectorAll(".treasureMapView-goals-group-goal").forEach(el => { var span = el.querySelector("span") span.style = "width: auto; height: auto; font-size: 10px;"; }) }