Multibox script

multibox after 2023 patch

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

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