Greasy Fork

MouseHunt - Sum Up Living Garden Essences

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

目前为 2018-11-06 提交的版本。查看 最新版本

// ==UserScript==
// @name         MouseHunt - Sum Up Living Garden Essences
// @author       Yigit Sever (drocan#9084 @Discord)
// @namespace    https://greasyfork.org/en/users/223891-yigit-sever
// @version      1.0
// @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() {
    var essenceNames = ["Aleth", "Ber", "Cynd", "Dol", "Est", "Fel", "Gur", "Hix", "Icuri"];
    var essenceDict = {};

    let a = 1;
    for (var name of essenceNames){
        essenceDict[name] = a;
        a *= 3;
    }

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

    $('.journaltext').each(function() {
        var entry = $(this).text();
        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).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();
    }
});