Melvor Better Tooltips

Adds extra useful information to some of the game's tooltips.

目前為 2022-07-30 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Melvor Better Tooltips
// @description Adds extra useful information to some of the game's tooltips.
// @version     1.3
// @author      OldAbblis#6012
// @namespace   http://tampermonkey.net/
// @match       https://melvoridle.com/*
// @match       https://www.melvoridle.com/*
// @match       https://test.melvoridle.com/*
// @noframes
// @grant       none
// ==/UserScript==
/* jshint esversion: 6 */

((main) => {
    var script = document.createElement('script');
    script.textContent = `try { (${main})(); } catch (e) { console.log(e); }`;
    document.body.appendChild(script).parentNode.removeChild(script);
})(() => {
    'use strict';

    function betterTooltips() {
        createItemInformationTooltip = (itemID, showStats = false) => {
            let potionCharges = "", description = "", spec = getItemSpecialAttackInformation(itemID), hp = "", passive = "", html = "", baseStats = "", totalPrice = "", remainingCharges = "";
            const item = items[itemID];

            if (showStats && item.isEquipment)
                baseStats = getItemBaseStatsBreakdown(itemID);
            if (item.isPotion)
                potionCharges = "<small class='text-warning'>" + templateString(getLangString("MENU_TEXT", "POTION_CHARGES"), {charges: `${items[itemID].potionCharges}`}) + "</small><br>";
            if (item.description !== undefined)
                description = "<small class='text-info'>" + items[itemID].description + "</small><br>";
            if (isFood(item))
                hp = "<img class='skill-icon-xs ml-2' src='" + CDNDIR + "assets/media/skills/hitpoints/hitpoints.svg'><span class='text-success'>+" + player.getFoodHealing(item) + "</span>";
            if (isEquipment(item) && item.validSlots.includes("Passive") && equipmentSlotData.Passive.unlocked)
                passive = '<br><small class="text-success">' + getLangString("MENU_TEXT", "PASSIVE_SLOT_COMPATIBLE") + "</small>";
            if (isEquipment(item) && item.validSlots.includes("Gloves") && item.name.includes("ing Gloves"))
                remainingCharges = '<small class="badge badge-info">' + formatNumber(glovesTracker[items[itemID].gloveID].remainingActions) + " Charges</small>";
            if (getBankQty(itemID) !== 1)
                totalPrice = "(" + numberWithCommas(getItemSalePrice(itemID) * getBankQty(itemID)) + ")";

            html += `<div class="text-center">
                <div class="media d-flex align-items-center push">
                    <div class="mr-3">
                        <img class="bank-img m-1" src="${getItemMedia(itemID)}">
                    </div>
                    <div class="media-body">
                        <div class="font-size-sm">
                            ${remainingCharges}
                        </div>
                        <div class="font-w600">
                            ${items[itemID].name} <span style="font-weight: 400 !important">
                                (ID: ${itemID})
                            </span>
                        </div>
                        ${potionCharges}
                        ${description}
                        ${spec}
                        <div class="font-size-sm">
                            <img class="skill-icon-xs" src="${CDNDIR}assets/media/main/coins.svg"> ${numberWithCommas(getItemSalePrice(itemID))} ${totalPrice}
                            <br>
                            ${hp}
                            ${passive}
                            <br>
                        </div>
                        ${baseStats}
                    </div>
                </div>
            </div>`;

            return html;
        }
    }

    function loadScript() {
        if (typeof confirmedLoaded !== 'undefined' && confirmedLoaded) {
            clearInterval(interval);
            console.log('Loading Melvor Better Tooltips script');
            betterTooltips();
        }
    }

    const interval = setInterval(loadScript, 500);
});