Greasy Fork

Greasy Fork is available in English.

MH - Map TEM Catch Stats

Adds catch/crown statistics next to mouse names on the map

当前为 2021-05-29 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         MH - Map TEM Catch Stats
// @version      1.1.1
// @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 http://greasyfork.icu/users/748165
// ==/UserScript==

var debug = 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 http://greasyfork.icu/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 {
                    addCrown();
                    //Another listener :notlikeduck:
                    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";
        });
    }
}

function listen(){
    var clicked =$(".treasureMapRootView-subTab")[0]
    clicked.addEventListener("click",function(){
        addCrown()
    })
}