Greasy Fork

Greasy Fork is available in English.

Moomoo.io Auto Spike Breaker

Automatically breaks spikes using hammer and tank in sandbox.moomoo.io

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Moomoo.io Auto Spike Breaker
// @namespace    http://tampermonkey.net/
// @version      0.1
// @author       wat
// @description  Automatically breaks spikes using hammer and tank in sandbox.moomoo.io
// @match        *://sandbox.moomoo.io/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const hammerKey = 'KeyV'; // Key to equip hammer
    const tankKey = 'KeyH';   // Key to equip tank gear

    const angleStep = Math.PI / 8; // Angle step for rotation (45 degrees)
    let currentAngle = 0;

    function equipHammer() {
        const event = new KeyboardEvent('keydown', { 'key': hammerKey });
        document.dispatchEvent(event);
    }

    function equipTank() {
        const event = new KeyboardEvent('keydown', { 'key': tankKey });
        document.dispatchEvent(event);
    }

    function attack() {
        window.input.mouseButton = 1;
        window.input.mouseButtonOld = 1;
    }

    function stopAttack() {
        window.input.mouseButton = 0;
        window.input.mouseButtonOld = 0;
    }

    function rotatePlayer() {
        currentAngle = (currentAngle + angleStep) % (2 * Math.PI);
        window.player.dir = currentAngle;
    }

    function autoBreakSpikes() {
        equipHammer();
        setTimeout(() => {
            equipTank();
            setTimeout(() => {
                attack();
                const breakInterval = setInterval(() => {
                    rotatePlayer();
                    if (currentAngle === 0) {
                        clearInterval(breakInterval);
                        stopAttack();
                    }
                }, 100);
            }, 50);
        }, 50);
    }

    // Run the auto break function every 5 seconds
    setInterval(autoBreakSpikes, 5000);

    // Add a hotkey to manually trigger the auto break function (press 'B')
    document.addEventListener('keydown', function(event) {
        if (event.code === 'KeyB') {
            autoBreakSpikes();
        }
    });

    console.log("Auto Spike Breaker script loaded!");
})();