Slither.io Enhancer (Background + Zoom Control + FPS Counter)

Adds background color changer, zoom controls, and a rainbow FPS counter to slither.io

当前为 2025-06-04 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Slither.io Enhancer (Background + Zoom Control + FPS Counter)
// @namespace    http://tampermonkey.net/
// @version      3.1
// @description  Adds background color changer, zoom controls, and a rainbow FPS counter to slither.io
// @author       Jadob Lane
// @match        http://slither.com/io
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // ===== Background Color Changer =====
    function createBackgroundChanger() {
        const colors = {
            Default: '#1a1a1a',
            Light: '#f0f0f0',
            Navy: '#001f3f',
            Green: '#2ecc40',
            Purple: '#7f00ff',
            Pink: '#ff69b4',
            Cyan: '#00ffff',
            Red: '#ff4136',
            Orange: '#ff851b',
            Yellow: '#ffdc00',
            Lime: '#01ff70',
            Teal: '#39cccc',
            Indigo: '#4b0082',
            Brown: '#8b4513',
            Gray: '#aaaaaa',
            Blue: '#00008B',
        };

        const container = document.createElement('div');
        container.style.position = 'fixed';
        container.style.top = '10px';
        container.style.left = '10px';
        container.style.zIndex = '9999';
        container.style.background = 'rgba(0, 0, 0, 0.6)';
        container.style.padding = '8px';
        container.style.borderRadius = '5px';
        container.style.color = '#fff';
        container.style.fontFamily = 'Arial, sans-serif';
        container.style.fontSize = '14px';

        const label = document.createElement('label');
        label.textContent = 'Background: ';
        label.style.marginRight = '5px';

        const select = document.createElement('select');
        for (let name in colors) {
            const option = document.createElement('option');
            option.value = colors[name];
            option.textContent = name;
            select.appendChild(option);
        }

        select.addEventListener('change', function() {
            document.body.style.backgroundColor = select.value;
        });

        container.appendChild(label);
        container.appendChild(select);
        document.body.appendChild(container);

        select.addEventListener('keydown', function(event) {
            if (event.key === ' ' || event.keyCode === 32) {
                event.preventDefault();
            }
        });
    }

    // ===== Zoom Control =====
    window.logDebugging = false;
    window.log = function() {
        if (window.logDebugging) {
            console.log.apply(console, arguments);
        }
    };

    window.zoomMultiplier = 1.0;

    window.updateZoom = function() {
        window.gsc = window.zoomMultiplier;
        const zoomOverlay = document.getElementById("zoom_overlay");
        if (zoomOverlay) {
            zoomOverlay.innerHTML = `Press (8/9) to change zoom: ${window.zoomMultiplier.toFixed(1)}`;
        }
    };

    window.recursiveZoomUpdate = function() {
        window.gsc = window.zoomMultiplier;
        requestAnimationFrame(window.recursiveZoomUpdate);
    };

    window.resetZoom = function() {
        window.zoomMultiplier = 1.0;
        window.updateZoom();
    };

    window.adjustZoom = function(amount) {
        window.zoomMultiplier = Math.max(0.2, Math.min(3.0, window.zoomMultiplier + amount));
        window.updateZoom();
    };

    document.oldKeyDown = document.onkeydown;
    document.onkeydown = function(e) {
        if (typeof document.oldKeyDown === "function") {
            document.oldKeyDown(e);
        }

        if (document.activeElement?.parentElement !== window.nick_holder) {
            if (e.keyCode === 57) {       // Key "9"
                window.adjustZoom(0.1);
            } else if (e.keyCode === 56) { // Key "8"
                window.adjustZoom(-0.1);
            } else if (e.keyCode === 49) { // Key "1"
                window.resetZoom();
            }
        }
    };

    window.initZoomOverlay = function() {
        let overlay = document.createElement("div");
        overlay.id = "zoom_overlay";
        overlay.style = "color: #FFF; font-family: Arial, sans-serif; font-size: 18px; position: fixed; left: 30px; top: 65px; z-index: 1000;";
        overlay.innerHTML = "Press (8/9) to change zoom: " + window.zoomMultiplier.toFixed(1);
        document.body.appendChild(overlay);
    };

    // ===== Initialize Everything After Page Load =====
    window.addEventListener('load', function() {
        createBackgroundChanger();
        window.initZoomOverlay();
        window.updateZoom();
        window.recursiveZoomUpdate();

        // ===== Rainbow FPS Counter =====
        const fpsDisplay = document.createElement('div');
        fpsDisplay.style.position = 'fixed';
        fpsDisplay.style.top = '10px';
        fpsDisplay.style.right = '10px';
        fpsDisplay.style.zIndex = '10000';
        fpsDisplay.style.fontFamily = 'Arial, sans-serif';
        fpsDisplay.style.fontSize = '16px';
        fpsDisplay.style.fontWeight = 'bold';
        fpsDisplay.style.padding = '5px 10px';
        fpsDisplay.style.borderRadius = '5px';
        fpsDisplay.style.background = 'rgba(0, 0, 0, 0.5)';
        document.body.appendChild(fpsDisplay);

        let lastFrameTime = performance.now();
        let frames = 0;
        let fps = 0;
        let hue = 0;

        function updateFPS() {
            const now = performance.now();
            frames++;
            if (now - lastFrameTime >= 1000) {
                fps = frames;
                frames = 0;
                lastFrameTime = now;
            }

            hue = (hue + 1) % 360;
            fpsDisplay.style.color = `hsl(${hue}, 100%, 60%)`;
            fpsDisplay.textContent = `FPS: ${fps}`;

            requestAnimationFrame(updateFPS);
        }

        requestAnimationFrame(updateFPS);
    });
})();