Smash Karts Wapenmenu

Kies je eigen wapens in Smash Karts met een menu (druk op 'G')

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Smash Karts Wapenmenu
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Kies je eigen wapens in Smash Karts met een menu (druk op 'G')
// @author       JouwNaam
// @match        *://smashkarts.io/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let gameInstance = null;

    function findGameInstance() {
        let allObjects = Object.values(window);
        for (let obj of allObjects) {
            if (obj && obj.players && obj.addEventListener) {
                gameInstance = obj;
                console.log("✅ Game-instantie gevonden!", gameInstance);
                return;
            }
        }
        console.log("❌ Game niet gevonden!");
    }

    function createWeaponMenu() {
        let menu = document.createElement("div");
        menu.id = "weapon-menu";
        menu.style.position = "fixed";
        menu.style.top = "50px";
        menu.style.left = "50px";
        menu.style.background = "rgba(0,0,0,0.8)";
        menu.style.padding = "10px";
        menu.style.borderRadius = "10px";
        menu.style.color = "white";
        menu.style.fontSize = "16px";
        menu.style.zIndex = "9999";
        menu.style.display = "none";

        let weapons = ["Minigun", "Raket", "Mijnen", "Shotgun", "Sniper"];

        weapons.forEach(weapon => {
            let btn = document.createElement("button");
            btn.innerText = weapon;
            btn.style.display = "block";
            btn.style.margin = "5px";
            btn.style.padding = "5px";
            btn.style.background = "#ff6600";
            btn.style.border = "none";
            btn.style.color = "white";
            btn.style.cursor = "pointer";
            btn.onclick = () => selectWeapon(weapon);
            menu.appendChild(btn);
        });

        document.body.appendChild(menu);

        document.addEventListener("keydown", function(event) {
            if (event.key === "G" || event.key === "g") {
                menu.style.display = menu.style.display === "none" ? "block" : "none";
            }
        });
    }

    function selectWeapon(weapon) {
        if (!gameInstance) {
            alert("Game niet gevonden! Probeer opnieuw.");
            return;
        }

        let player = Object.values(gameInstance.players)[0];
        if (!player) {
            alert("Speler niet gevonden!");
            return;
        }

        player.inventory.push(weapon);
        alert(`${weapon} geselecteerd!`);
    }

    setTimeout(() => {
        findGameInstance();
        createWeaponMenu();
    }, 5000);
})();