MouseHunt - Display Converted Charms Thumbnail

Adds a thumbnail showing the charms obtained from Unstable/Torch/Treasure Trawling Charms.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         MouseHunt - Display Converted Charms Thumbnail
// @author       Jia Hao (Limerence#0448 @Discord)
// @namespace    https://greasyfork.org/en/users/165918-jia-hao
// @version      1.3
// @description  Adds a thumbnail showing the charms obtained from Unstable/Torch/Treasure Trawling Charms.
// @include      https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
// @include      http://www.mousehuntgame.com/*
// @include      https://www.mousehuntgame.com/*
// ==/UserScript==

//Special thanks to Tan Y.K. for refactoring this function! :D
function unstableThumbnails() {
    var charmPops = $(".chesla_trap_trigger,.torch_charm_event").not(".minimalJournal,:has(img)");
    charmPops.each(function() {
        //Only entries made by Unstable/Torch/Treasure Trawling charms
        if ($(this).text().indexOf("Unstable Charm") >= 0 || $(this).text().indexOf("Treasure Trawling Charm") >= 0 || $(this).text().indexOf("Torch Charm") >= 0) {
            var itemType = $(".journaltext>a",this).attr("href").match(/[?&]item_type=([^&]+)/);
            if (itemType) {
                var $this = $(this).prepend("<div class=journalimage><img /></div>");
                hg.utils.UserInventory.getItem(decodeURIComponent(itemType[1]), function(x) {
                    $("img",$this).css("border","1px solid black").attr("src", x.thumbnail);
                    $this.css("background-image","none");
                });
            }
        }
    });
}

$(document).ajaxSuccess(unstableThumbnails);
$(document).ready(function() {
    //If current page is main camp or journal
    var pageTitle = document.title;
    if (pageTitle.includes("Hunter's Camp") || pageTitle.includes("Journal Page")) {
        unstableThumbnails();
    }

});