Player Border + Smart Auto Space

Highlights player border + auto space when target is visible

Versione datata 13/11/2025. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Player Border + Smart Auto Space
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Highlights player border + auto space when target is visible
// @author       Havvingyy
// @match        *://smashkarts.io/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function waitForGame(callback) {
        const interval = setInterval(() => {
            if (window.game && window.game.player && window.game.players) {
                clearInterval(interval);
                callback();
            }
        }, 100);
    }

    waitForGame(() => {
        // Popup
        const popup = document.createElement('div');
        popup.style.position = 'fixed';
        popup.style.top = '0';
        popup.style.left = '0';
        popup.style.width = '100%';
        popup.style.backgroundColor = '#333';
        popup.style.color = '#fff';
        popup.style.padding = '10px';
        popup.style.textAlign = 'center';
        popup.style.zIndex = '9999';
        popup.style.fontFamily = 'monospace';
        popup.innerHTML = 'Player Border + Smart Auto-Space Enabled.<button style="margin-left:10px;background:#ff6600;color:#fff;border:none;padding:5px 10px;border-radius:5px;cursor:pointer;" onclick="this.parentNode.remove()">Close</button>';
        document.body.appendChild(popup);

        // Shader override for blinking border
        const originalShader = WebGL2RenderingContext.prototype.shaderSource;
        WebGL2RenderingContext.prototype.shaderSource = function(shader, src) {
            if (src.includes("hlslcc_mtx4x4unity_ObjectToWorld[4]") &&
                src.includes("hlslcc_mtx4x4unity_MatrixVP[4]")) {
                src = src.replace(/gl_Position = [\s\S]*?;/, m => m + "\n    gl_Position.xy += 0.005 * sin(gl_FragCoord.x * 10.0);");
            }
            return originalShader.apply(this, [shader, src]);
        };

        // Raycast line-of-sight check
        function isVisible(player, target) {
            const walls = window.game.walls || [];
            const steps = 10;
            const dx = (target.x - player.x)/steps;
            const dy = (target.y - player.y)/steps;
            for (let i = 1; i <= steps; i++) {
                const px = player.x + dx*i, py = player.y + dy*i;
                if (walls.some(w => px >= w.x && px <= w.x + w.width && py >= w.y && py <= w.y + w.height)) return false;
            }
            return true;
        }

        // Smart auto-space
        function autoSpace() {
            const player = window.game.player;
            const allPlayers = window.game.players;
            allPlayers.forEach(t => {
                if (t === player) return;
                const dx = t.x - player.x, dy = t.y - player.y;
                const angleDiff = Math.abs(Math.atan2(dy, dx) - player.rotation);
                if (angleDiff < 0.2 && Math.hypot(dx, dy) < 10 && isVisible(player, t)) {
                    document.dispatchEvent(new KeyboardEvent('keydown', { key: ' ', bubbles: true }));
                }
            });
        }
        setInterval(autoSpace, 50);
    });
})();