Greasy Fork is available in English.

无尽矿石(More Ore)自定义倍速及暴露全局变量

通过劫持方法暴露游戏内置变量到window.game,并可自定义游戏内置倍速。【测试版,不保证无BUG】

// ==UserScript==
// @name         无尽矿石(More Ore)自定义倍速及暴露全局变量
// @version      1.0-Demo
// @description  通过劫持方法暴露游戏内置变量到window.game,并可自定义游戏内置倍速。【测试版,不保证无BUG】
// @author       DreamNya
// @match        https://file.u77.games/zh-cn/*/more-ore-v3/index.html
// @grant        none
// @license      MIT
// @run-at       document-start
// @namespace https://greasyfork.org/users/809466
// ==/UserScript==
const customSpeed = 10; //自定义倍速,默认10倍,影响实际计算,不影响动画效果;动态调整倍速方法:控制台修改game.State.settings.gameSpeed

const realDef = window.Object.defineProperty;
const realAssign = window.Object.assign;

let objHooked = false;
let speedHooked = false;


window.Object.assign = function (...args) {
    if (args[1]?.settings) {
        args[1].settings.gameSpeed = customSpeed
        window.Object.assign = realAssign
    }
    return realAssign.call(this, ...args)
}

window.Object.defineProperty = function (...args) {
    if (args[1] == '__esModule') {
        watchObject(args[0])
    }
    realDef.call(this, ...args)
}

function watchObject(obj) {
    let value
    realDef(obj, "State", {
        get() {
            return value
        },
        set(newValue) {
            value = newValue
            if (!objHooked) {
                window.game = obj
                objHooked = true
                window.Object.defineProperty = realDef
            }
        }
    })
}