Shape Aimbot UPDATED

try to take over the world!

  1. // ==UserScript==
  2. // @name Shape Aimbot UPDATED
  3. // @namespace http://tampermonkey.net/
  4. // @version 2023
  5. // @description try to take over the world!
  6. // @author Mi300
  7. // @match https://diep.io/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @license dont copy thx
  10. // @grant none
  11. // ==/UserScript==
  12. setTimeout(function(){
  13. const canvas = document.getElementById ('canvas');
  14. const context = canvas.getContext ('2d');
  15. let mouse = [0, 0]
  16. let shapes = {};
  17. function clearShapes() {
  18. shapes = {
  19. squares: [],
  20. triangles: [],
  21. pentagons: [],
  22. }
  23. }
  24. clearShapes();
  25. let shapeData = {
  26. triangles: {
  27. sides: 3,
  28. colour: '',
  29. },
  30. squares: {
  31. sides: 4,
  32. colour: '',
  33. },
  34. pentagons: {
  35. sides: 5,
  36. colour: '',
  37. },
  38. }
  39. let debugOptions = {
  40. lines: true,
  41. shapeInfo: true,
  42. aim: false,
  43. }
  44. const names = {
  45. squares: 'Square',
  46. triangles: 'Triangle',
  47. pentagons: 'Pentagon',
  48. }
  49. function hook(target, callback){
  50. const check = () => {
  51. window.requestAnimationFrame(check)
  52. const func = CanvasRenderingContext2D.prototype[target]
  53.  
  54. if(func.toString().includes(target)){
  55.  
  56. CanvasRenderingContext2D.prototype[target] = new Proxy (func, {
  57. apply (method, thisArg, args) {
  58. callback(thisArg, args)
  59.  
  60. return Reflect.apply (method, thisArg, args)
  61. }
  62. });
  63. }
  64. }
  65. check()
  66. }
  67. document.addEventListener('keydown', function(e) {
  68. if (e.key === 't') {
  69. debugOptions.aim = !debugOptions.aim;
  70. }
  71. if (e.key === 'r') {
  72. debugOptions.lines = !debugOptions.lines;
  73. }
  74. if (e.key === 'q') {
  75. debugOptions.shapeInfo = !debugOptions.shapeInfo;
  76. }
  77. });
  78.  
  79.  
  80. function hookShapes(callback) {
  81. let calls = 0;
  82. let points = [];
  83.  
  84.  
  85. const onClose = (colour) => {
  86. callback(getCentre(points), colour, calls)
  87. }
  88. hook('beginPath', function(thisArg, args){
  89. calls = 1;
  90. points = [];
  91. });
  92. hook('moveTo', function(thisArg, args){
  93. if (calls == 1) {
  94. calls+=1;
  95. points.push(args)
  96. } else {
  97. calls = 0;
  98. }
  99. });
  100. hook('lineTo', function(thisArg, args){
  101. if (calls >= 2 && calls <= 6) {
  102. calls+=1;
  103. points.push(args)
  104. } else {
  105. calls = 0;
  106. }
  107. });
  108. hook('fill', function(thisArg, args){
  109. if(calls >= 4 && calls <= 6) {
  110. onClose(thisArg.fillStyle);
  111. } else {
  112. calls = 0;
  113. }
  114. });
  115. }
  116. function getCentre (vertices) {
  117. let centre = [0, 0];
  118. vertices.forEach (vertex => {
  119. centre [0] += vertex[0]
  120. centre [1] += vertex[1]
  121. });
  122. centre[0] /= vertices.length;
  123. centre[1] /= vertices.length;
  124. return centre;
  125. }
  126. document.addEventListener('mousemove', function() {
  127. if (!debugOptions.aim) {
  128. return;
  129. }
  130. input.mouse(...mouse)
  131. });
  132. hookShapes(function(a, c, ca){
  133. if (!['#ffe869', '#fc7677', '#768dfc'].includes(c)) {
  134. return;
  135. }
  136. if(ca == 4){
  137. shapes.triangles.push(a)
  138. }
  139. if(ca == 5){
  140. shapes.squares.push(a)
  141. }
  142. if(ca == 6){
  143. shapes.pentagons.push(a)
  144. }
  145. });
  146.  
  147. function getDist(t1, t2){
  148. const distX = t1[0] - t2[0];
  149. const distY = t1[1] - t2[1];
  150.  
  151. return [Math.hypot(distX, distY), distX, distY];
  152. };
  153. function getClosest (entities) {
  154. let acc = [0, 0]
  155. for (let i = 0; i < entities.length; i ++) {
  156. const accumulator = getDist (acc, [canvas.width / 2, canvas.height / 2])[0];
  157. const current = getDist (entities[i], [canvas.width / 2, canvas.height / 2])[0];
  158.  
  159. if (current < accumulator) acc = entities[i];
  160. }
  161. return acc;
  162. }
  163. function aim() {
  164. const target = getClosest
  165. (
  166. shapes.pentagons.length>0
  167. ?shapes.pentagons
  168. :shapes.triangles.length>0
  169. ?shapes.triangles
  170. :shapes.squares
  171. )
  172. if (!debugOptions.aim) {
  173. return;
  174. }
  175. mouse = target;
  176. input.mouse(...target)
  177. }
  178. function drawDebug() {
  179.  
  180. if (debugOptions.lines) {
  181. const everyshape = [].concat(
  182. shapes.squares,
  183. shapes.triangles,
  184. shapes.pentagons,
  185. )
  186. everyshape.forEach(function(shape){
  187. context.beginPath();
  188. context.lineWidth = 0.5;
  189. context.strokeStyle == 'black';
  190. context.moveTo(canvas.width / 2, canvas.height / 2);
  191. context.lineTo(...shape)
  192.  
  193. context.stroke()
  194. context.closePath()
  195. });
  196. }
  197. if (debugOptions.shapeInfo) {
  198. for (let key in shapes) {
  199. const type = shapeData[key];
  200.  
  201. context.strokeStyle = 'red';
  202. context.lineWidth = 2;
  203. shapes[key].forEach(function(shape){
  204. const size = 75;
  205. context.beginPath();
  206. context.strokeRect(shape[0] - size / 2, shape[1] - size / 2, size, size);
  207. context.closePath();
  208. });
  209. }
  210. for (let key in shapes) {
  211. const type = shapeData[key];
  212. shapes[key].forEach(function(shape){
  213. const size = 75;
  214. context.beginPath();
  215. context.lineWidth = 2;
  216. context.font = "30px serif";
  217. context.strokeStyle = '#000000';
  218. context.fillStyle = '#FFFFFF';
  219. context.strokeText(names[key], shape[0] - 25, shape[1] + size / 2.5)
  220. context.fillText(names[key], shape[0] - 25, shape[1] + size / 2.5)
  221. context.closePath();
  222. });
  223. }
  224. }
  225. }
  226.  
  227. function mainloop() {
  228. window.requestAnimationFrame(mainloop);
  229. drawDebug();
  230. aim();
  231. clearShapes();
  232. }
  233. mainloop();
  234. },2500);