twisted

Twisted - op kranker dot eye oh h4x dll firefox api

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         twisted
// @version      1.0.6
// @author       Twisted
// @description  Twisted - op kranker dot eye oh h4x dll firefox api
// @match        *://krunker.io/*
// @grant        GM.registerMenuCommand
// @grant        unsafeWindow
// @run-at       document-start
// @namespace https://greasyfork.org/users/717607
// ==/UserScript==

window = unsafeWindow;

window.hackToggle = true;

let game, input, me, recon, lock;

const key = {
    frame: 0,
    delta: 1,
    xdir: 2,
    ydir: 3,
    moveDir: 4,
    shoot: 5,
    scope: 6,
    jump: 7,
    reload: 8,
    crouch: 9,
    weaponScroll: 10,
    weaponSwap: 11,
    moveLock: 12
};

const varsRe = {
    cnBSeen: { regex: /(&&!\w\['\w+']&&\w\['\w+'\]&&)\w\['(\w+)'](\){)/, pos: 2 },
    recoilAnimY: { regex: /this\['(\w+)']\+=this\['\w+']\*\(/, pos: 1 },
    aimVal: { regex: /this\['(\w+)']-=0x1\/\(this\['weapon']\['\w+']\/\w+\)/, pos: 1 },
    pchObjc: { regex: /0x0,this\['(\w+)']=new \w+\['Object3D']\(\),this/, pos: 1 },
    didShoot: { regex: /--,\w+\['(\w+)']=!0x0/, pos: 1 },
    nAuto: { regex: /'Single\\x20Fire','varN':'(\w+)'/, pos: 1 }
}

const vars = {}

const getDistance = function(x1, y1, z1, x2, y2, z2) {
    var dx = x1 - x2;
    var dy = y1 - y2;
    var dz = z1 - z2;
    return Math.hypot(dx, dy, dz);
}

const getDirection = function(a, b, c, d) {
    return Math.atan2(b - d, a - c);
}

const getXDir = function(e, n, r, i, a, s) {
    const o = Math.abs(n - a);
    const dis = getDistance(e, n, r, i, a, s);
    return Math.asin(o / dis) * (n > a ? -1 : 1);
}

const getTarget = function() {
    let fil = game.players.list.filter(function(player) {
        return (player[vars.cnBSeen] && player.active && player !== me) && (!me.team || me.team !== player.team)
    });
    return fil[0];
}

const shoot = function() {
    input[key.scope] = 1;
    let weapon = me.weapon;
    if (weapon[vars.nAuto] && me[vars.didShoot]) {
        input[key.shoot] = 0;
    } else if (!me[vars.aimVal]) {
        input[key.shoot] = 1;
    }
}

const toggleHack = function() {
    window.hackToggle = !window.hackToggle;
}

window.useHack = function(i, g, m, r, l) {
    game = g; input = i; me = m; recon = r; lock = l;

    let target = getTarget();
    if (target && window.hackToggle) {
        const yDire = (getDirection(me.z, me.x, target.z, target.x) || 0) * 1000;
        const xDire = ((getXDir(me.x, me.y, me.z, target.x, target.y, target.z) || 0) - (0.3 * me[vars.recoilAnimY])) * 1000;

        input[key.ydir] = yDire;
        input[key.xdir] = xDire;

        shoot();
    }
}

const patchCode = function(code) {
    for (let i in varsRe) {
        const key = varsRe[i];
        vars[i] = key.regex.exec(code)[key.pos];
    }
    code = code.replace(varsRe.cnBSeen.regex, "$1true$3").replace(/!(\w+)\['transparent']/, `$&& (!window.hackToggle || !$1.penetrable )`).replace(/(this\['\w+']=function\(\w+,\w+,\w+,\w+\){)(this\['recon'])/, "$1{\nconst [input, game, recon, lock] = arguments, me = this;\nwindow.useHack(input, game, me, recon, lock);};$2") // patches code
    GM.registerMenuCommand("Toggle Hack", toggleHack);
    return code;
}

const _Function = Function;
window.Function = new Proxy(Function, {
    construct(target, args) {
        if ((args[2] || "").startsWith("var vrtInit")) {
            args[2] = patchCode(args[2]);
            window.Function = _Function;
        }
        return new target(...args);
    }
})