Melvor Idle - Mastery Enhancements

Adds mastery pool progress bars to skills in the menu

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Melvor Idle - Mastery Enhancements
// @description Adds mastery pool progress bars to skills in the menu
// @version     1.5
// @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.some(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) {
            clearInterval(interval);
            console.log('Loading Mastery Enhancements');
            addProgressBars();
        }
    }

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