Hammer Senpa.io Mod - Performance & Visual Enhancements with GUI

Optimize Senpa.io with FPS optimization, freeze on death, and visual effects, all customizable via GUI

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Hammer Senpa.io Mod - Performance & Visual Enhancements with GUI
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Optimize Senpa.io with FPS optimization, freeze on death, and visual effects, all customizable via GUI
// @author       Hammer
// @match        https://senpa.io/*
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // Initial states
    let optimizationEnabled = true;
    let fxOn = true;
    let isFrozen = false;

    // Create the small toggle button (bottom right)
    const smallGui = document.createElement('div');
    smallGui.id = 'small-gui';
    smallGui.style.position = 'fixed';
    smallGui.style.bottom = '20px';
    smallGui.style.right = '20px';
    smallGui.style.width = '50px';
    smallGui.style.height = '50px';
    smallGui.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
    smallGui.style.color = 'white';
    smallGui.style.textAlign = 'center';
    smallGui.style.fontSize = '14px';
    smallGui.style.borderRadius = '5px';
    smallGui.style.cursor = 'pointer';
    smallGui.style.zIndex = '9999';
    smallGui.innerText = 'Mods';

    document.body.appendChild(smallGui);

    // Create the larger menu (hidden initially)
    const guiContainer = document.createElement('div');
    guiContainer.id = 'gui-container';
    guiContainer.style.position = 'fixed';
    guiContainer.style.bottom = '100px';
    guiContainer.style.right = '20px';
    guiContainer.style.width = '250px';
    guiContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
    guiContainer.style.color = 'white';
    guiContainer.style.padding = '20px';
    guiContainer.style.borderRadius = '10px';
    guiContainer.style.zIndex = '9999';
    guiContainer.style.display = 'none';
    guiContainer.style.fontFamily = 'Arial, sans-serif';

    const closeButton = document.createElement('button');
    closeButton.innerText = 'X';
    closeButton.style.backgroundColor = '#dc3545';
    closeButton.style.color = 'white';
    closeButton.style.border = 'none';
    closeButton.style.padding = '5px';
    closeButton.style.borderRadius = '50%';
    closeButton.style.cursor = 'pointer';
    closeButton.style.position = 'absolute';
    closeButton.style.top = '10px';
    closeButton.style.right = '10px';
    closeButton.addEventListener('click', () => {
        guiContainer.style.display = 'none';  // Close the menu
    });
    
    const optimizationToggle = document.createElement('button');
    optimizationToggle.innerText = optimizationEnabled ? 'Disable FPS Optimization' : 'Enable FPS Optimization';
    optimizationToggle.style.backgroundColor = optimizationEnabled ? '#28a745' : '#dc3545';
    optimizationToggle.style.color = 'white';
    optimizationToggle.style.border = 'none';
    optimizationToggle.style.padding = '10px';
    optimizationToggle.style.borderRadius = '5px';
    optimizationToggle.style.cursor = 'pointer';
    optimizationToggle.style.marginBottom = '10px';
    optimizationToggle.addEventListener('click', () => {
        optimizationEnabled = !optimizationEnabled;
        optimizationToggle.innerText = optimizationEnabled ? 'Disable FPS Optimization' : 'Enable FPS Optimization';
        optimizationToggle.style.backgroundColor = optimizationEnabled ? '#28a745' : '#dc3545';
        if (optimizationEnabled) {
            enableOptimization();
        } else {
            disableOptimization();
        }
    });

    const fxToggle = document.createElement('button');
    fxToggle.innerText = fxOn ? 'Disable FX' : 'Enable FX';
    fxToggle.style.backgroundColor = fxOn ? '#28a745' : '#dc3545';
    fxToggle.style.color = 'white';
    fxToggle.style.border = 'none';
    fxToggle.style.padding = '10px';
    fxToggle.style.borderRadius = '5px';
    fxToggle.style.cursor = 'pointer';
    fxToggle.style.marginBottom = '10px';
    fxToggle.addEventListener('click', () => {
        fxOn = !fxOn;
        fxToggle.innerText = fxOn ? 'Disable FX' : 'Enable FX';
        fxToggle.style.backgroundColor = fxOn ? '#28a745' : '#dc3545';
        applyVisualEffects();
    });

    const freezeToggle = document.createElement('button');
    freezeToggle.innerText = isFrozen ? 'Unfreeze on Death' : 'Freeze on Death';
    freezeToggle.style.backgroundColor = isFrozen ? '#dc3545' : '#28a745';
    freezeToggle.style.color = 'white';
    freezeToggle.style.border = 'none';
    freezeToggle.style.padding = '10px';
    freezeToggle.style.borderRadius = '5px';
    freezeToggle.style.cursor = 'pointer';
    freezeToggle.addEventListener('click', () => {
        isFrozen = !isFrozen;
        freezeToggle.innerText = isFrozen ? 'Unfreeze on Death' : 'Freeze on Death';
        freezeToggle.style.backgroundColor = isFrozen ? '#dc3545' : '#28a745';
    });

    const hammerText = document.createElement('div');
    hammerText.innerText = 'hammer';
    hammerText.style.color = '#fff';
    hammerText.style.fontSize = '14px';
    hammerText.style.textAlign = 'center';
    hammerText.style.marginTop = '20px';

    guiContainer.appendChild(closeButton);
    guiContainer.appendChild(optimizationToggle);
    guiContainer.appendChild(fxToggle);
    guiContainer.appendChild(freezeToggle);
    guiContainer.appendChild(hammerText);  // Add the "hammer" text
    document.body.appendChild(guiContainer);

    // Toggle menu visibility when small GUI is clicked
    smallGui.addEventListener('click', () => {
        guiContainer.style.display = guiContainer.style.display === 'none' ? 'block' : 'none';
    });

    // Apply visual effects (brightness, contrast, etc.)
    function applyVisualEffects() {
        const canvas = document.querySelector('canvas');
        if (canvas) {
            canvas.style.filter = fxOn ? 'brightness(1.1) contrast(1.2) saturate(1.1)' : 'none';
        }
    }

    // Function to enable FPS optimization
    function enableOptimization() {
        document.body.style.backgroundImage = 'none';
        const images = document.querySelectorAll('img');
        images.forEach(img => {
            img.src = '';  // Remove image sources
        });

        const style = document.createElement('style');
        style.innerHTML = `
            * {
                animation: none !important;
                transition: none !important;
                box-shadow: none !important;
            }
            canvas {
                image-rendering: optimizeSpeed;
                will-change: transform;
            }
            body, html {
                background: #000 !important;
                overflow: hidden;
                margin: 0;
                padding: 0;
            }
        `;
        document.head.appendChild(style);

        const audios = document.querySelectorAll('audio');
        audios.forEach(audio => {
            audio.pause();  // Pause background music
        });

        const ads = document.querySelectorAll('.ad, .sidebar, .popup');
        ads.forEach(ad => ad.remove());  // Remove ads and popups
    }

    // Function to disable FPS optimization
    function disableOptimization() {
        const style = document.createElement('style');
        style.innerHTML = `
            * {
                animation: initial !important;
                transition: initial !important;
            }
        `;
        document.head.appendChild(style);
    }

    // Freeze the player on death (if enabled)
    function freezeOnDeath() {
        if (!isFrozen) return;

        const player = document.querySelector('.player');  // Adjust selector as necessary
        if (!player) return;

        isFrozen = true;

        document.addEventListener('keydown', preventMovement);
        document.addEventListener('mousemove', preventMovement);
        document.addEventListener('mousedown', preventMovement);

        setTimeout(() => {
            isFrozen = false;
            document.removeEventListener('keydown', preventMovement);
            document.removeEventListener('mousemove', preventMovement);
            document.removeEventListener('mousedown', preventMovement);
        }, 3000);  // Freeze for 3 seconds (adjust as needed)
    }

    function preventMovement(event) {
        event.preventDefault();
        event.stopPropagation();
    }

    // Periodically check for death and freeze the player if necessary
    setInterval(() => {
        const deathState = document.querySelector('.dead');  // Update selector based on game's death state
        if (deathState && isFrozen) {
            freezeOnDeath();
        }
    }, 1000);

    // Initialize optimizations
    if (optimizationEnabled) {
        enableOptimization();
    }
    if (fxOn) {
        applyVisualEffects();
    }
})();