_N0N4M3's Diep.io Mod

Dark theme, FPS & Ping display, ESP, Aim helper, Factory helper

  1. // ==UserScript==
  2. // @name _N0N4M3's Diep.io Mod
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-11-06
  5. // @description Dark theme, FPS & Ping display, ESP, Aim helper, Factory helper
  6. // @author _N0N4M3
  7. // @match https://diep.io/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=diep.io
  9. // @run-at document-start
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. let darkThemeEnabled = 0;
  14. let info = 0;
  15. let currentElem = {};
  16. let fill = CanvasRenderingContext2D.prototype.fill;
  17. let X = 200;
  18. let Y = X * (innerHeight / innerWidth);
  19. let aimLine = 0;
  20. let esp = 0;
  21. let factoryHelper = 0;
  22. let D = Math.hypot(innerWidth / 2, innerHeight / 2);
  23. let cursorX = 0;
  24. let cursorY = 0;
  25. let closestCircleX = innerWidth / 2;
  26. let closestCircleY = innerHeight / 2;
  27. function darkTheme() {
  28. input.execute("ren_background false");
  29. input.execute("net_replace_colors 0x1c1c1c 0x333333 0x003b4b 0x003b4b 0x501a1c 0x3f2a51 0x004b24 0x2e5523 0x554d23 0x542727 0x272f54 0x502749 0x554d23 0x165530 0x3e3e3e 0x501a1c 0x544127 0x404040");
  30. input.execute("ren_minimap_background_color 0x444444");
  31. input.execute("ren_minimap_border_color 0x444444");
  32. input.execute("ren_stroke_soft_color_intensity -2");
  33. input.execute("ren_health_background_color 0x222222");
  34. input.execute("ren_health_fill_color 0x00FF00");
  35. input.execute("ren_score_bar_fill_color 0xFF0000");
  36. input.execute("ren_xp_bar_fill_color 0xFFFF80");
  37. input.execute("ren_bar_background_color 0x111111");
  38.  
  39. darkThemeEnabled = 1;
  40. }
  41.  
  42. function lightTheme() {
  43. input.execute("ren_background true");
  44. input.execute("net_replace_colors 0x555555 0x999999 0x00B2E1 0x00B2E1 0xF14E54 0xBF7FF5 0x00E16E 0x8AFF69 0xFFE869 0xFC7677 0x768DFC 0xF177DD 0xFFE869 0x43FF91 0xBBBBBB 0xF14E54 0xFCC376 0xC0C0C0");
  45. input.execute("ren_minimap_background_color 0xCDCDCD");
  46. input.execute("ren_minimap_border_color 0x555555");
  47. input.execute("ren_stroke_soft_color_intensity 0.25");
  48. input.execute("ren_health_background_color 0x555555");
  49. input.execute("ren_health_fill_color 0x85E37D");
  50. input.execute("ren_score_bar_fill_color 0x43FF91");
  51. input.execute("ren_xp_bar_fill_color 0xFFDE43");
  52. input.execute("ren_bar_background_color 0x000000");
  53.  
  54. darkThemeEnabled = 0;
  55. }
  56. function showInfo() {
  57. input.execute("ren_debug_info true");
  58. input.execute("ren_fps true");
  59. }
  60. function hideInfo() {
  61. input.execute("ren_debug_info false");
  62. input.execute("ren_fps false");
  63. }
  64.  
  65. function canUseKey(e) {
  66. return input.doesHaveTank() && !e.ctrlKey && currentElem.tagName != "INPUT" && document.activeElement && document.activeElement.tagName != "INPUT";
  67. }
  68.  
  69. function drawLine(ctx, x, y) {
  70. if ((x < X || x > innerWidth - X) || (y < Y || y > innerHeight - Y)) {
  71. let cX = innerWidth / 2;
  72. let cY = innerHeight / 2;
  73. let p1X = x;
  74. let p1Y = y;
  75. let p2X = p1X + (cX - p1X) * 0.4;
  76. let p2Y = p1Y + (cY - p1Y) * 0.4;
  77.  
  78. ctx.beginPath();
  79. ctx.moveTo(p1X, p1Y);
  80. ctx.lineTo(p2X, p2Y);
  81. ctx.lineWidth = 3;
  82. ctx.strokeStyle = "#FF0";
  83. ctx.stroke();
  84. ctx.closePath();
  85. }
  86. }
  87.  
  88. function resize(canvas) {
  89. canvas.width = innerWidth;
  90. canvas.height = innerHeight;
  91.  
  92. Y = X * (innerHeight / innerWidth);
  93. D = Math.hypot(innerWidth / 2, innerHeight / 2);
  94. }
  95.  
  96. function createCanvas() {
  97. let canvas = document.createElement("canvas");
  98.  
  99. resize(canvas);
  100.  
  101. canvas.style.display = "block";
  102. canvas.style.position = "absolute";
  103. canvas.style.left = "0px";
  104. canvas.style.top = "0px";
  105. canvas.style.zIndex = 1000;
  106. canvas.style.pointerEvents = "none";
  107.  
  108. document.body.append(canvas);
  109.  
  110. return canvas;
  111. }
  112.  
  113. function drawAimLine(ctx) {
  114. let p1X = closestCircleX;
  115. let p1Y = closestCircleY;
  116. let a = Math.atan2(cursorY - p1Y, cursorX - p1X);
  117. let p2X = p1X + Math.cos(a) * D;
  118. let p2Y = p1Y + Math.sin(a) * D;
  119.  
  120. ctx.beginPath();
  121. ctx.moveTo(p1X, p1Y);
  122. ctx.lineTo(p2X, p2Y);
  123. ctx.lineWidth = 2;
  124. ctx.strokeStyle = "#EEE";
  125. ctx.stroke();
  126. ctx.closePath();
  127. }
  128.  
  129. function drawCircle(ctx, r) {
  130. ctx.beginPath();
  131. ctx.arc(cursorX, cursorY, r, 0, Math.PI * 2);
  132. ctx.stroke();
  133. ctx.closePath();
  134. }
  135.  
  136. function drawFactoryHelperCircles(ctx) {
  137. ctx.lineWidth = 2;
  138. ctx.strokeStyle = "#EEE";
  139. drawCircle(ctx, 315);
  140. drawCircle(ctx, 85);
  141. }
  142. document.addEventListener("keydown", e => {
  143. let canUse = canUseKey(e);
  144.  
  145. if (canUse) {
  146. let code = e.code;
  147. if (code == "KeyR") {
  148. darkTheme();
  149. }
  150. if (code == "KeyT") {
  151. lightTheme();
  152. }
  153.  
  154. if (code == "KeyF") {
  155. aimLine = !aimLine;
  156. }
  157.  
  158. if (code == "KeyG") {
  159. esp = !esp;
  160. }
  161.  
  162. if (code == "KeyJ") {
  163. factoryHelper = !factoryHelper;
  164. }
  165.  
  166. if (code == "KeyB") {
  167. // openBuilds();
  168. }
  169.  
  170. if (code == "KeyN") {
  171. // openScoreHistory();
  172. }
  173. }
  174. });
  175. document.addEventListener("keyup", e => {
  176. let canUse = canUseKey(e);
  177.  
  178. if (canUse) {
  179. let code = e.code;
  180. if (code == "KeyL") {
  181. info = !info;
  182. if (info) {
  183. showInfo();
  184. } else {
  185. hideInfo();
  186. }
  187. }
  188. }
  189. });
  190.  
  191. document.addEventListener("mousemove", e => {
  192. cursorX = e.clientX;
  193. cursorY = e.clientY;
  194. });
  195.  
  196. window.addEventListener("beforeunload", () => {
  197. lightTheme();
  198. });
  199.  
  200. CanvasRenderingContext2D.prototype.fill = function() {
  201. if (darkThemeEnabled && this.fillStyle == "#000000") {
  202. this.fillStyle = "#EEEEEE";
  203. }
  204.  
  205. fill.apply(this);
  206. }
  207.  
  208. let interval = setInterval(function() {
  209. let img = document.getElementById("backdrop-asset");
  210. let canvas1 = document.getElementById("canvas");
  211.  
  212. if (img && canvas1) {
  213. clearInterval(interval);
  214.  
  215. img.remove();
  216.  
  217. let ctx1 = canvas1.getContext("2d");
  218. let fill = ctx1.fill.bind(ctx1);
  219. let arc = ctx1.arc.bind(ctx1);
  220. let clearRect = ctx1.clearRect.bind(ctx1);
  221.  
  222. let canvas2 = createCanvas();
  223. let ctx2 = canvas2.getContext("2d");
  224.  
  225. document.body.addEventListener("resize", function() {
  226. resize(canvas2);
  227. });
  228.  
  229. ctx1.arc = function(x, y, r, sA, eA, cc = false) {
  230. arc(x, y, r, sA, eA, cc);
  231.  
  232. let transform = ctx1.getTransform();
  233. let x1 = transform.e;
  234. let y1 = transform.f;
  235. let r1 = transform.a;
  236.  
  237. if (esp && r1 >= 20 && ctx1.globalAlpha == 1) {
  238. drawLine(ctx2, x1, y1);
  239. }
  240.  
  241. if (Math.abs(x1 - innerWidth / 2) < 70 && Math.abs(y1 - innerHeight / 2) < 70 && r1 >= 20 && ctx1.globalAlpha == 1) {
  242. closestCircleX = x1;
  243. closestCircleY = y1;
  244. }
  245. }
  246.  
  247. ctx1.clearRect = function(x, y, w, h) {
  248. clearRect(x, y, w, h);
  249. ctx2.clearRect(0, 0, innerWidth, innerHeight);
  250.  
  251. if (aimLine && input.doesHaveTank()) {
  252. drawAimLine(ctx2);
  253. }
  254.  
  255. if (factoryHelper && input.doesHaveTank()) {
  256. drawFactoryHelperCircles(ctx2);
  257. }
  258. }
  259. }
  260. }, 100);