Multibox script Working December 2023

multibox

当前为 2023-12-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Multibox script Working December 2023
  3. // @namespace http://tampermonkey.net/
  4. // @version 20231
  5. // @description multibox
  6. // @author Mi300#4401
  7. // @match https://diep.io/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @license dont copy thx
  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 moveKeys = new Array(4)
  27. let tabId = Math.round(Math.random()*10000)
  28. GM_setValue('multiboxEnabled', false)
  29.  
  30. setInterval(function(){
  31. document.title = 'diep.io tab #' + tabId
  32. window.localStorage.removeItem("rivet:token");
  33. }, 1000)
  34.  
  35. const canvas = document.getElementById ('canvas');
  36.  
  37. function hook(target, callback){
  38.  
  39. const check = () => {
  40. window.requestAnimationFrame(check)
  41. const func = CanvasRenderingContext2D.prototype[target]
  42.  
  43. if(func.toString().includes(target)){
  44.  
  45. CanvasRenderingContext2D.prototype[target] = new Proxy (func, {
  46. apply (method, thisArg, args) {
  47. callback(method, thisArg, args)
  48.  
  49. return Reflect.apply (method, thisArg, args)
  50. }
  51. });
  52. }
  53. }
  54. check()
  55. }
  56. let dgg = 'i';
  57.  
  58. function hookMinimapArrow () {
  59.  
  60. let drawInstructions = 0;
  61. let minimapArrowVertex = [];
  62. hook ('beginPath', (method, thisArg, args) => {
  63. //console.log('beginPath', args)
  64. drawInstructions = 1;
  65. minimapArrowVertex = [];
  66. });
  67. hook ('moveTo', (method, thisArg, args) => {
  68. //console.log('moveTo', args)
  69. drawInstructions = 2;
  70. minimapArrowVertex.push ( args );
  71. });
  72. hook ('lineTo', (method, thisArg, args) => {
  73. //console.log('lineTo', args)
  74. if (drawInstructions >= 2 && drawInstructions <= 5) {
  75. drawInstructions ++;
  76. minimapArrowVertex.push ( args );
  77.  
  78. } else {
  79. drawInstructions = 0;
  80. }
  81. });
  82. hook ('fill', (method, thisArg, args) => {
  83. //console.log('fill', args)
  84. if (thisArg.fillStyle != '#000000' || thisArg.globalAlpha < 1) {
  85. return;
  86. }
  87. if (drawInstructions === 4) {
  88. const pos = getAverage (minimapArrowVertex);
  89. //console.log(pos)
  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. if (input.should_prevent_unload()) {
  137. canRespawn = true;
  138. }
  139. let masterMouse = GM_getValue('multiboxMouse');
  140. let masterMove = GM_getValue ('multiboxWorld');
  141.  
  142. console.log(masterMove, worldPosition)
  143. const distanceMove = getDist (masterMove, worldPosition);
  144. if (!masterMouse[0] || !masterMouse[1] || !masterMove[0] || !masterMove[1]) {
  145. return;
  146. }
  147.  
  148.  
  149.  
  150. if (GM_getValue('copyMovement')) {
  151. //console.log(distanceMove[0])
  152. if (distanceMove[0] > 400) {
  153. angleMove(distanceMove[1], distanceMove[2])
  154. } else {
  155. copyMove(GM_getValue('keys'))
  156. }
  157. }
  158. if (GM_getValue('copyMouse')) {
  159. angleShoot(...masterMouse)
  160. }
  161. }
  162.  
  163.  
  164.  
  165. function angleMove(dX, dY){
  166. if (dX > 0) {
  167. input.key_up (65);
  168. input.key_down (68);
  169. } else if (dX < 0) {
  170. input.key_up (68);
  171. input.key_down (65);
  172. } else {
  173. input.key_up (68);
  174. input.key_up (65);
  175. }
  176.  
  177. if (dY > 0) {
  178. input.key_up (87);
  179. input.key_down (83);
  180. } else if (dY < 0) {
  181. input.key_up (83);
  182. input.key_down (87);
  183. } else {
  184. input.key_up (83);
  185. input.key_up (87);
  186. }
  187. }
  188. function angleShoot(stepX, stepY){
  189. const x = stepX * canvas.width * window.devicePixelRatio;
  190. const y = stepY * canvas.height * window.devicePixelRatio;
  191.  
  192. input.mouse(x, y)
  193. }
  194. function copyMove(keys){
  195. if(keys[0]){
  196. input.key_down(87)
  197. }
  198. else{
  199. input.key_up(87)
  200. }
  201. if(keys[1]){
  202. input.key_down(65)
  203. }
  204. else {
  205. input.key_up(65)
  206. }
  207. if(keys[2]){
  208. input.key_down(83)
  209. }
  210. else {
  211. input.key_up(83)
  212. }
  213. if(keys[3]){
  214. input.key_down(68)
  215. }
  216. else {
  217. input.key_up(68)
  218. }
  219. }
  220.  
  221.  
  222.  
  223. function frame () {
  224. overlay.innerHTML = `
  225. <h1>MULTIBOX</h1>
  226. <br> <br>
  227. World position: <br> ${Math.round(worldPosition[0]) || 0} ${Math.round(worldPosition[1]) || 0}
  228. <br> <br>
  229. Master Tab: #${GM_getValue('master') || 0}
  230. <br> <br>
  231. [F] Multibox Enabled: ${GM_getValue('multiboxEnabled') || false}
  232. <br> <br>
  233. [G] Copy Movement: ${GM_getValue('copyMovement') || false}
  234. <br> <br>
  235. [J] Copy Mouse: ${GM_getValue('copyMouse') || false}
  236. <br> <br>
  237. [Q] Toggle Gui: true
  238. <br> <br>
  239. [Z] Auto Respawn: ${GM_getValue('autoRespawn') || false}
  240. <br> <br>
  241. [,] Always Shoot: ${GM_getValue('autoShoot') || false}
  242. <br> <br>
  243. `
  244. if(GM_getValue('autoShoot')){
  245. input.key_down(1)
  246. }
  247. else{
  248. input.key_up(1)
  249. }
  250. if (GM_getValue('autoRespawn')) {
  251. input.execute('game_spawn ' + localStorage.name)
  252. }
  253. if (GM_getValue('master') == tabId){
  254. GM_setValue('multiboxWorld', worldPosition)
  255. GM_setValue('multiboxMouse', mouseOffset)
  256. GM_setValue('keys', moveKeys)
  257.  
  258. } else if (GM_getValue('multiboxEnabled')) {
  259. moveBot ();
  260. }
  261. window.requestAnimationFrame (frame);
  262. }
  263.  
  264.  
  265. document.addEventListener ('keydown', e => {
  266. if (e.key === 'f') {
  267. GM_setValue('multiboxEnabled', !GM_getValue('multiboxEnabled'))
  268. if(GM_getValue('multiboxEnabled')){
  269. GM_setValue('master', tabId)
  270. }
  271. }
  272. if (e.key === 'g') {
  273. GM_setValue('copyMovement', !GM_getValue('copyMovement'))
  274. }
  275. if (e.key === 'j') {
  276. GM_setValue('copyMouse', !GM_getValue('copyMouse'))
  277. }
  278. if (e.key === 'q') {
  279. gui = !gui;
  280. overlay.style.display = gui ? 'block' : 'none'
  281. }
  282. if (e.key === ',') {
  283. GM_setValue('autoShoot', !GM_getValue('autoShoot'))
  284. }
  285. if (e.key === 'z') {
  286. GM_setValue('autoRespawn', !GM_getValue('autoRespawn'))
  287. }
  288. if(e.key === 'p'){
  289. GM_setValue('master', tabId)
  290. }
  291.  
  292. if(e.key === 'w'){
  293. moveKeys[0] = true;
  294. }
  295. if(e.key === 'a') {
  296. moveKeys[1] = true;
  297. }
  298. if(e.key === 's') {
  299. moveKeys[2] = true;
  300. }
  301. if(e.key === 'd') {
  302. moveKeys[3] = true;
  303. }
  304. })
  305. document.addEventListener('keyup', e => {
  306. if(e.key === 'w'){
  307. moveKeys[0] = false;
  308. }
  309. if(e.key === 'a') {
  310. moveKeys[1] = false;
  311. }
  312. if(e.key === 's') {
  313. moveKeys[2] = false;
  314. }
  315. if(e.key === 'd') {
  316. moveKeys[3] = false;
  317. }
  318. });
  319.  
  320. document.addEventListener ('mousemove', e => {
  321. mouseOffset = [
  322. e.x / canvas.width,
  323. e.y / canvas.height,
  324. ]
  325. });
  326. function terminate () {
  327. overlay = document.createElement('div');
  328. overlay.style.position = 'fixed';
  329. overlay.style.top = '1px';
  330. overlay.style.left = '1px';
  331. overlay.style.fontFamily = 'Lucida Console, Courier, monospace';
  332. overlay.style.fontSize = '12px';
  333. overlay.style.color = '#ffffff';
  334. overlay.style.pointerEvents = 'none';
  335. overlay.style.userSelect = 'none';
  336. overlay.style.fontSize = '14px';
  337. overlay.style.backgroundColor = 'gray';
  338. overlay.style.height = '450px';
  339. overlay.style.width = '250px';
  340. overlay.style.borderRadius = '1px'
  341. overlay.style.borderStyle = 'solid'
  342. overlay.style.borderColor = '#404040'
  343. overlay.style.borderWidth = '5px'
  344. overlay.style.textAlign = 'center';
  345. document.body.appendChild(overlay);
  346.  
  347. frame ();
  348. hookMinimapArrow ();
  349. hookMinimap ();
  350.  
  351.  
  352.  
  353. }
  354. terminate ();
  355. },400);