Wolf_ RGB Menu

RGB gun

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Advertisement:

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

Advertisement:

// ==UserScript==
// @name         Wolf_ RGB Menu
// @match        *://kour.io/*
// @version      final
// @author       wolf_
// @description  RGB gun
// @run-at       document-start
// @grant        none
// @namespace https://greasyfork.org/users/1598070
// ==/UserScript==

(function () {
    'use strict';

    let savedPos =
        JSON.parse(
            localStorage.getItem('wolfMenuPos')
        ) || {
            top: '15px',
            left: 'auto',
            right: '15px'
        };

    let rgbEnabled =
        localStorage.getItem(
            'wolfRgbEnabled'
        ) !== 'false';


    const GUN_IDS = [
        7092,
        1998,
        2118,
        1746
    ];

    const XM1014_GHOST_IDS = [
        3624,
        3816,
        4284
    ];

    let menuVisible = true;

    let hue = 0;
    let speed = 0.6;



    const style =
        document.createElement('style');

    style.innerHTML = `
        @keyframes neonGlow {

            0% {
                box-shadow:
                    0 0 10px rgba(255,0,0,0.4),
                    inset 0 0 5px rgba(255,0,0,0.2);
            }

            50% {
                box-shadow:
                    0 0 25px rgba(255,0,0,0.8),
                    inset 0 0 10px rgba(255,0,0,0.4);
            }

            100% {
                box-shadow:
                    0 0 10px rgba(255,0,0,0.4),
                    inset 0 0 5px rgba(255,0,0,0.2);
            }
        }
    `;

    document.head.appendChild(style);

    const menu =
        document.createElement('div');

    menu.id = 'wolfRgbMenu';

    menu.style.cssText = `
        position:fixed;

        top:${savedPos.top};
        left:${savedPos.left};
        right:${savedPos.right};

        z-index:999999;

        background:rgba(10,10,10,0.98);

        color:white;

        padding:12px 15px;

        border-radius:8px;

        border:1px solid rgba(255,0,0,0.9);

        min-width:170px;

        text-align:center;

        cursor:move;

        user-select:none;

        backdrop-filter:blur(8px);

        animation:
            neonGlow 2s infinite ease-in-out;

        font-family:sans-serif;
    `;

    menu.innerHTML = `
        <div style="
            border-bottom:
                1px solid rgba(255,255,255,0.08);

            margin-bottom:10px;

            padding-bottom:6px;
        ">
            <b style="
                font-size:15px;

                color:white;

                text-shadow:0 0 8px red;
            ">
                RGB COLOR FOR GUNS
            </b>
        </div>

        <div style="
            background:
                rgba(255,255,255,0.03);

            padding:8px;

            border-radius:6px;

            margin-bottom:8px;
        ">

            <label style="
                display:flex;

                align-items:center;

                justify-content:center;

                font-size:13px;

                font-weight:bold;

                cursor:pointer;
            ">

                <input
                    type="checkbox"
                    id="rgbToggle"
                    ${rgbEnabled ? 'checked' : ''}

                    style="
                        margin-right:8px;
                        accent-color:red;
                    "
                >

                ENABLE
            </label>

            <span style="
                display:block;

                margin-top:4px;

                color:red;

                font-size:11px;

                font-weight:bold;
            ">
                Made by wolf_
            </span>
        </div>

        <div style="
            margin-top:8px;

            font-size:11px;
        ">
            Press
            <span style="color:red;">
                G
            </span>
            to Hide
        </div>
    `;

    document.addEventListener(
        'DOMContentLoaded',
        () => {

            document.body.appendChild(menu);

            initMenu();

        }
    );


    function initMenu() {

        let isDragging = false;

        let offset = [0, 0];

        menu.onmousedown = (e) => {

            if (
                e.target.id !== 'rgbToggle'
            ) {

                isDragging = true;

                offset = [
                    menu.offsetLeft - e.clientX,
                    menu.offsetTop - e.clientY
                ];
            }
        };

        document.onmousemove = (e) => {

            if (!isDragging) return;

            let newX = Math.max(
                2,
                Math.min(
                    e.clientX + offset[0],
                    window.innerWidth -
                    menu.offsetWidth - 2
                )
            );

            let newY = Math.max(
                2,
                Math.min(
                    e.clientY + offset[1],
                    window.innerHeight -
                    menu.offsetHeight - 2
                )
            );

            menu.style.left =
                newX + 'px';

            menu.style.top =
                newY + 'px';

            menu.style.right =
                'auto';
        };

        document.onmouseup = () => {

            if (isDragging) {

                isDragging = false;

                localStorage.setItem(
                    'wolfMenuPos',

                    JSON.stringify({
                        top: menu.style.top,
                        left: menu.style.left,
                        right: 'auto'
                    })
                );
            }
        };

        document.addEventListener(
            'keydown',
            (e) => {

                if (
                    e.key.toLowerCase() === 'g'
                ) {

                    menuVisible =
                        !menuVisible;

                    menu.style.display =
                        menuVisible
                            ? 'block'
                            : 'none';
                }
            }
        );

        document
            .getElementById(
                'rgbToggle'
            )
            .onchange = (e) => {

                rgbEnabled =
                    e.target.checked;

                localStorage.setItem(
                    'wolfRgbEnabled',
                    rgbEnabled
                );
            };
    }


    function rainbowColor() {

        hue =
            (hue + speed) % 360;

        const s = 1;

        const l = 0.5;

        const a =
            s * Math.min(
                l,
                1 - l
            );

        const f = (
            n,
            k = (n + hue / 30) % 12
        ) =>
            l - a *
            Math.max(
                Math.min(
                    k - 3,
                    9 - k,
                    1
                ),
                -1
            );

        return [
            f(0),
            f(8),
            f(4)
        ];
    }

    function hook(proto) {

        const original =
            proto.drawElements;

        proto.drawElements = function (
            mode,
            count,
            type,
            offset
        ) {

            if (
                XM1014_GHOST_IDS.includes(count)
            ) {
                return;
            }


            if (
                rgbEnabled &&
                GUN_IDS.includes(count)
            ) {

                const vp =
                    this.getParameter(
                        this.VIEWPORT
                    );

                const isLocalGun =
                    vp &&
                    (
                        vp[2] <
                        window.innerWidth ||

                        vp[3] <
                        window.innerHeight
                    );

                if (isLocalGun) {

                    const rgb =
                        rainbowColor();

                    this.enable(
                        this.BLEND
                    );

                    this.blendFunc(
                        this.CONSTANT_COLOR,
                        this.ZERO
                    );

                    this.blendColor(
                        rgb[0],
                        rgb[1],
                        rgb[2],
                        1.0
                    );

                    const res =
                        original.call(
                            this,
                            mode,
                            count,
                            type,
                            offset
                        );

                    this.disable(
                        this.BLEND
                    );

                    return res;
                }
            }

            return original.call(
                this,
                mode,
                count,
                type,
                offset
            );
        };
    }

    if (
        window.WebGLRenderingContext
    ) {

        hook(
            WebGLRenderingContext.prototype
        );
    }

    if (
        window.WebGL2RenderingContext
    ) {

        hook(
            WebGL2RenderingContext.prototype
        );
    }

})();