Greasy Fork

Greasy Fork is available in English.

MouseHunt - Sum Up Living Garden Essences

sums up looted living garden essences so you can see how many aleth you just looted

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         MouseHunt - Sum Up Living Garden Essences
// @author       Yigit Sever (drocan#9084 @Discord)
// @namespace    http://greasyfork.icu/en/users/223891-yigit-sever
// @version      1.1
// @description  sums up looted living garden essences so you can see how many aleth you just looted
// @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==

function collateEssences() {
    // create an associative list, best drop is fel
    var essenceNames = ["Aleth", "Ber", "Cynd", "Dol", "Est", "Fel", "Gur", "Hix", "Icuri"];
    var essenceDict = {};

    let a = 1;
    for (var name of essenceNames){
        essenceDict[name] = a;
        // to promote an essence, you need to craft 3 of them together (with an essence prism, but we don't care about that)
        a *= 3;
    }

    var lootRegex = /(\d+) (\w+) Essence/g;

    $('.journaltext').each(function() {
        var entry = $(this).text();

        // due to ajax successes, we might have added our stuff already, check it
        // there must be a better way, people who know js knows them
        if (entry.endsWith("Essences)") || entry.endsWith("(Just 1)")) {
            return;
        }

        var match;
        let total = 0;
        while (match = lootRegex.exec(entry)) {
            var amt = match[1];
            var name = match[2];
            total += essenceDict[name] * amt;
        }
        if (total == 1) {
            $( this ).append(" (Just 1)");
        } else if (total > 1) {
            $( this ).append(" (" + total + " Essences)");
        }
    });

}
$(document).ajaxSuccess(function () {
    var pageTitle = document.title;
    if (pageTitle.includes("Hunter's Camp") || pageTitle.includes("Journal Page")) {
        collateEssences();
    }
});

$(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")) {
        collateEssences();
    }
});