Bonk.io Ultimate Script

Add rainbow styles, auto-join games, UI tweaks, hotkeys, and more to Bonk.io. Activated via commands.

目前為 2024-12-17 提交的版本,檢視 最新版本

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Bonk.io Ultimate Script
// @namespace    http://tampermonkey.net/
// @version      17.8.9
// @description  Add rainbow styles, auto-join games, UI tweaks, hotkeys, and more to Bonk.io. Activated via commands.
// @author       YourName
// @match        https://bonk.io/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    let isRainbowActive = false;
    let isAutoJoinActive = false;
    let isChatBoostActive = false;
    let isAutoPlayActive = false;
    let customSkin = null;
    let hotkeys = {};

    let hue = 0;

    function setupCommandListener() {
        document.addEventListener('keydown', (e) => {
            if (e.key === 'Enter') {
                setTimeout(() => {
                    const chatInput = document.querySelector('#chatinput');
                    if (!chatInput) return;

                    const command = chatInput.value.trim().toLowerCase();
                    chatInput.value = ''; // Clear input

                    // Handle commands
                    switch (command) {
                        case '/rainbowstyle':
                            isRainbowActive = !isRainbowActive;
                            console.log(`Rainbow Style: ${isRainbowActive ? 'Enabled' : 'Disabled'}`);
                            break;
                        case '/autojoin':
                            isAutoJoinActive = !isAutoJoinActive;
                            console.log(`Auto-Join: ${isAutoJoinActive ? 'Enabled' : 'Disabled'}`);
                            break;
                        case '/customizeui':
                            customizeUI();
                            break;
                        case '/sethotkeys':
                            setHotkeys();
                            break;
                        case '/chatboost':
                            isChatBoostActive = !isChatBoostActive;
                            console.log(`Chat Boost: ${isChatBoostActive ? 'Enabled' : 'Disabled'}`);
                            break;
                        case '/setskin':
                            setCustomSkin();
                            break;
                        case '/autoplay':
                            isAutoPlayActive = !isAutoPlayActive;
                            console.log(`Auto-Play: ${isAutoPlayActive ? 'Enabled' : 'Disabled'}`);
                            break;
                        default:
                            console.log(`Unknown command: ${command}`);
                    }
                }, 0);
            }
        });
    }

    function applyRainbowEffect() {
        setInterval(() => {
            if (!isRainbowActive) return;

            hue = (hue + 5) % 360;
            const rectangleColor = `hsl(${hue}, 100%, 50%)`;
            const oppositeColor = `hsl(${(hue + 180) % 360}, 100%, 50%)`;

            try {
                if (window.bonkHost && window.bonkHost.p) {
                    window.bonkHost.p.color = rectangleColor;
                    window.bonkHost.p.outline = rectangleColor;
                }

                const playerName = document.querySelector('.playerName');
                const levelText = document.querySelector('.levelText');
                if (playerName) playerName.style.color = oppositeColor;
                if (levelText) levelText.style.color = oppositeColor;

            } catch (e) {
                console.error('Error applying rainbow effect:', e);
            }
        }, 100);
    }

    function autoJoinGames() {
        setInterval(() => {
            if (!isAutoJoinActive) return;

            try {
                const joinButton = document.querySelector('.joinGameButton');
                if (joinButton) {
                    joinButton.click();
                    console.log('Auto-Joined a game!');
                }
            } catch (e) {
                console.error('Error with Auto-Join:', e);
            }
        }, 1000);
    }

    function customizeUI() {
        alert('UI customization activated! (This is a placeholder — add customization logic here.)');
    }

    function setHotkeys() {
        alert('Hotkey configuration activated! (This is a placeholder — add hotkey logic here.)');
    }

    function chatBoost() {
        if (!isChatBoostActive) return;

        const chatLog = document.querySelector('.chatLog');
        if (chatLog) {
            // Example: Automatically highlight certain messages
            chatLog.querySelectorAll('.chatMessage').forEach((msg) => {
                if (msg.textContent.includes('!')) {
                    msg.style.color = 'red';
                }
            });
        }
    }

    function setCustomSkin() {
        customSkin = prompt('Enter a hex color for your custom skin:');
        if (customSkin && window.bonkHost && window.bonkHost.p) {
            window.bonkHost.p.color = customSkin;
            window.bonkHost.p.outline = customSkin;
            console.log(`Custom skin set to: ${customSkin}`);
        }
    }

    function autoPlay() {
        setInterval(() => {
            if (!isAutoPlayActive) return;

            try {
                if (window.bonkHost && window.bonkHost.p) {
                    // Example: Automatically jump every second
                    window.bonkHost.p.jump();
                    console.log('Auto-Jumping!');
                }
            } catch (e) {
                console.error('Error with Auto-Play:', e);
            }
        }, 1000);
    }

    const waitForGame = setInterval(() => {
        if (typeof window.bonkHost !== 'undefined' && window.bonkHost.p !== undefined) {
            clearInterval(waitForGame);
            setupCommandListener();
            applyRainbowEffect();
            autoJoinGames();
            setInterval(chatBoost, 500); // Enhance chat functionality
            autoPlay();
        }
    }, 100);
})();