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 提交的版本,檢視 最新版本

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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();
    }
})();