Thin Moving Crosshair

moving cross hair

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Thin Moving Crosshair
// @match        *://*.shellshock.io/*
// @grant        none
// @description moving cross hair
// @version 0.0.1.20251120194352
// @namespace https://greasyfork.org/users/1357667
// ==/UserScript==

(function () {
    function waitForElement(id) {
        return new Promise(resolve => {
            const check = setInterval(() => {
                const el = document.getElementById(id);
                if (el) {
                    clearInterval(check);
                    resolve(el);
                }
            }, 100);
        });
    }

    waitForElement("crosshairContainer").then(container => {
        console.log("Crosshair container found!");

        
        const ch = document.createElement("div");
        ch.id = "thinCrosshair";
        Object.assign(ch.style, {
            position: "absolute",
            left: "50%",
            top: "50%",
            transform: "translate(-50%, -50%)",
            pointerEvents: "none",
            zIndex: 1
        });

        const vert = document.createElement("div");
        Object.assign(vert.style, {
            position: "absolute",
            width: "1.2px",
            height: "24px",
            background: "#ffffff",
            left: "50%",
            top: "50%",
            transform: "translate(-50%, -50%)"
        });

        const horiz = document.createElement("div");
        Object.assign(horiz.style, {
            position: "absolute",
            width: "24px",
            height: "1.2px",
            background: "#ffffff",
            left: "50%",
            top: "50%",
            transform: "translate(-50%, -50%)"
        });

        ch.appendChild(vert);
        ch.appendChild(horiz);
        container.appendChild(ch);

        
        let offsetX = 0, offsetY = 0;
        const strength = 0.28;  // how much it moves
        const smoothing = 0.15; // reduce jitter

        document.addEventListener("mousemove", e => {
            
            if (document.pointerLockElement == null) return;

            offsetX += e.movementX * strength;
            offsetY += e.movementY * strength;
        });

        function animate() {
  
            offsetX *= (1 - smoothing);
            offsetY *= (1 - smoothing);

            ch.style.transform =
                `translate(calc(-50% + ${offsetX}px), calc(-50% + ${offsetY}px))`;

            requestAnimationFrame(animate);
        }
        animate();
    });
})();