Krunker.IO Aimbot & ESP

Aimbot locks to nearest player & ESP shows players behind walls. Includes toggleable settings. For Krunker.io.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Krunker.IO Aimbot & ESP
// @namespace    https://greasyfork.org/users/662330-zertalious
// @version      0.3.1
// @description  Aimbot locks to nearest player & ESP shows players behind walls. Includes toggleable settings. For Krunker.io.
// @author       Zertalious
// @match        *://krunker.io/*
// @match        *://browserfps.com/*
// @exclude      *://krunker.io/social*
// @exclude      *://krunker.io/editor*
// @icon         https://www.google.com/s2/favicons?domain=krunker.io
// @grant        none
// @run-at       document-start
// @require      https://unpkg.com/[email protected]/build/three.min.js
// ==/UserScript==

(function () {
    'use strict';

    const THREE = window.THREE;
    delete window.THREE;

    const settings = {
        aimbotEnabled: true,
        aimbotOnRightMouse: false,
        espEnabled: true,
        espLines: true,
        wireframe: false
    };

    const keyToSetting = {
        KeyB: 'aimbotEnabled',
        KeyL: 'aimbotOnRightMouse',
        KeyM: 'espEnabled',
        KeyN: 'espLines',
        KeyK: 'wireframe'
    };

    const gui = createGUI();
    let scene;

    const x = {
        window: window,
        document: document,
        querySelector: document.querySelector,
        consoleLog: console.log,
        ReflectApply: Reflect.apply,
        ArrayPrototype: Array.prototype,
        ArrayPush: Array.prototype.push,
        ObjectPrototype: Object.prototype,
        clearInterval: window.clearInterval,
        setTimeout: window.setTimeout,
        reToString: RegExp.prototype.toString,
        indexOf: String.prototype.indexOf,
        requestAnimationFrame: window.requestAnimationFrame
    };

    x.consoleLog('Waiting to inject...');

    const proxied = function (object) {
        try {
            if (typeof object === 'object' && object.parent?.type === 'Scene' && object.parent.name === 'Main') {
                x.consoleLog('Found Scene!');
                scene = object.parent;
                x.ArrayPrototype.push = x.ArrayPush;
            }
        } catch (error) {}
        return x.ArrayPush.apply(this, arguments);
    };

    const tempVector = new THREE.Vector3();
    const tempObject = new THREE.Object3D();
    tempObject.rotation.order = 'YXZ';

    const geometry = new THREE.EdgesGeometry(new THREE.BoxGeometry(5, 15, 5).translate(0, 7.5, 0));
    const material = new THREE.RawShaderMaterial({
        vertexShader: `
        attribute vec3 position;
        uniform mat4 projectionMatrix;
        uniform mat4 modelViewMatrix;
        void main() {
            gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
            gl_Position.z = 1.0;
        }`,
        fragmentShader: `
        void main() {
            gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
        }`
    });

    const line = new THREE.LineSegments(new THREE.BufferGeometry(), material);
    line.frustumCulled = false;

    const linePositions = new THREE.BufferAttribute(new Float32Array(100 * 2 * 3), 3);
    line.geometry.setAttribute('position', linePositions);

    let injectTimer = null;

    function animate() {
        x.requestAnimationFrame.call(x.window, animate);

        if (!scene && !injectTimer) {
            const el = x.querySelector.call(x.document, '#loadingBg');
            if (el && el.style.display === 'none') {
                x.consoleLog('Inject timer started!');
                injectTimer = x.setTimeout.call(x.window, () => {
                    x.consoleLog('Injected!');
                    x.ArrayPrototype.push = proxied;
                }, 2000);
            }
        }

        if (!scene?.children) return;

        const players = [];
        let myPlayer;

        for (const child of scene.children) {
            if (child.type === 'Object3D') {
                try {
                    if (child.children[0]?.children[0]?.type === 'PerspectiveCamera') {
                        myPlayer = child;
                    } else {
                        players.push(child);
                    }
                } catch (err) {}
            } else if (child.material) {
                child.material.wireframe = settings.wireframe;
            }
        }

        if (!myPlayer) {
            x.consoleLog('Player not found, finding new scene.');
            x.ArrayPrototype.push = proxied;
            return;
        }

        let counter = 0;
        let targetPlayer;
        let minDistance = Infinity;

        tempObject.matrix.copy(myPlayer.matrix).invert();

        for (const player of players) {
            if (!player.box) {
                const box = new THREE.LineSegments(geometry, material);
                box.frustumCulled = false;
                player.add(box);
                player.box = box;
            }

            if (player.position.equals(myPlayer.position)) {
                player.box.visible = false;
                if (line.parent !== player) player.add(line);
                continue;
            }

            linePositions.setXYZ(counter++, 0, 10, -5);

            tempVector.copy(player.position);
            tempVector.y += 9;
            tempVector.applyMatrix4(tempObject.matrix);

            linePositions.setXYZ(counter++, tempVector.x, tempVector.y, tempVector.z);

            player.visible = settings.espEnabled || player.visible;
            player.box.visible = settings.espEnabled;

            const distance = player.position.distanceTo(myPlayer.position);
            if (distance < minDistance) {
                targetPlayer = player;
                minDistance = distance;
            }
        }

        linePositions.needsUpdate = true;
        line.geometry.setDrawRange(0, counter);
        line.visible = settings.espLines;

        if (!settings.aimbotEnabled || (settings.aimbotOnRightMouse && !rightMouseDown) || !targetPlayer) return;

        tempVector.setScalar(0);
        targetPlayer.children[0]?.children[0]?.localToWorld(tempVector);
        tempObject.position.copy(myPlayer.position);
        tempObject.lookAt(tempVector);
        myPlayer.children[0].rotation.x = -tempObject.rotation.x;
        myPlayer.rotation.y = tempObject.rotation.y + Math.PI;
    }

    let rightMouseDown = false;

    function handleMouse(event) {
        if (event.button === 2) rightMouseDown = event.type === 'pointerdown';
    }

    window.addEventListener('pointerdown', handleMouse);
    window.addEventListener('pointerup', handleMouse);

    window.addEventListener('keyup', (event) => {
        if (x.document.activeElement?.value !== undefined) return;
        if (keyToSetting[event.code]) toggleSetting(keyToSetting[event.code]);
        if (event.code === 'Slash') toggleElementVisibility(gui);
    });

    function toggleElementVisibility(el) {
        el.style.display = el.style.display === '' ? 'none' : '';
    }

    animate();

    function createGUI() {
        const guiEl = fromHtml(`
        <div style="position:fixed;top:10px;right:10px;background:#000;padding:10px;color:#fff;z-index:9999;">
            <div>Aimbot & ESP by Zertalious</div>
            ${Object.keys(settings).map(key => `
            <div>
                ${key}: <span id="toggle-${key}">${settings[key]}</span>
            </div>`).join('')}
        </div>`);
        document.body.appendChild(guiEl);
        return guiEl;
    }

    function fromHtml(html) {
        const div = document.createElement('div');
        div.innerHTML = html;
        return div.firstChild;
    }

    function toggleSetting(key) {
        settings[key] = !settings[key];
        document.getElementById(`toggle-${key}`).innerText = settings[key];
    }
})();