Melvor Completion Log Helper

The completion logs now show images of undiscovered items/monsters/pets, including those entities that do not count towards completion.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        Melvor Completion Log Helper
// @namespace   http://tampermonkey.net/
// @version     0.7.1
// @description The completion logs now show images of undiscovered items/monsters/pets, including those entities that do not count towards completion.
// @author		GMiclotte
// @include		https://melvoridle.com/*
// @include		https://*.melvoridle.com/*
// @exclude		https://melvoridle.com/index.php
// @exclude		https://*.melvoridle.com/index.php
// @exclude		https://wiki.melvoridle.com/*
// @exclude		https://*.wiki.melvoridle.com/*
// @inject-into page
// @noframes
// @grant		none
// ==/UserScript==
/* jshint esversion: 6 */

// Thanks to Breindahl#2660 for the original implementation
// Big thanks to Visua#9999 for helping with parts of the code and troubleshooting

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

    function patchCode(code, additionalPatch) {
        code = code.toString();
        code = code.replace(/!items\[[a-zA-Z]*\].ignoreCompletion/g, 'true');
        code = code.replace(/!MONSTERS\[[a-zA-Z]*\].ignoreCompletion/g, 'true');
        code = code.replace(/!PETS\[[a-zA-Z]*\].ignoreCompletion/g, 'true');
        if (additionalPatch !== undefined) {
            code = additionalPatch(code);
        }
        return code.replace(/^function (\w+)/, 'window.$1 = function');
    }

    const toPatch = [
        filterItemLog,
        createItemLogTooltip,
        createMonsterLogTooltip,
        createPetLogTooltip,
    ];

    function additionalPatchApplyCompletionLogEntryElement(code) {
        code = code.split(/Element\(-8,/);
        for (let i = 1; i < code.length; i++) {
            code[i] = code[i].replace(';', `; const htmlIdx = html.lastIndexOf('<img ') + 5; html = html.substring(0, htmlIdx) + 'style="opacity: 25%"' + html.substring(htmlIdx); `);
        }
        return code.join('Element(id,');
    }

    function startCompletionLogHelper() {
        // patch functions
        toPatch.forEach(x => eval(patchCode(x)));
        eval(patchCode(applyCompletionLogEntryElement, additionalPatchApplyCompletionLogEntryElement));

        // reset loaded variables
        itemLogLoaded = false;
        monsterLogLoaded = false;
        petLogLoaded = false;

        // build Monster and pet logs
        buildMonsterLog();
        buildPetLog();

        // logging
        console.log('Melvor Completion Log Helper Loaded');
    }

    function loadScript() {
        if (typeof confirmedLoaded !== typeof undefined && confirmedLoaded) {
            clearInterval(scriptLoader);
            startCompletionLogHelper();
        }
    }

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