Choose Easy Slayer Task

Allows rerolling Slayer tasks for a desired task

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name            Choose Easy Slayer Task
// @version         1.0.0
// @license         MIT
// @description     Allows rerolling Slayer tasks for a desired task
// @author          lucidobservor
// @match           https://*.melvoridle.com/*
// @exclude         https://wiki.melvoridle.com*
// @namespace       https://greasyfork.org/users/884123
// ==/UserScript==

function EasySlayerChoice() {
    // Set the monster IDs you want to create buttons for. These must be valid targets for Easy Slayer tasks.
    const MONSTER_IDS = [111, 82, 9, 71]

    combatManager.slayerTask.extendContainer.appendChild(document.createElement("br"));

    for (let i = 0; i < MONSTER_IDS.length; i++) {
        combatManager.slayerTask.extendContainer.appendChild(getButton(MONSTER_IDS[i]));
    }

    function getButton(monsterId) {
        let btn = document.createElement("button");
        btn.id = "new-easy-task-btn";
        btn.classList.add(...["btn", "btn-sm", "btn-primary", "m-1"]);
        btn.innerHTML = `<img class="skill-icon-xs mr-1" src="https://cdn.melvor.net/core/v018/${MONSTERS[monsterId].media}">`;
        btn.addEventListener("click", () => setNewEasyTask(monsterId));
        return btn;
    }

    function setNewEasyTask(id) {
        // Check if currently fighting an Easy task. Comment these lines out if you like to live dangerously
        if (combatManager.slayerTask.tier > 0) {
            notifyPlayer(CONSTANTS.skill.Slayer, "You must be fighting an Easy slayer task", "danger");
            return;
        }

        while (combatManager.slayerTask.monster.id != id) { combatManager.slayerTask.selectTask(0,false,false); }
    }
}


// Injecting the script when possible
(() => {
    function loadScript() {
        // Load script after the actual Melvor game has loaded
        if (typeof isLoaded !== typeof undefined && isLoaded) {
            clearInterval(scriptLoader);

            const scriptElem = document.createElement("script");
            scriptElem.textContent = `try {(${EasySlayerChoice})();} catch (e) {console.log(e);}`;
            document.body.appendChild(scriptElem).parentNode.removeChild(scriptElem);
        }
    }

    const scriptLoader = setInterval(loadScript, 250);
})();