Multibox script

multibox after 2023 patch

当前为 2023-09-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Multibox script
  3. // @namespace http://tampermonkey.net/
  4. // @version 2
  5. // @description multibox after 2023 patch
  6. // @author Mi300#4401
  7. // @match https://diep.io/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @license MIT
  10. // @grant GM_getValue
  11. // @grant GM_setValue
  12. // ==/UserScript==
  13.  
  14.  
  15. let WTF = setInterval (function() {
  16. if (!document.querySelector('d-base').shadowRoot.children[0].shadowRoot.getElementById('username-input')) {
  17. return;
  18. }
  19. clearInterval (WTF)
  20.  
  21. let canRespawn = false;
  22. let worldPosition = [0, 0];
  23. let overlay;
  24. let mouseOffset = [0, 0];
  25. let gui = true;
  26.  
  27.  
  28. let gamepadConnected = false;
  29. let gamepadAxes = [0, 0, 0, 0]
  30. let gamepadButtons = [
  31. ...Array(17)].map((x) => {
  32. return { pressed: false };
  33. });
  34.  
  35. const fetchGamepad = () => {
  36. return {
  37. axes: gamepadAxes,
  38. buttons: gamepadButtons,
  39. mapping: 'standard',
  40. }
  41. }
  42. navigator.getGamepads = new Proxy(navigator.getGamepads, {
  43. apply (target, thisArg, args) {
  44. if (gamepadConnected) return [fetchGamepad()];
  45. return Reflect.apply(target, thisArg, args);
  46. },
  47. });
  48.  
  49. const canvas = document.getElementById ('canvas');
  50.  
  51. function hook (target, callbackFunc) {
  52. CanvasRenderingContext2D.prototype[target] = new Proxy (CanvasRenderingContext2D.prototype[target], {
  53.  
  54. apply (method, thisArg, args) {
  55. callbackFunc (method, thisArg, args);
  56.  
  57. return Reflect.apply (method, thisArg, args)
  58. }
  59. });
  60. }
  61. let dgg = 'i';
  62.  
  63. function hookMinimapArrow () {
  64.  
  65. let drawInstructions = 0;
  66. let minimapArrowVertex = [];
  67. hook ('beginPath', (method, thisArg, args) => {
  68. drawInstructions = 1;
  69. minimapArrowVertex = [];
  70. });
  71. hook ('moveTo', (method, thisArg, args) => {
  72. drawInstructions = 2;
  73. minimapArrowVertex.push ( args );
  74. });
  75. hook ('lineTo', (method, thisArg, args) => {
  76. if (drawInstructions >= 2 && drawInstructions <= 5) {
  77. drawInstructions ++;
  78. minimapArrowVertex.push ( args );
  79.  
  80. } else {
  81. drawInstructions = 0;
  82. }
  83. });
  84. hook ('fill', (method, thisArg, args) => {
  85. if (thisArg.fillStyle != '#000000') {
  86. return;
  87. }
  88. if (drawInstructions === 4) {
  89. const pos = getAverage (minimapArrowVertex);
  90. worldPosition = getWorldPosition (pos);
  91. }
  92. });
  93. }
  94. let minimapPosition = [0, 0];
  95. let minimapDim = [0, 0];
  96.  
  97. function hookMinimap () {
  98. hook ('strokeRect', (method, thisArg, args) => {
  99. const transform = thisArg.getTransform ();
  100. minimapPosition = [transform.e, transform.f];
  101. minimapDim = [transform.a, transform.d];
  102. });
  103. }
  104.  
  105. function getWorldPosition (position) {
  106. const ret = [
  107. parseFloat((((position[0] - minimapPosition[0] - minimapDim[0] / 2) / minimapDim[0] * 100) * 460).toFixed (3)),
  108. parseFloat((((position[1] - minimapPosition[1] - minimapDim[1] / 2) / minimapDim[1] * 100) * 460).toFixed (3)),
  109. ]
  110. return ret;
  111. }
  112. const Mi = '';
  113.  
  114. function getAverage (points) {
  115. let ret = [0, 0];
  116. points.forEach (point => {
  117. ret[0] += point[0];
  118. ret[1] += point[1];
  119. });
  120. ret[0] /= points.length;
  121. ret[1] /= points.length;
  122.  
  123. return ret;
  124. }
  125. let dgh = 'M';
  126.  
  127.  
  128. const getDist = (t1, t2) => {
  129. const distX = t1[0] - t2[0];
  130. const distY = t1[1] - t2[1];
  131.  
  132. return [Math.hypot(distX, distY), distX, distY];
  133. };
  134.  
  135. function moveBot () {
  136. const dangerRadius = Boolean(parseInt(localStorage.followCursor)) ? 750 : 250
  137. gamepadButtons[7].pressed = Boolean(parseInt(localStorage.autoShoot))
  138.  
  139. if (Boolean(parseInt(localStorage.autoRespawn))) {
  140. if (canRespawn) {
  141. input.trySpawn (localStorage.name)
  142. }
  143. }
  144. if (input.should_prevent_unload()) {
  145. canRespawn = true;
  146. }
  147. let masterMouse = GM_getValue('multiboxMouse');
  148. let masterMove = GM_getValue ('multiboxWorld');
  149.  
  150. if (Boolean(parseInt(localStorage.followCursor))) {
  151. masterMove = masterMouse;
  152. }
  153.  
  154. const distanceMouse = getDist (masterMouse, worldPosition);
  155. const distanceMove = getDist (masterMove, worldPosition);
  156.  
  157. if (!masterMouse[0] || !masterMouse[1] || !masterMove[0] || !masterMove[1]) {
  158. return;
  159. }
  160.  
  161.  
  162.  
  163. if (Boolean(parseInt(localStorage.copyMovement))) {
  164. if (distanceMove[0] > dangerRadius) {
  165. gamepadAxes[0] = masterMove[0] + distanceMove[1] * 100;
  166. gamepadAxes[1] = masterMove[1] + distanceMove[2] * 100;
  167. } else {
  168. gamepadAxes[0] = -(masterMove[0] + distanceMove[1] * 100);
  169. gamepadAxes[1] = -(masterMove[1] + distanceMove[2] * 100);
  170. }
  171. } else {
  172. gamepadAxes[0] = worldPosition[0];
  173. gamepadAxes[1] = worldPosition[1];
  174. }
  175. if (Boolean(parseInt(localStorage.copyMouse))) {
  176. gamepadAxes[2] = masterMouse[0] + distanceMouse[1] * 100;
  177. gamepadAxes[3] = masterMouse[1] + distanceMouse[2] * 100;
  178. }
  179. gamepadConnected = true;
  180. }
  181.  
  182.  
  183.  
  184. function frame () {
  185. overlay.innerHTML = `
  186. <h1>MULTIBOX</h1>
  187. <br> <br>
  188. World position: <br> ${Math.round(worldPosition[0]) + ', ' + Math.round(worldPosition[1])}
  189. <br> <br>
  190. Master Tab: ${Boolean (document.hasFocus ())}
  191. <br> <br>
  192. [F] Multibox Enabled: ${Boolean (parseInt (localStorage.multiboxEnabled))}
  193. <br> <br>
  194. [G] Copy Movement: ${Boolean (parseInt (localStorage.copyMovement))}
  195. <br> <br>
  196. [J] Copy Mouse: ${Boolean (parseInt (localStorage.copyMouse))}
  197. <br> <br>
  198. [R] Follow Cursor: ${Boolean (parseInt (localStorage.followCursor))}
  199. <br> <br>
  200. [Q] Toggle Gui: true
  201. <br> <br>
  202. [Z] Auto Respawn: ${Boolean (parseInt (localStorage.autoRespawn))}
  203. <br> <br>
  204. [,] Always Shoot: ${Boolean (parseInt (localStorage.autoShoot))}
  205. <br> <br>
  206. `
  207.  
  208. if (Boolean (document.hasFocus ())) {
  209. gamepadConnected = false;
  210.  
  211. GM_setValue('multiboxWorld', worldPosition);
  212. GM_setValue('multiboxMouse', [
  213. worldPosition[0] + mouseOffset[0] * 4,
  214. worldPosition[1] + mouseOffset[1] * 4,
  215. ]);
  216.  
  217. } else if (localStorage.multiboxEnabled === '1') {
  218. moveBot ();
  219. } else {
  220. gamepadConnected = false;
  221. }
  222. window.requestAnimationFrame (frame);
  223. }
  224.  
  225.  
  226.  
  227. document.addEventListener ('keydown', e => {
  228. if (e.key === 'f') {
  229. localStorage.multiboxEnabled = Number (!Boolean (parseInt (localStorage.multiboxEnabled)))
  230. }
  231. if (e.key === 'g') {
  232. localStorage.copyMovement = Number (!Boolean (parseInt (localStorage.copyMovement)))
  233. }
  234. if (e.key === 'j') {
  235. localStorage.copyMouse = Number (!Boolean (parseInt (localStorage.copyMouse)))
  236. }
  237. if (e.key === 'r') {
  238. localStorage.followCursor = Number (!Boolean (parseInt (localStorage.followCursor)))
  239. }
  240. if (e.key === 'q') {
  241. gui = !gui;
  242. overlay.style.display = gui ? 'block' : 'none'
  243. }
  244. if (e.key === ',') {
  245. localStorage.autoShoot = Number (!Boolean (parseInt (localStorage.autoShoot)))
  246. }
  247. if (e.key === 'z') {
  248. localStorage.autoRespawn = Number (!Boolean (parseInt (localStorage.autoRespawn)))
  249. }
  250. })
  251.  
  252. document.addEventListener ('mousemove', e => {
  253. const aimRatioX = 1 - (e.x / canvas.width);
  254. const aimRatioY = 1 - (e.y / canvas.height);
  255.  
  256. if (Boolean (document.hasFocus ())) {
  257. localStorage.aimRatioX = aimRatioX;
  258. localStorage.aimRatioY = aimRatioY;
  259. }
  260.  
  261. mouseOffset = [
  262. e.x - canvas.width / 2,
  263. e.y - canvas.height / 2,
  264. ]
  265. });
  266. function terminate () {
  267. if (!localStorage.multiboxEnabled) {
  268. localStorage.multiboxEnabled = 0;
  269. }
  270. if (!localStorage.copyMovement) {
  271. localStorage.copyMovement = 1;
  272. }
  273. if (!localStorage.copyMouse) {
  274. localStorage.copyMouse = 1;
  275. }
  276. if (!localStorage.followCursor) {
  277. localStorage.followCursor = 0;
  278. }
  279. if (!localStorage.autoRespawn) {
  280. localStorage.autoRespawn = 0;
  281. }
  282. if (!localStorage.autoShoot) {
  283. localStorage.autoShoot = 0;
  284. }
  285.  
  286. overlay = document.createElement('div');
  287. overlay.style.position = 'fixed';
  288. overlay.style.top = '1px';
  289. overlay.style.left = '1px';
  290. overlay.style.fontFamily = 'Lucida Console, Courier, monospace';
  291. overlay.style.fontSize = '12px';
  292. overlay.style.color = '#ffffff';
  293. overlay.style.pointerEvents = 'none';
  294. overlay.style.userSelect = 'none';
  295. overlay.style.fontSize = '14px';
  296. overlay.style.backgroundColor = 'gray';
  297. overlay.style.height = '450px';
  298. overlay.style.width = '250px';
  299. overlay.style.borderRadius = '1px'
  300. overlay.style.borderStyle = 'solid'
  301. overlay.style.borderColor = '#404040'
  302. overlay.style.borderWidth = '5px'
  303. overlay.style.textAlign = 'center';
  304. document.body.appendChild(overlay);
  305.  
  306. frame ();
  307. hookMinimapArrow ();
  308. hookMinimap ();
  309.  
  310.  
  311.  
  312. }
  313. terminate ();
  314. },400);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址