Krunker.IO Aimbot & ESP

Locks aim to the nearest player in krunker.io and shows players behind walls. Also shows a line between you and them.

当前为 2024-03-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Krunker.IO Aimbot & ESP
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2.9
  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 Zertalious (Zert)
  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. // @antifeature ads
  16. // ==/UserScript==
  17.  
  18. const THREE = window.THREE;
  19. delete window.THREE;
  20.  
  21. const settings = {
  22. aimbotEnabled: true,
  23. aimbotOnRightMouse: false,
  24. espEnabled: true,
  25. espLines: true,
  26. wireframe: false
  27. };
  28.  
  29. const keyToSetting = {
  30. KeyB: 'aimbotEnabled',
  31. KeyL: 'aimbotOnRightMouse',
  32. KeyM: 'espEnabled',
  33. KeyN: 'espLines',
  34. KeyK: 'wireframe'
  35. };
  36.  
  37. const gui = createGUI();
  38.  
  39. let scene;
  40.  
  41. const x = {
  42. window: window,
  43. document: document,
  44. querySelector: document.querySelector,
  45. consoleLog: console.log,
  46. ReflectApply: Reflect.apply,
  47. ArrayPrototype: Array.prototype,
  48. ArrayPush: Array.prototype.push,
  49. ObjectPrototype: Object.prototype,
  50. clearInterval: window.clearInterval,
  51. setTimeout: window.setTimeout,
  52. reToString: RegExp.prototype.toString,
  53. indexOf: String.prototype.indexOf,
  54. requestAnimationFrame: window.requestAnimationFrame
  55. };
  56.  
  57. x.consoleLog( 'Waiting to inject...' );
  58.  
  59. const proxied = function ( object ) {
  60.  
  61. // [native code]
  62.  
  63. try {
  64.  
  65. if ( typeof object === 'object' &&
  66. typeof object.parent === 'object' &&
  67. object.parent.type === 'Scene' &&
  68. object.parent.name === 'Main' ) {
  69.  
  70. x.consoleLog( 'Found Scene!' )
  71. scene = object.parent;
  72. x.ArrayPrototype.push = x.ArrayPush;
  73.  
  74. }
  75.  
  76. } catch ( error ) {}
  77.  
  78. return x.ArrayPush.apply( this, arguments );
  79.  
  80. }
  81.  
  82. const tempVector = new THREE.Vector3();
  83.  
  84. const tempObject = new THREE.Object3D();
  85. tempObject.rotation.order = 'YXZ';
  86.  
  87. const geometry = new THREE.EdgesGeometry( new THREE.BoxGeometry( 5, 15, 5 ).translate( 0, 7.5, 0 ) );
  88.  
  89. const material = new THREE.RawShaderMaterial( {
  90. vertexShader: `
  91.  
  92. attribute vec3 position;
  93.  
  94. uniform mat4 projectionMatrix;
  95. uniform mat4 modelViewMatrix;
  96.  
  97. void main() {
  98.  
  99. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  100. gl_Position.z = 1.0;
  101.  
  102. }
  103.  
  104. `,
  105. fragmentShader: `
  106.  
  107. void main() {
  108.  
  109. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  110.  
  111. }
  112.  
  113. `
  114. } );
  115.  
  116. const line = new THREE.LineSegments( new THREE.BufferGeometry(), material );
  117.  
  118. line.frustumCulled = false;
  119.  
  120. const linePositions = new THREE.BufferAttribute( new Float32Array( 100 * 2 * 3 ), 3 );
  121. line.geometry.setAttribute( 'position', linePositions );
  122.  
  123. let injectTimer = null;
  124.  
  125. function animate() {
  126.  
  127. x.requestAnimationFrame.call( x.window, animate );
  128.  
  129. if ( ! scene && ! injectTimer ) {
  130.  
  131. const el = x.querySelector.call( x.document, '#loadingBg' );
  132.  
  133. if ( el && el.style.display === 'none' ) {
  134.  
  135. x.consoleLog( 'Inject timer started!' );
  136.  
  137. injectTimer = x.setTimeout.call( x.window, () => {
  138.  
  139. x.consoleLog( 'Injected!' );
  140. x.ArrayPrototype.push = proxied;
  141.  
  142. }, 2e3 );
  143.  
  144. }
  145.  
  146. }
  147.  
  148. if ( typeof shouldShowAd === 'undefined' || shouldShowAd === true || scene === undefined || ! scene.children ) {
  149.  
  150. return;
  151.  
  152. }
  153.  
  154. const players = [];
  155.  
  156. let myPlayer;
  157.  
  158. for ( let i = 0; i < scene.children.length; i ++ ) {
  159.  
  160. const child = scene.children[ i ];
  161.  
  162. if ( child.type === 'Object3D' ) {
  163.  
  164. try {
  165.  
  166. if ( child.children[ 0 ].children[ 0 ].type === 'PerspectiveCamera' ) {
  167.  
  168. myPlayer = child;
  169.  
  170. } else {
  171.  
  172. players.push( child );
  173.  
  174. }
  175.  
  176. } catch ( err ) {}
  177.  
  178. } else if ( child.material ) {
  179.  
  180. child.material.wireframe = settings.wireframe;
  181.  
  182. }
  183.  
  184. }
  185.  
  186. if ( ! myPlayer ) {
  187.  
  188. x.consoleLog( 'Player not found, finding new scene.' );
  189. x.ArrayPrototype.push = proxied;
  190. return;
  191.  
  192. }
  193.  
  194. let counter = 0;
  195.  
  196. let targetPlayer;
  197. let minDistance = Infinity;
  198.  
  199. tempObject.matrix.copy( myPlayer.matrix ).invert()
  200.  
  201. for ( let i = 0; i < players.length; i ++ ) {
  202.  
  203. const player = players[ i ];
  204.  
  205. if ( ! player.box ) {
  206.  
  207. const box = new THREE.LineSegments( geometry, material );
  208. box.frustumCulled = false;
  209.  
  210. player.add( box );
  211.  
  212. player.box = box;
  213.  
  214. }
  215.  
  216. if ( player.position.x === myPlayer.position.x && player.position.z === myPlayer.position.z ) {
  217.  
  218. player.box.visible = false;
  219.  
  220. if ( line.parent !== player ) {
  221.  
  222. player.add( line );
  223.  
  224. }
  225.  
  226. continue;
  227.  
  228. }
  229.  
  230. linePositions.setXYZ( counter ++, 0, 10, - 5 );
  231.  
  232. tempVector.copy( player.position );
  233.  
  234. tempVector.y += 9;
  235.  
  236. tempVector.applyMatrix4( tempObject.matrix );
  237.  
  238. linePositions.setXYZ(
  239. counter ++,
  240. tempVector.x,
  241. tempVector.y,
  242. tempVector.z
  243. );
  244.  
  245. player.visible = settings.espEnabled || player.visible;
  246. player.box.visible = settings.espEnabled;
  247.  
  248. const distance = player.position.distanceTo( myPlayer.position );
  249.  
  250. if ( distance < minDistance ) {
  251.  
  252. targetPlayer = player;
  253.  
  254. minDistance = distance;
  255.  
  256. }
  257.  
  258. }
  259.  
  260. linePositions.needsUpdate = true;
  261. line.geometry.setDrawRange( 0, counter );
  262.  
  263. line.visible = settings.espLines;
  264.  
  265. if ( settings.aimbotEnabled === false || ( settings.aimbotOnRightMouse && ! rightMouseDown ) || targetPlayer === undefined ) {
  266.  
  267. return;
  268.  
  269. }
  270.  
  271. tempVector.setScalar( 0 );
  272.  
  273. targetPlayer.children[ 0 ].children[ 0 ].localToWorld( tempVector );
  274.  
  275. tempObject.position.copy( myPlayer.position );
  276.  
  277. tempObject.lookAt( tempVector );
  278.  
  279. myPlayer.children[ 0 ].rotation.x = - tempObject.rotation.x;
  280. myPlayer.rotation.y = tempObject.rotation.y + Math.PI;
  281.  
  282. }
  283.  
  284. const value = parseInt( new URLSearchParams( window.location.search ).get( 'showAd' ), 16 );
  285. const shouldShowAd = isNaN( value ) || Date.now() - value < 0 || Date.now() - value > 10 * 60 * 1000;
  286.  
  287. function removeQueries() {
  288.  
  289. const withoutQuery = window.location.href.split( '?' )[ 0 ];
  290. const params = new URLSearchParams( window.location.search );
  291. params.delete( 'showAd' );
  292. params.delete( 'scriptVersion' );
  293.  
  294. const newUrl = withoutQuery + '?' + params.toString();
  295.  
  296. window.history.pushState( null, '', newUrl );
  297.  
  298. }
  299. removeQueries();
  300.  
  301. const el = document.createElement( 'div' );
  302.  
  303. el.innerHTML = `<style>
  304.  
  305. .dialog {
  306. position: absolute;
  307. left: 50%;
  308. top: 50%;
  309. padding: 20px;
  310. background: rgba(0, 0, 0, 0.8);
  311. border: 6px solid rgba(0, 0, 0, 0.2);
  312. color: #fff;
  313. transform: translate(-50%, -50%);
  314. text-align: center;
  315. z-index: 999999;
  316. }
  317.  
  318. .dialog * {
  319. color: #fff;
  320. }
  321.  
  322. .close {
  323. position: absolute;
  324. right: 5px;
  325. top: 5px;
  326. width: 20px;
  327. height: 20px;
  328. opacity: 0.5;
  329. cursor: pointer;
  330. }
  331.  
  332. .close:before, .close:after {
  333. content: ' ';
  334. position: absolute;
  335. left: 50%;
  336. top: 50%;
  337. width: 100%;
  338. height: 20%;
  339. transform: translate(-50%, -50%) rotate(-45deg);
  340. background: #fff;
  341. }
  342.  
  343. .close:after {
  344. transform: translate(-50%, -50%) rotate(45deg);
  345. }
  346.  
  347. .close:hover {
  348. opacity: 1;
  349. }
  350.  
  351. .btn {
  352. cursor: pointer;
  353. padding: 0.5em;
  354. background: red;
  355. border: 3px solid rgba(0, 0, 0, 0.2);
  356. }
  357.  
  358. .btn:active {
  359. transform: scale(0.8);
  360. }
  361.  
  362. .msg {
  363. position: absolute;
  364. left: 10px;
  365. bottom: 10px;
  366. color: #fff;
  367. background: rgba(0, 0, 0, 0.6);
  368. font-weight: bolder;
  369. padding: 15px;
  370. animation: msg 0.5s forwards, msg 0.5s reverse forwards 3s;
  371. z-index: 999999;
  372. pointer-events: none;
  373. }
  374.  
  375. @keyframes msg {
  376. from {
  377. transform: translate(-120%, 0);
  378. }
  379.  
  380. to {
  381. transform: none;
  382. }
  383. }
  384.  
  385. .zui {
  386. position: fixed;
  387. right: 10px;
  388. top: 0;
  389. z-index: 999;
  390. display: flex;
  391. flex-direction: column;
  392. font-family: monospace;
  393. font-size: 14px;
  394. color: #fff;
  395. width: 250px;
  396. user-select: none;
  397. border: 2px solid #000;
  398. }
  399.  
  400. .zui-item {
  401. padding: 5px 8px;
  402. display: flex;
  403. justify-content: space-between;
  404. align-items: center;
  405. background: #222;
  406. cursor: pointer;
  407. }
  408.  
  409. .zui-item:hover {
  410. background: #333;
  411. }
  412.  
  413. .zui-item span {
  414. color: #fff;
  415. font-family: monospace;
  416. font-size: 14px;
  417. }
  418.  
  419. .zui-header {
  420. background: #000;
  421. }
  422.  
  423. .zui-header span {
  424. font-size: 16px;
  425. }
  426.  
  427. .zui-header:hover {
  428. background: #000;
  429. }
  430.  
  431. .zui-on {
  432. color: green;
  433. }
  434.  
  435. .zui-item-value {
  436. font-size: 0.8em;
  437. }
  438.  
  439. .zui-content .zui-item-value {
  440. font-weight: bolder;
  441. }
  442.  
  443. </style>
  444. <div class="msg" style="display: none;"></div>
  445. <div class="dialog">${shouldShowAd ? `<big>Loading ad...</big>` : `<div class="close" onclick="this.parentNode.style.display='none';"></div>
  446. <big>== Aimbot & ESP ==</big>
  447. <br>
  448. <br>
  449. [B] to toggle aimbot
  450. <br>
  451. [V] to toggle ESP
  452. <br>
  453. [N] to toggle ESP Lines
  454. <br>
  455. [L] to toggle aimbot on <br>right mouse hold
  456. <br>
  457. [H] to show/hide help
  458. <br>
  459. <br>
  460. By Zertalious
  461. <br>
  462. <br>
  463. <div style="display: grid; grid-template-columns: 1fr 1fr; grid-gap: 5px;">
  464. <div class="btn" onclick="window.open('https://discord.gg/K24Zxy88VM', '_blank')">Discord</div>
  465. <div class="btn" onclick="window.open('https://www.instagram.com/zertalious/', '_blank')">Instagram</div>
  466. <div class="btn" onclick="window.open('https://twitter.com/Zertalious', '_blank')">Twitter</div>
  467. <div class="btn" onclick="window.open('https://greasyfork.org/en/users/662330-zertalious', '_blank')">More scripts</div>
  468. </div>
  469. ` }
  470. </div>`;
  471.  
  472. const msgEl = el.querySelector( '.msg' );
  473. const dialogEl = el.querySelector( '.dialog' );
  474.  
  475. window.addEventListener( 'DOMContentLoaded', function () {
  476.  
  477. while ( el.children.length > 0 ) {
  478.  
  479. document.body.appendChild( el.children[ 0 ] );
  480.  
  481. }
  482.  
  483. document.body.appendChild( gui );
  484.  
  485. } );
  486.  
  487. if ( shouldShowAd ) {
  488.  
  489. const url = new URL( window.location.href );
  490.  
  491. url.searchParams.set( 'showAd', Date.now().toString( 16 ) );
  492. url.searchParams.set( 'scriptVersion', GM.info.script.version );
  493.  
  494. window.location.href = 'https://zertalious.xyz?ref=' + new TextEncoder().encode( url.href ).toString();
  495.  
  496. }
  497.  
  498. let rightMouseDown = false;
  499.  
  500. function handleMouse( event ) {
  501.  
  502. if ( event.button === 2 ) {
  503.  
  504. rightMouseDown = event.type === 'pointerdown' ? true : false;
  505.  
  506. }
  507.  
  508. }
  509.  
  510. window.addEventListener( 'pointerdown', handleMouse );
  511. window.addEventListener( 'pointerup', handleMouse );
  512.  
  513. window.addEventListener( 'keyup', function ( event ) {
  514.  
  515. if ( x.document.activeElement && x.document.activeElement.value !== undefined ) return;
  516.  
  517. if ( keyToSetting[ event.code ] ) {
  518.  
  519. toggleSetting( keyToSetting[ event.code ] );
  520.  
  521. }
  522.  
  523. switch ( event.code ) {
  524.  
  525. case 'Slash' :
  526. toggleElementVisibility( gui );
  527. break;
  528.  
  529. case 'KeyH' :
  530. toggleElementVisibility( dialogEl );
  531. break;
  532.  
  533. }
  534.  
  535. } );
  536.  
  537. function toggleElementVisibility( el ) {
  538.  
  539. el.style.display = el.style.display === '' ? 'none' : '';
  540.  
  541. }
  542.  
  543. function showMsg( name, bool ) {
  544.  
  545. msgEl.innerText = name + ': ' + ( bool ? 'ON' : 'OFF' );
  546.  
  547. msgEl.style.display = 'none';
  548. void msgEl.offsetWidth;
  549. msgEl.style.display = '';
  550.  
  551. }
  552.  
  553. animate();
  554.  
  555. function createGUI() {
  556.  
  557. const guiEl = fromHtml( `<div class="zui">
  558. <div class="zui-item zui-header">
  559. <span>[/] Controls</span>
  560. <span class="zui-item-value">[close]</span>
  561. </div>
  562. <div class="zui-content"></div>
  563. </div>` );
  564.  
  565. const headerEl = guiEl.querySelector( '.zui-header' );
  566. const contentEl = guiEl.querySelector( '.zui-content' );
  567. const headerStatusEl = guiEl.querySelector( '.zui-item-value' );
  568.  
  569. headerEl.onclick = function () {
  570.  
  571. const isHidden = contentEl.style.display === 'none';
  572.  
  573. contentEl.style.display = isHidden ? '' : 'none';
  574. headerStatusEl.innerText = isHidden ? '[close]' : '[open]';
  575.  
  576. }
  577.  
  578. const settingToKey = {};
  579. for ( const key in keyToSetting ) {
  580.  
  581. settingToKey[ keyToSetting[ key ] ] = key;
  582.  
  583. }
  584.  
  585. for ( const prop in settings ) {
  586.  
  587. let name = fromCamel( prop );
  588. let shortKey = settingToKey[ prop ];
  589.  
  590. if ( shortKey ) {
  591.  
  592. if ( shortKey.startsWith( 'Key' ) ) shortKey = shortKey.slice( 3 );
  593. name = `[${shortKey}] ${name}`;
  594.  
  595. }
  596.  
  597. const itemEl = fromHtml( `<div class="zui-item">
  598. <span>${name}</span>
  599. <span class="zui-item-value"></span>
  600. </div>` );
  601. const valueEl = itemEl.querySelector( '.zui-item-value' );
  602.  
  603. function updateValueEl() {
  604.  
  605. const value = settings[ prop ];
  606. valueEl.innerText = value ? 'ON' : 'OFF';
  607. valueEl.style.color = value ? 'green' : 'red';
  608.  
  609. }
  610. itemEl.onclick = function() {
  611.  
  612. settings[ prop ] = ! settings[ prop ];
  613.  
  614. }
  615. updateValueEl();
  616.  
  617. contentEl.appendChild( itemEl );
  618.  
  619. const p = `__${prop}`;
  620. settings[ p ] = settings[ prop ];
  621. Object.defineProperty( settings, prop, {
  622. get() {
  623.  
  624. return this[ p ];
  625.  
  626. },
  627. set( value ) {
  628.  
  629. this[ p ] = value;
  630. updateValueEl();
  631.  
  632. }
  633. } );
  634.  
  635. }
  636.  
  637. return guiEl;
  638.  
  639. }
  640.  
  641. function fromCamel( text ) {
  642.  
  643. const result = text.replace( /([A-Z])/g, ' $1' );
  644. return result.charAt( 0 ).toUpperCase() + result.slice( 1 );
  645.  
  646. }
  647.  
  648. function fromHtml( html ) {
  649.  
  650. const div = document.createElement( 'div' );
  651. div.innerHTML = html;
  652. return div.children[ 0 ];
  653.  
  654. }
  655.  
  656. function toggleSetting( key ) {
  657.  
  658. settings[ key ] = ! settings[ key ];
  659. showMsg( fromCamel( key ), settings[ key ] );
  660.  
  661. }