Shape Aimbot UPDATED

try to take over the world!

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

  1. // ==UserScript==
  2. // @name Shape Aimbot UPDATED
  3. // @namespace http://tampermonkey.net/
  4. // @version 10
  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. const
  18. p = CanvasRenderingContext2D.prototype,
  19. _fill = p.fill,
  20. _moveTo = p.moveTo,
  21. _lineTo = p.lineTo,
  22. _beginPath = p.beginPath,
  23. _toString = Function.prototype.toString;
  24.  
  25. let fill,
  26. moveTo,
  27. lineTo,
  28. beginPath;
  29.  
  30.  
  31. function clearShapes() {
  32. shapes = {
  33. squares: [],
  34. triangles: [],
  35. pentagons: [],
  36. }
  37. }
  38. clearShapes();
  39. let shapeData = {
  40. triangles: {
  41. sides: 3,
  42. colour: '',
  43. },
  44. squares: {
  45. sides: 4,
  46. colour: '',
  47. },
  48. pentagons: {
  49. sides: 5,
  50. colour: '',
  51. },
  52. }
  53. let debugOptions = {
  54. lines: true,
  55. shapeInfo: true,
  56. aim: false,
  57. }
  58. const names = {
  59. squares: 'square',
  60. triangles: 'triangle',
  61. pentagons: 'pentagon',
  62. }
  63. document.addEventListener('keydown', function(e) {
  64. if (e.key === 't') {
  65. debugOptions.aim = !debugOptions.aim;
  66. }
  67. if (e.key === 'r') {
  68. debugOptions.lines = !debugOptions.lines;
  69. }
  70. if (e.key === 'q') {
  71. debugOptions.shapeInfo = !debugOptions.shapeInfo;
  72. }
  73. });
  74.  
  75.  
  76. let calls = 0;
  77. let points = [];
  78. const onClose = (c) => {
  79. if(['#999999', '#000000', '#00b2e1', '#fcc376'].includes(c)) {
  80. return;
  81. }
  82. if(calls == 4){
  83. shapes.triangles.push(getCentre(points))
  84. }
  85. if(calls == 5){
  86. shapes.squares.push(getCentre(points))
  87. }
  88. if(calls == 6){
  89. shapes.pentagons.push(getCentre(points))
  90. }
  91. }
  92. beginPath = function(...args) {
  93. calls = 1;
  94. points = [];
  95. _beginPath.call(this, ...args);
  96. }
  97. moveTo = function(...args) {
  98. calls = 2;
  99. points.push (args);
  100. _moveTo.call(this, ...args)
  101. }
  102. lineTo = function(...args) {
  103. if (calls >= 2 && calls <= 5) {
  104. calls ++;
  105. points.push (args);
  106. } else {
  107. calls = 0;
  108. }
  109. _lineTo.call(this, ...args)
  110. }
  111. fill = function(...args) {
  112. onClose(this.fillStyle);
  113. _fill.call(this, ...args)
  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.  
  133. function getDist(t1, t2){
  134. const distX = t1[0] - t2[0];
  135. const distY = t1[1] - t2[1];
  136.  
  137. return [Math.hypot(distX, distY), distX, distY];
  138. };
  139. function getClosest (entities) {
  140. let acc = [0, 0]
  141. for (let i = 0; i < entities.length; i ++) {
  142. const accumulator = getDist (acc, [canvas.width / 2, canvas.height / 2])[0];
  143. const current = getDist (entities[i], [canvas.width / 2, canvas.height / 2])[0];
  144.  
  145. if (current < accumulator) acc = entities[i];
  146. }
  147. return acc;
  148. }
  149. function aim() {
  150. const target = getClosest
  151. (
  152. shapes.pentagons.length>0
  153. ?shapes.pentagons
  154. :shapes.triangles.length>0
  155. ?shapes.triangles
  156. :shapes.squares
  157. )
  158. if (!debugOptions.aim) {
  159. return;
  160. }
  161. mouse = target;
  162. input.mouse(...target)
  163. }
  164. function drawDebug() {
  165.  
  166. if (debugOptions.lines) {
  167. const everyshape = [].concat(
  168. shapes.squares,
  169. shapes.triangles,
  170. shapes.pentagons,
  171. )
  172. everyshape.forEach(function(shape){
  173. context.beginPath();
  174. context.lineWidth = 0.5;
  175. context.strokeStyle == 'black';
  176. context.moveTo(canvas.width / 2, canvas.height / 2);
  177. context.lineTo(...shape)
  178.  
  179. context.stroke()
  180. context.closePath()
  181. });
  182. }
  183. if (debugOptions.shapeInfo) {
  184. for (let key in shapes) {
  185. const type = shapeData[key];
  186.  
  187. context.strokeStyle = 'red';
  188. context.lineWidth = 2;
  189. shapes[key].forEach(function(shape){
  190. const size = 75;
  191. context.beginPath();
  192. context.strokeRect(shape[0] - size / 2, shape[1] - size / 2, size, size);
  193. context.closePath();
  194. });
  195. }
  196. for (let key in shapes) {
  197. const type = shapeData[key];
  198. shapes[key].forEach(function(shape){
  199. const size = 75;
  200. context.beginPath();
  201. context.lineWidth = 2;
  202. context.font = "bold 23px serif";
  203. context.strokeStyle = '#000000';
  204. context.fillStyle = 'red';
  205. context.strokeText(names[key], shape[0] - 25, shape[1] + size / 2.5)
  206. context.fillText(names[key], shape[0] - 25, shape[1] + size / 2.5)
  207. context.closePath();
  208. });
  209. }
  210. }
  211. }
  212.  
  213. function mainloop() {
  214. window.requestAnimationFrame(mainloop);
  215. drawDebug();
  216. aim();
  217. clearShapes();
  218. }
  219. mainloop();
  220.  
  221.  
  222.  
  223. const toString = function() {
  224. switch(this) {
  225. case fill: return _toString.call(_fill);
  226. case moveTo: return _toString.call(_moveTo);
  227. case beginPath: return _toString.call(_beginPath);
  228. case lineTo: return _toString.call(_lineTo);
  229. case toString: return _toString.call(_toString);
  230. }
  231. return _toString.call(this);
  232. };
  233. p.fill = fill;
  234. p.beginPath = beginPath;
  235. p.moveTo = moveTo;
  236. p.lineTo = lineTo;
  237. Function.prototype.toString = toString;
  238. },2500);