Melvor Idle - Mastery Enhancements

Colors buttons to spend pool xp depending on current xp and adds progress bars for pools to skills in the menu

当前为 2021-03-14 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Melvor Idle - Mastery Enhancements
// @description Colors buttons to spend pool xp depending on current xp and adds progress bars for pools to skills in the menu
// @version     1.3
// @namespace   Visua
// @match       https://*.melvoridle.com/*
// @exclude     https://wiki.melvoridle.com*
// @noframes
// @grant       none
// ==/UserScript==
/* jshint esversion: 6 */

// Code by Acrone#1563, Aurora Aquir#4272, Breindahl#2660, NotCorgan#1234 and Visua#9999

((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 addProgressBars() {
        const MAX_XP = 13034432;
        const maxedSkills = [];
        setInterval(() => {
            for (const [skillId, mastery] of Object.entries(MASTERY)) {
                const poolPercentage = (mastery.pool / getMasteryPoolTotalXP(skillId)) * 100;
                if ($(`#skill-nav-mastery-${skillId} .progress-bar`)[0]) {
                    $(`#skill-nav-mastery-${skillId} .progress-bar`)[0].style.width = (poolPercentage) + '%';
                    const tip = $(`#skill-nav-mastery-${skillId}`)[0]._tippy;
                    tip.setContent(poolPercentage.toFixed(2) + '%');
                } else {
                    const skillItem = $(`#skill-nav-name-${skillId}`)[0].parentNode;
                    skillItem.style.flexWrap = 'wrap';
                    skillItem.style.setProperty('padding-top', '.25rem', 'important');
                    const progress = document.createElement('div');
                    const progressBar = document.createElement('div');
                    progress.id = `skill-nav-mastery-${skillId}`;
                    progress.className = 'progress active pointer-enabled';
                    progress.style.height = '2px';
                    progress.style.width = '100%';
                    progress.style.margin = '.25rem 0rem';
                    progress.style.setProperty('background', 'rgb(76,80,84)', 'important');
                    progressBar.className = 'progress-bar bg-warning';
                    progressBar.style.width = poolPercentage + '%';
                    progress.appendChild(progressBar);
                    skillItem.appendChild(progress);
                    tippy($(`#skill-nav-mastery-${skillId}`)[0], {
                        placement: 'right',
                        content: poolPercentage.toFixed(2) + '%'
                    });
                }
                if (!maxedSkills[skillId] && !mastery.xp.find(xp => xp < MAX_XP)) {
                    maxedSkills[skillId] = true;
                    $(`#skill-nav-mastery-${skillId} .progress-bar`)[0].classList.replace('bg-warning', 'bg-success');
                }
            }
        }, 5000);
    }

    function loadScript() {
        if (typeof confirmedLoaded !== 'undefined' && confirmedLoaded && !currentlyCatchingUp) {
            clearInterval(interval);
            console.log('Loading Mastery Enhancements');
            addProgressBars();
        }
    }

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