Krunker.IO AimLock

Locks aim to the nearest player in krunker.io

2021/12/07のページです。最新版はこちら。

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  1. // ==UserScript==
  2. // @name Krunker.IO AimLock
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.0.4
  5. // @description Locks aim to the nearest player in krunker.io
  6. // @author Zertalious (Zert)
  7. // @match *://krunker.io/*
  8. // @icon https://www.google.com/s2/favicons?domain=krunker.io
  9. // @grant none
  10. // @run-at document-end
  11. // @require https://unpkg.com/three@latest/build/three.min.js
  12. // ==/UserScript==
  13.  
  14. const tempVector = new THREE.Vector3();
  15.  
  16. const tempObject = new THREE.Object3D();
  17.  
  18. tempObject.rotation.order = 'YXZ';
  19.  
  20. const geometry = new THREE.SphereGeometry( 10 );
  21.  
  22. const material = new THREE.MeshLambertMaterial( {
  23. color: 'red',
  24. wireframe: true
  25. } );
  26.  
  27. const meshes = [];
  28.  
  29. let isActive = true;
  30.  
  31. let scene;
  32.  
  33. WeakMap.prototype.set = new Proxy( WeakMap.prototype.set, {
  34. apply( target, thisArgs, args ) {
  35.  
  36. if ( args[ 0 ].type === 'Scene' && args[ 0 ].name === 'Main' ) {
  37.  
  38. scene = args[ 0 ];
  39.  
  40. }
  41.  
  42. return Reflect.apply( ...arguments );
  43.  
  44. }
  45. } );
  46.  
  47. function animate() {
  48.  
  49. window.requestAnimationFrame( animate );
  50.  
  51. if ( isActive === false || scene === undefined ) {
  52.  
  53. return;
  54.  
  55. }
  56.  
  57. const players = [];
  58.  
  59. let myPlayer;
  60.  
  61. for ( let i = 0; i < scene.children.length; i ++ ) {
  62.  
  63. const child = scene.children[ i ];
  64.  
  65. if ( child.type === 'Object3D' ) {
  66.  
  67. try {
  68.  
  69. if ( child.children[ 0 ].children[ 0 ].type === 'PerspectiveCamera' ) {
  70.  
  71. myPlayer = child;
  72.  
  73. } else {
  74.  
  75. players.push( child );
  76.  
  77. }
  78.  
  79. } catch ( err ) {}
  80.  
  81. }
  82.  
  83. }
  84.  
  85. if ( players.length < 2 ) {
  86.  
  87. return;
  88.  
  89. }
  90.  
  91. let targetPlayer;
  92. let minDistance = Infinity;
  93.  
  94. for ( let i = 0; i < players.length; i ++ ) {
  95.  
  96. const player = players[ i ];
  97.  
  98. if ( player.position.x === myPlayer.position.x && player.position.z === myPlayer.position.z ) {
  99.  
  100. continue;
  101.  
  102. }
  103.  
  104. if ( player.firstTime !== true ) {
  105.  
  106. const mesh = new THREE.Mesh( geometry, material );
  107.  
  108. meshes.push( mesh );
  109.  
  110. player.add( mesh );
  111.  
  112. player.firstTime = true;
  113.  
  114. }
  115.  
  116. const distance = player.position.distanceTo( myPlayer.position );
  117.  
  118. if ( distance < minDistance ) {
  119.  
  120. targetPlayer = player;
  121.  
  122. minDistance = distance;
  123.  
  124. }
  125.  
  126. }
  127.  
  128. if ( targetPlayer === undefined ) {
  129.  
  130. return;
  131.  
  132. }
  133.  
  134. tempVector.setScalar( 0 );
  135.  
  136. targetPlayer.children[ 0 ].children[ 0 ].localToWorld( tempVector );
  137.  
  138. tempObject.position.copy( myPlayer.position );
  139.  
  140. tempObject.lookAt( tempVector );
  141.  
  142. myPlayer.children[ 0 ].rotation.x = - tempObject.rotation.x;
  143. myPlayer.rotation.y = tempObject.rotation.y + Math.PI;
  144.  
  145. }
  146.  
  147. animate();
  148.  
  149. window.addEventListener( 'keydown', function ( event ) {
  150.  
  151. if ( String.fromCharCode( event.keyCode ) === 'G' ) {
  152.  
  153. isActive = ! isActive;
  154.  
  155. for ( let i = 0; i < meshes.length; i ++ ) {
  156.  
  157. meshes[ i ].visible = isActive;
  158.  
  159. }
  160.  
  161. }
  162.  
  163. } );
  164.  
  165. const el = document.createElement( 'div' );
  166.  
  167. el.innerHTML = `<style>
  168.  
  169. .dialog {
  170. position: absolute;
  171. left: 50%;
  172. top: 50%;
  173. padding: 20px;
  174. background: rgba(0, 0, 0, 0.8);
  175. border: 6px solid rgba(0, 0, 0, 0.2);
  176. color: #fff;
  177. transform: translate(-50%, -50%);
  178. text-align: center;
  179. z-index: 999999;
  180. }
  181.  
  182. .dialog * {
  183. color: #fff;
  184. }
  185.  
  186. .close {
  187. position: absolute;
  188. right: 5px;
  189. top: 5px;
  190. width: 20px;
  191. height: 20px;
  192. opacity: 0.5;
  193. cursor: pointer;
  194. }
  195.  
  196. .close:before, .close:after {
  197. content: ' ';
  198. position: absolute;
  199. left: 50%;
  200. top: 50%;
  201. width: 100%;
  202. height: 20%;
  203. transform: translate(-50%, -50%) rotate(-45deg);
  204. background: #fff;
  205. }
  206.  
  207. .close:after {
  208. transform: translate(-50%, -50%) rotate(45deg);
  209. }
  210.  
  211. .close:hover {
  212. opacity: 1;
  213. }
  214.  
  215. .btn {
  216. cursor: pointer;
  217. padding: 0.5em;
  218. background: red;
  219. border: 3px solid rgba(0, 0, 0, 0.2);
  220. margin-bottom: 5px;
  221. }
  222.  
  223. .btn:active {
  224. transform: scale(0.8);
  225. }
  226.  
  227. </style>
  228. <div class="dialog">
  229. <div class="close" onclick="this.parentNode.style.display='none';"></div>
  230. <big>== Aimlocker ==</big>
  231. <br>
  232. <br>
  233. [G] to toggle aimlock
  234. <br>
  235. <br>
  236. By Zertalious
  237. <br>
  238. <br>
  239. <div class="btn" onclick="window.open('https://discord.gg/K24Zxy88VM')">Discord</div>
  240. <div class="btn" onclick="window.open('https://greatest.deepsurf.us/en/users/662330-zertalious', '_blank')">More scripts</div>
  241. </div>`;
  242.  
  243. while ( el.children.length > 0 ) {
  244.  
  245. document.body.appendChild( el.children[ 0 ] );
  246.  
  247. }