Hammer Senpa.io Mod - UI Tweaks & Enhancements

Tweaks Senpa.io UI: Removes ad panel, preserves side GUIs, and keeps mod box visible & movable

当前为 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 - UI Tweaks & Enhancements
// @namespace    http://tampermonkey.net/
// @version      2.1
// @description  Tweaks Senpa.io UI: Removes ad panel, preserves side GUIs, and keeps mod box visible & movable
// @author       Hammer
// @match        https://senpa.io/*
// @grant        GM_addStyle
// ==/UserScript==

(function () {
    'use strict';

    let optimizationEnabled = true;
    let fxOn = true;
    let isFrozen = false;
    let isBlurred = false;

    // Style the small GUI initially center (moves later)
    const smallGui = document.createElement('div');
    smallGui.id = 'small-gui';
    Object.assign(smallGui.style, {
        position: 'fixed',
        top: '50%',
        left: '50%',
        transform: 'translate(-50%, -50%)',
        width: '70px',
        height: '50px',
        backgroundColor: 'rgba(0, 0, 0, 0.7)',
        color: 'white',
        textAlign: 'center',
        fontSize: '14px',
        borderRadius: '5px',
        cursor: 'pointer',
        zIndex: '9999',
        border: '2px solid red'
    });
    smallGui.innerText = 'Mods';
    document.body.appendChild(smallGui);

    const guiContainer = document.createElement('div');
    guiContainer.id = 'gui-container';
    Object.assign(guiContainer.style, {
        position: 'fixed',
        top: '60%',
        left: '50%',
        transform: 'translateX(-50%)',
        width: '250px',
        backgroundColor: 'rgba(0, 0, 0, 0.8)',
        color: 'white',
        padding: '20px',
        borderRadius: '10px',
        zIndex: '9999',
        display: 'none',
        fontFamily: 'Arial, sans-serif',
        border: '2px solid red'
    });

    const closeButton = document.createElement('button');
    closeButton.innerText = 'X';
    Object.assign(closeButton.style, {
        backgroundColor: '#dc3545',
        color: 'white',
        border: 'none',
        padding: '5px',
        borderRadius: '50%',
        cursor: 'pointer',
        position: 'absolute',
        top: '10px',
        right: '10px'
    });
    closeButton.addEventListener('click', () => {
        guiContainer.style.display = 'none';
        hammerText.style.display = 'none';
    });

    const hammerText = document.createElement('div');
    hammerText.innerText = 'made by hammer <3';
    Object.assign(hammerText.style, {
        color: '#fff',
        fontSize: '14px',
        textAlign: 'center',
        marginTop: '20px',
        display: 'none'
    });

    function createToggleButton(textOn, textOff, initialState, callback) {
        const btn = document.createElement('button');
        btn.innerText = initialState ? textOff : textOn;
        btn.style.backgroundColor = initialState ? '#28a745' : '#dc3545';
        btn.style.color = 'white';
        btn.style.border = 'none';
        btn.style.padding = '10px';
        btn.style.borderRadius = '5px';
        btn.style.cursor = 'pointer';
        btn.style.marginBottom = '10px';
        btn.addEventListener('click', () => {
            const newState = callback();
            btn.innerText = newState ? textOff : textOn;
            btn.style.backgroundColor = newState ? '#28a745' : '#dc3545';
        });
        return btn;
    }

    guiContainer.appendChild(closeButton);
    guiContainer.appendChild(createToggleButton('Enable FPS Optimization', 'Disable FPS Optimization', optimizationEnabled, () => {
        optimizationEnabled = !optimizationEnabled;
        optimizationEnabled ? enableOptimization() : disableOptimization();
        return optimizationEnabled;
    }));
    guiContainer.appendChild(createToggleButton('Enable FX', 'Disable FX', fxOn, () => {
        fxOn = !fxOn;
        applyVisualEffects();
        return fxOn;
    }));
    guiContainer.appendChild(createToggleButton('Freeze on Death', 'Unfreeze on Death', isFrozen, () => {
        isFrozen = !isFrozen;
        return isFrozen;
    }));
    guiContainer.appendChild(createToggleButton('Enable Background Blur', 'Disable Background Blur', isBlurred, () => {
        isBlurred = !isBlurred;
        const canvas = document.querySelector('canvas');
        if (canvas) {
            canvas.style.filter = isBlurred ? 'blur(3px)' : 'none';
        }
        document.body.style.backdropFilter = isBlurred ? 'blur(2px)' : 'none';
        return isBlurred;
    }));
    guiContainer.appendChild(hammerText);
    document.body.appendChild(guiContainer);

    smallGui.addEventListener('click', () => {
        const isHidden = guiContainer.style.display === 'none';
        guiContainer.style.display = isHidden ? 'block' : 'none';
        hammerText.style.display = isHidden ? 'block' : 'none';
    });

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

    function enableOptimization() {
        document.body.style.backgroundImage = 'none';
        document.querySelectorAll('img').forEach(img => img.src = '');
        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);
        document.querySelectorAll('audio').forEach(audio => audio.pause());
        document.querySelectorAll('.ad, .sidebar, .popup').forEach(ad => ad.remove());
    }

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

    function freezeOnDeath() {
        if (!isFrozen) return;
        const player = document.querySelector('.player');
        if (!player) return;

        isFrozen = true;
        const preventMovement = e => { e.preventDefault(); e.stopPropagation(); };

        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);
    }

    // Check for death/game start and adjust UI accordingly
    const observer = new MutationObserver(() => {
        const middleAd = document.querySelector('.middle, .middle-panel, .ad-middle');
        if (middleAd) {
            middleAd.remove();
        }

        const inGame = document.querySelector('.player');
        if (inGame) {
            smallGui.style.top = 'auto';
            smallGui.style.left = 'auto';
            smallGui.style.bottom = '20px';
            smallGui.style.right = '20px';
            smallGui.style.transform = 'none';

            guiContainer.style.top = 'auto';
            guiContainer.style.left = 'auto';
            guiContainer.style.bottom = '80px';
            guiContainer.style.right = '20px';
            guiContainer.style.transform = 'none';
        }
    });

    observer.observe(document.body, { childList: true, subtree: true });

    setInterval(() => {
        const deathState = document.querySelector('.dead');
        if (deathState && isFrozen) {
            freezeOnDeath();
        }
    }, 1000);

    if (optimizationEnabled) enableOptimization();
    if (fxOn) applyVisualEffects();
})();