Player Border + Smart Auto Space

Highlights player border + auto space when target is visible

当前为 2025-11-13 提交的版本,查看 最新版本

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

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 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);
    });
})();