Advertisement
Guest User

Krunker.IO Aimbot & ESP (Clean, No-ADS etc...)

a guest
Mar 13th, 2023
2,763
-1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Krunker.IO Aimbot & ESP
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.2.1
  5. // @description  Locks aim to the nearest player in krunker.io and shows players behind walls. Also shows a line between you and them.
  6. // @author       Someone
  7. // @match        *://krunker.io/*
  8. // @match        *://browserfps.com/*
  9. // @exclude      *://krunker.io/social*
  10. // @exclude      *://krunker.io/editor*
  11. // @icon         https://www.google.com/s2/favicons?domain=krunker.io
  12. // @grant        none
  13. // @run-at       document-start
  14. // @require      https://unpkg.com/three@latest/build/three.min.js
  15. // ==/UserScript==
  16. let scene;
  17.  
  18. const x = {
  19.     document: document,
  20.     querySelector: document.querySelector,
  21.     consoleLog: console.log,
  22.     ReflectApply: Reflect.apply,
  23.     ArrayPrototype: Array.prototype
  24. };
  25.  
  26. const proxied = new Proxy(Array.prototype.push, {
  27.     apply(target, thisArgs, [object]) {
  28.         try {
  29.             if (typeof object === 'object' &&
  30.                 typeof object.parent === 'object' &&
  31.                 object.parent.type === 'Scene' &&
  32.                 object.parent.name === 'Main') {
  33.  
  34.                 scene = object.parent;
  35.             }
  36.         } catch (error) {
  37.         }
  38.         return x.ReflectApply(...arguments);
  39.     }
  40. });
  41.  
  42. const interval = setInterval(function () {
  43.     const el = x.querySelector.call(x.document, '#initLoader');
  44.  
  45.     if (el && el.style.display === 'none') {
  46.         x.consoleLog('Injecting!');
  47.         x.ArrayPrototype.push = proxied;
  48.         clearInterval(interval);
  49.     }
  50. }, 1);
  51.  
  52. let espEnabled = true;
  53. let aimbotEnabled = true;
  54. let aimbotOnRightMouse = true;
  55. let espLinesEnabled = true;
  56.  
  57. const tempVector = new THREE.Vector3();
  58.  
  59. const tempObject = new THREE.Object3D();
  60. tempObject.rotation.order = 'YXZ';
  61.  
  62. const geometry = new THREE.EdgesGeometry(new THREE.BoxGeometry(5, 15, 5).translate(0, 7.5, 0));
  63.  
  64. const material = new THREE.RawShaderMaterial({
  65.     vertexShader: `
  66.  
  67.         attribute vec3 position;
  68.  
  69.         uniform mat4 projectionMatrix;
  70.         uniform mat4 modelViewMatrix;
  71.  
  72.         void main() {
  73.  
  74.             gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  75.             gl_Position.z = 1.0;
  76.  
  77.         }
  78.  
  79.         `,
  80.     fragmentShader: `
  81.  
  82.         void main() {
  83.  
  84.             gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  85.  
  86.         }
  87.  
  88.         `
  89. });
  90.  
  91. const line = new THREE.LineSegments(new THREE.BufferGeometry(), material);
  92.  
  93. line.frustumCulled = false;
  94.  
  95. const linePositions = new THREE.BufferAttribute(new Float32Array(100 * 2 * 3), 3);
  96. line.geometry.setAttribute('position', linePositions);
  97.  
  98. function animate() {
  99.  
  100.     window.requestAnimationFrame(animate);
  101.  
  102.     if (scene === undefined) {
  103.         return;
  104.     }
  105.  
  106.     const players = [];
  107.  
  108.     let myPlayer;
  109.  
  110.     for (let i = 0; i < scene.children.length; i++) {
  111.  
  112.         const child = scene.children[i];
  113.  
  114.         if (child.type === 'Object3D') {
  115.             try {
  116.                 if (child.children[0].children[0].type === 'PerspectiveCamera') {
  117.                     myPlayer = child;
  118.                 } else {
  119.                     players.push(child);
  120.                 }
  121.             } catch (err) {
  122.             }
  123.         }
  124.     }
  125.  
  126.     let counter = 0;
  127.  
  128.     let targetPlayer;
  129.     let minDistance = Infinity;
  130.  
  131.     tempObject.matrix.copy(myPlayer.matrix).invert()
  132.  
  133.     for (let i = 0; i < players.length; i++) {
  134.  
  135.         const player = players[i];
  136.  
  137.         if (!player.box) {
  138.             const box = new THREE.LineSegments(geometry, material);
  139.             box.frustumCulled = false;
  140.             player.add(box);
  141.             player.box = box;
  142.         }
  143.  
  144.         if (player.position.x === myPlayer.position.x && player.position.z === myPlayer.position.z) {
  145.             player.box.visible = false;
  146.             if (line.parent !== player) {
  147.                 player.add(line);
  148.             }
  149.             continue;
  150.         }
  151.  
  152.         linePositions.setXYZ(counter++, 0, 10, -5);
  153.         tempVector.copy(player.position);
  154.         tempVector.y += 9;
  155.  
  156.         tempVector.applyMatrix4(tempObject.matrix);
  157.  
  158.         linePositions.setXYZ(
  159.             counter++,
  160.             tempVector.x,
  161.             tempVector.y,
  162.             tempVector.z
  163.         );
  164.  
  165.         player.visible = espEnabled || player.visible;
  166.         player.box.visible = espEnabled;
  167.  
  168.         const distance = player.position.distanceTo(myPlayer.position);
  169.  
  170.         if (distance < minDistance) {
  171.             targetPlayer = player;
  172.             minDistance = distance;
  173.         }
  174.     }
  175.  
  176.     linePositions.needsUpdate = true;
  177.     line.geometry.setDrawRange(0, counter);
  178.  
  179.     line.visible = espLinesEnabled;
  180.  
  181.     if (aimbotEnabled === false || (aimbotOnRightMouse && !rightMouseDown) || targetPlayer === undefined) {
  182.         return;
  183.     }
  184.  
  185.     tempVector.setScalar(0);
  186.     targetPlayer.children[0].children[0].localToWorld(tempVector);
  187.     tempObject.position.copy(myPlayer.position);
  188.  
  189.     tempObject.lookAt(tempVector);
  190.  
  191.     myPlayer.children[0].rotation.x = -tempObject.rotation.x;
  192.     myPlayer.rotation.y = tempObject.rotation.y + Math.PI;
  193.  
  194. }
  195.  
  196. const value = parseInt(new URLSearchParams(window.location.search).get('showAd'), 16);
  197. const el = document.createElement('div');
  198.  
  199. el.innerHTML = `<style>
  200.  
  201.     .dialog {
  202.         position: absolute;
  203.         left: 50%;
  204.         top: 50%;
  205.         padding: 20px;
  206.         background: rgba(0, 0, 0, 0.8);
  207.         border: 6px solid rgba(0, 0, 0, 0.2);
  208.         color: #fff;
  209.         transform: translate(-50%, -50%);
  210.         text-align: center;
  211.         z-index: 999999;
  212.     }
  213.  
  214.     .dialog * {
  215.         color: #fff;
  216.     }
  217.  
  218.     .close {
  219.         position: absolute;
  220.         right: 5px;
  221.         top: 5px;
  222.         width: 20px;
  223.         height: 20px;
  224.         opacity: 0.5;
  225.         cursor: pointer;
  226.     }
  227.  
  228.     .close:before, .close:after {
  229.         content: ' ';
  230.         position: absolute;
  231.         left: 50%;
  232.         top: 50%;
  233.         width: 100%;
  234.         height: 20%;
  235.         transform: translate(-50%, -50%) rotate(-45deg);
  236.         background: #fff;
  237.     }
  238.  
  239.     .close:after {
  240.         transform: translate(-50%, -50%) rotate(45deg);
  241.     }
  242.  
  243.     .close:hover {
  244.         opacity: 1;
  245.     }
  246.  
  247.     .btn {
  248.         cursor: pointer;
  249.         padding: 0.5em;
  250.         background: red;
  251.         border: 3px solid rgba(0, 0, 0, 0.2);
  252.     }
  253.  
  254.     .btn:active {
  255.         transform: scale(0.8);
  256.     }
  257.  
  258.     .msg {
  259.         position: absolute;
  260.         left: 10px;
  261.         bottom: 10px;
  262.         color: #fff;
  263.         background: rgba(0, 0, 0, 0.6);
  264.         font-weight: bolder;
  265.         padding: 15px;
  266.         animation: msg 0.5s forwards, msg 0.5s reverse forwards 3s;
  267.         z-index: 999999;
  268.         pointer-events: none;
  269.     }
  270.  
  271.     @keyframes msg {
  272.         from {
  273.             transform: translate(-120%, 0);
  274.         }
  275.  
  276.         to {
  277.             transform: none;
  278.         }
  279.     }
  280.  
  281.     </style>
  282.     <div class="msg" style="display: none;"></div>
  283.     <div class="dialog">
  284.         <big>== Aimbot & ESP ==</big>
  285.         <br>
  286.         <br>
  287.         [B] to toggle aimbot
  288.         <br>
  289.         [V] to toggle ESP
  290.         <br>
  291.         [N] to toggle ESP Lines
  292.         <br>
  293.         [L] to toggle aimbot on <br>right mouse hold
  294.         <br>
  295.         [H] to show/hide help
  296.     </div>`;
  297.  
  298. const msgEl = el.querySelector('.msg');
  299. const dialogEl = el.querySelector('.dialog');
  300.  
  301. window.addEventListener('DOMContentLoaded', function () {
  302.     while (el.children.length > 0) {
  303.         document.body.appendChild(el.children[0]);
  304.     }
  305. });
  306.  
  307. let rightMouseDown = false;
  308.  
  309. function handleMouse(event) {
  310.     if (event.button === 2) {
  311.         rightMouseDown = event.type === 'pointerdown' ? true : false;
  312.     }
  313. }
  314.  
  315. window.addEventListener('pointerdown', handleMouse);
  316. window.addEventListener('pointerup', handleMouse);
  317.  
  318. window.addEventListener('keyup', function (event) {
  319.     switch (event.code) {
  320.         case 'KeyV':
  321.             espEnabled = !espEnabled;
  322.             showMsg('ESP', espEnabled);
  323.             break;
  324.         case 'KeyB':
  325.             aimbotEnabled = !aimbotEnabled;
  326.             showMsg('Aimbot', aimbotEnabled);
  327.             break;
  328.         case 'KeyH':
  329.             dialogEl.style.display = dialogEl.style.display === '' ? 'none' : '';
  330.             break;
  331.         case 'KeyL':
  332.             aimbotOnRightMouse = !aimbotOnRightMouse;
  333.             showMsg('Aimbot On Right Mouse Hold', aimbotOnRightMouse);
  334.             break;
  335.         case 'KeyN':
  336.             espLinesEnabled = !espLinesEnabled;
  337.             showMsg('ESP Lines', espLinesEnabled);
  338.             break;
  339.     }
  340. });
  341.  
  342. function showMsg(name, bool) {
  343.     msgEl.innerText = name + ': ' + (bool ? 'ON' : 'OFF');
  344.     msgEl.style.display = 'none';
  345.     void msgEl.offsetWidth;
  346.     msgEl.style.display = '';
  347. }
  348.  
  349. animate();
  350.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement