Gimkit Custom Cosmetic Overlay

Adds a custom cosmetic overlay to Gimkit on the home page and in-game

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Gimkit Custom Cosmetic Overlay
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Adds a custom cosmetic overlay to Gimkit on the home page and in-game
// @author       YourName
// @match        *://www.gimkit.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Cosmetic data stored locally
    let userCosmetic = JSON.parse(localStorage.getItem("gimkitCustomCosmetic")) || {
        color: "#3498db",
        accessory: "🎩"
    };

    // Create a simple UI for selecting color and accessory on the home page and in-game
    function createCosmeticUI() {
        const uiContainer = document.createElement("div");
        uiContainer.style.position = "fixed";
        uiContainer.style.top = "20px";
        uiContainer.style.right = "20px";
        uiContainer.style.padding = "10px";
        uiContainer.style.backgroundColor = "rgba(255, 255, 255, 0.9)";
        uiContainer.style.borderRadius = "8px";
        uiContainer.style.zIndex = "1000";
        uiContainer.style.fontSize = "14px";
        uiContainer.style.fontFamily = "Arial, sans-serif";
        uiContainer.style.boxShadow = "0px 4px 12px rgba(0, 0, 0, 0.1)";
        
        // Title
        const title = document.createElement("h4");
        title.innerText = "Custom Cosmetic";
        title.style.marginBottom = "10px";
        uiContainer.appendChild(title);

        // Color picker
        const colorLabel = document.createElement("label");
        colorLabel.innerText = "Select Color:";
        colorLabel.style.display = "block";
        uiContainer.appendChild(colorLabel);

        const colorInput = document.createElement("input");
        colorInput.type = "color";
        colorInput.value = userCosmetic.color;
        colorInput.style.marginBottom = "10px";
        uiContainer.appendChild(colorInput);

        // Accessory picker
        const accessoryLabel = document.createElement("label");
        accessoryLabel.innerText = "Select Accessory:";
        accessoryLabel.style.display = "block";
        uiContainer.appendChild(accessoryLabel);

        const accessoryInput = document.createElement("input");
        accessoryInput.type = "text";
        accessoryInput.value = userCosmetic.accessory;
        accessoryInput.style.marginBottom = "10px";
        accessoryInput.placeholder = "Enter emoji, e.g., 🎩";
        uiContainer.appendChild(accessoryInput);

        // Save button
        const saveButton = document.createElement("button");
        saveButton.innerText = "Save Cosmetic";
        saveButton.style.display = "block";
        saveButton.style.marginTop = "10px";
        saveButton.onclick = () => {
            userCosmetic = {
                color: colorInput.value,
                accessory: accessoryInput.value
            };
            localStorage.setItem("gimkitCustomCosmetic", JSON.stringify(userCosmetic));
            applyCosmeticOverlay();
        };
        uiContainer.appendChild(saveButton);

        document.body.appendChild(uiContainer);
    }

    // Apply cosmetic overlay in-game or on the home page
    function applyCosmeticOverlay() {
        const interval = setInterval(() => {
            const playerElements = document.querySelectorAll("[class*=playerName]"); // Modify to match actual Gimkit class names if needed
            if (playerElements.length > 0) {
                clearInterval(interval);
                playerElements.forEach(playerElement => {
                    playerElement.style.color = userCosmetic.color;
                    playerElement.innerHTML = `${userCosmetic.accessory} ${playerElement.innerHTML}`;
                });
            }
        }, 1000); // Check every second for player elements
    }

    // Run on specific pages
    if (window.location.pathname.includes("home") || window.location.pathname.includes("game")) {
        createCosmeticUI();
        applyCosmeticOverlay();
    }
})();