Player Border + Smart Auto Space

Highlights player border + auto space when target is visible

目前為 2025-11-13 提交的版本,檢視 最新版本

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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);
    });
})();