Melvor Idle Offline Limit Remover

Remove 12 Hr Offline Idle Limit from Melvor Idle

您需要先安裝使用者腳本管理器擴展,如 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 Offline Limit Remover
// @namespace    https://zeldo.net
// @version      0.1
// @description  Remove 12 Hr Offline Idle Limit from Melvor Idle
// @author       Zeldo
// @match        https://*.melvoridle.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function Main() {
        if (typeof updateOffline === "undefined") {
            return;
        }

        console.log("Attempting to modify Main.js updateOffline");
        var UpdateOfflineNew = updateOffline.toString();

        UpdateOfflineNew = UpdateOfflineNew.replace("if (timeDiff > 43200000) timeDiff = 43200000;", "let hoursGone = (timeDiff / 1000 / 60 / 60);");

        if (UpdateOfflineNew == updateOffline.toString()) {
            console.error("Failed to find 12 hour limitor");
            return;
        }

        UpdateOfflineNew = UpdateOfflineNew.replace(/if \(timeGone >= 12\) goneFor \+= .+?\r\n/i, "");
        UpdateOfflineNew = UpdateOfflineNew.replace(/if \(timeGone >= 12\) goneFor \+= .+?\n/i, "");

        if (UpdateOfflineNew == updateOffline.toString()) {
            console.error("Failed to find 12 hour message for removal.");
        }

        UpdateOfflineNew = UpdateOfflineNew.replace("Loading your offline progress.", "Loading \' + ((hoursGone > 1) ? (Math.floor(hoursGone) + \" hours\") : Math.floor(hoursGone * 60) + \" minutes\") + \' of offline progress.");
        if (UpdateOfflineNew == updateOffline.toString()) {
            console.error("Failed to find 12 hour message for removal.");
        }

        updateOffline = eval("(" + UpdateOfflineNew + ")");

        console.log("Successfully removed 12 hour limit.");
    }

    var script = document.createElement('script');
    script.textContent = `try {(${Main})();} catch (e) {console.error(e);}`;
    document.body.appendChild(script).parentNode.removeChild(script);

})();