Optimized Krunker.IO Aimbot & ESP

High-performance aimbot and ESP for Krunker this auto locks on and tracks through walls

  1. // ==UserScript==
  2. // @name Optimized Krunker.IO Aimbot & ESP
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4.1
  5. // @description High-performance aimbot and ESP for Krunker this auto locks on and tracks through walls
  6. // @author Original by Lokiion (Loki)
  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@0.150.0/build/three.min.js
  15. // ==/UserScript==
  16.  
  17. const THREE = window.THREE;
  18. delete window.THREE;
  19.  
  20. // Settings with default values
  21. const settings = {
  22. aimbotEnabled: true,
  23. aimbotOnRightMouse: false,
  24. espEnabled: true,
  25. espLines: true,
  26. wireframe: false
  27. };
  28.  
  29. // Key bindings
  30. const keyBindings = {
  31. KeyB: 'aimbotEnabled',
  32. KeyL: 'aimbotOnRightMouse',
  33. KeyM: 'espEnabled',
  34. KeyN: 'espLines',
  35. KeyK: 'wireframe'
  36. };
  37.  
  38. // Game state
  39. let scene = null;
  40. let rightMouseDown = false;
  41.  
  42. // Cached objects for performance
  43. const tempVector = new THREE.Vector3();
  44. const tempObject = new THREE.Object3D();
  45. tempObject.rotation.order = 'YXZ';
  46.  
  47. // ESP Materials and Geometry
  48. const espMaterial = new THREE.LineBasicMaterial({
  49. color: 0xff0000,
  50. depthTest: false
  51. });
  52.  
  53. const boxGeometry = new THREE.EdgesGeometry(
  54. new THREE.BoxGeometry(5, 15, 5).translate(0, 7.5, 0)
  55. );
  56.  
  57. // Line for ESP
  58. const lineGeometry = new THREE.BufferGeometry();
  59. const linePositions = new Float32Array(100 * 2 * 3);
  60. lineGeometry.setAttribute('position', new THREE.BufferAttribute(linePositions, 3));
  61.  
  62. const line = new THREE.LineSegments(lineGeometry, espMaterial);
  63. line.frustumCulled = false;
  64.  
  65. // Scene injection
  66. const origArrayPush = Array.prototype.push;
  67. Array.prototype.push = function() {
  68. try {
  69. if (arguments[0] && arguments[0].parent &&
  70. arguments[0].parent.type === 'Scene' &&
  71. arguments[0].parent.name === 'Main') {
  72. scene = arguments[0].parent;
  73. Array.prototype.push = origArrayPush;
  74. console.log('Scene injected!');
  75. }
  76. } catch(e) {}
  77. return origArrayPush.apply(this, arguments);
  78. };
  79.  
  80. // Game logic
  81. function findPlayers() {
  82. if (!scene) return { players: [], myPlayer: null };
  83.  
  84. const players = [];
  85. let myPlayer = null;
  86.  
  87. for (const child of scene.children) {
  88. if (child.type !== 'Object3D') continue;
  89.  
  90. try {
  91. const camera = child.children[0]?.children[0];
  92. if (camera && camera.type === 'PerspectiveCamera') {
  93. myPlayer = child;
  94. } else if (child.children[0]) {
  95. players.push(child);
  96. }
  97. } catch(e) {}
  98. }
  99.  
  100. return { players, myPlayer };
  101. }
  102.  
  103. function updateESP(players, myPlayer) {
  104. if (!myPlayer) return null;
  105.  
  106. let targetPlayer = null;
  107. let minDist = Infinity;
  108. let counter = 0;
  109.  
  110. tempObject.matrix.copy(myPlayer.matrix).invert();
  111.  
  112. for (const player of players) {
  113. // Skip if it's our own position
  114. if (player.position.x === myPlayer.position.x &&
  115. player.position.z === myPlayer.position.z) {
  116. continue;
  117. }
  118.  
  119. // Create ESP box if needed
  120. if (!player.box && settings.espEnabled) {
  121. const box = new THREE.LineSegments(boxGeometry, espMaterial);
  122. box.frustumCulled = false;
  123. player.add(box);
  124. player.box = box;
  125. }
  126.  
  127. // Update ESP visibility
  128. if (player.box) {
  129. player.box.visible = settings.espEnabled;
  130. }
  131.  
  132. // Update ESP lines
  133. if (settings.espLines && counter < linePositions.length / 6) {
  134. linePositions[counter * 6] = 0;
  135. linePositions[counter * 6 + 1] = 10;
  136. linePositions[counter * 6 + 2] = -5;
  137.  
  138. tempVector.copy(player.position)
  139. .add(new THREE.Vector3(0, 9, 0))
  140. .applyMatrix4(tempObject.matrix);
  141.  
  142. linePositions[counter * 6 + 3] = tempVector.x;
  143. linePositions[counter * 6 + 4] = tempVector.y;
  144. linePositions[counter * 6 + 5] = tempVector.z;
  145.  
  146. counter++;
  147. }
  148.  
  149. // Track closest player for aimbot
  150. const dist = player.position.distanceTo(myPlayer.position);
  151. if (dist < minDist) {
  152. minDist = dist;
  153. targetPlayer = player;
  154. }
  155. }
  156.  
  157. // Update line visibility
  158. line.geometry.attributes.position.needsUpdate = true;
  159. line.geometry.setDrawRange(0, counter * 2);
  160. line.visible = settings.espLines;
  161.  
  162. return targetPlayer;
  163. }
  164.  
  165. function aimbot(targetPlayer, myPlayer) {
  166. if (!settings.aimbotEnabled || !targetPlayer || !myPlayer ||
  167. (settings.aimbotOnRightMouse && !rightMouseDown)) {
  168. return;
  169. }
  170.  
  171. // Get target position
  172. tempVector.setScalar(0);
  173. targetPlayer.children[0].children[0].localToWorld(tempVector);
  174.  
  175. // Calculate aim
  176. tempObject.position.copy(myPlayer.position);
  177. tempObject.lookAt(tempVector);
  178.  
  179. // Apply aim
  180. myPlayer.children[0].rotation.x = -tempObject.rotation.x;
  181. myPlayer.rotation.y = tempObject.rotation.y + Math.PI;
  182. }
  183.  
  184. // Main game loop
  185. function gameLoop() {
  186. requestAnimationFrame(gameLoop);
  187.  
  188. const { players, myPlayer } = findPlayers();
  189. if (!players.length || !myPlayer) return;
  190.  
  191. const targetPlayer = updateESP(players, myPlayer);
  192. aimbot(targetPlayer, myPlayer);
  193. }
  194.  
  195. // Event handlers
  196. window.addEventListener('pointerdown', e => {
  197. if (e.button === 2) rightMouseDown = true;
  198. });
  199.  
  200. window.addEventListener('pointerup', e => {
  201. if (e.button === 2) rightMouseDown = false;
  202. });
  203.  
  204. window.addEventListener('keyup', e => {
  205. if (document.activeElement?.value !== undefined) return;
  206.  
  207. const setting = keyBindings[e.code];
  208. if (setting) {
  209. settings[setting] = !settings[setting];
  210. showMessage(`${setting}: ${settings[setting] ? 'ON' : 'OFF'}`);
  211. }
  212. });
  213.  
  214. // UI
  215. function showMessage(text) {
  216. let msgEl = document.querySelector('.hack-message');
  217. if (!msgEl) {
  218. msgEl = document.createElement('div');
  219. msgEl.className = 'hack-message';
  220. msgEl.style.cssText = `
  221. position: fixed;
  222. left: 20px;
  223. bottom: 20px;
  224. background: rgba(0, 0, 0, 0.7);
  225. color: #fff;
  226. padding: 10px 15px;
  227. font-family: monospace;
  228. font-size: 14px;
  229. border-radius: 4px;
  230. z-index: 999999;
  231. transition: opacity 0.3s;
  232. `;
  233. document.body.appendChild(msgEl);
  234. }
  235.  
  236. msgEl.textContent = text;
  237. msgEl.style.opacity = '1';
  238.  
  239. clearTimeout(msgEl.fadeTimeout);
  240. msgEl.fadeTimeout = setTimeout(() => {
  241. msgEl.style.opacity = '0';
  242. }, 2000);
  243. }
  244.  
  245. // Start the script
  246. console.log('Starting Krunker hack...');
  247. gameLoop();