Choose Easy Slayer Task

Allows rerolling Slayer tasks for a desired task

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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);
})();