Diep.io Mod Menu

Loop upgrade custom builds, render aim line, render factory guide circle.

目前为 2024-09-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Diep.io Mod Menu
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.0
  5. // @homepage https://github.com/x032205/diep_mod_menu
  6. // @description Loop upgrade custom builds, render aim line, render factory guide circle.
  7. // @author https://github.com/x032205
  8. // @match https://diep.io/
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. "use strict";
  15.  
  16. const backdrop = document.createElement("div");
  17. backdrop.id = "backdrop";
  18.  
  19. const toggle_text = document.createElement("code");
  20. toggle_text.classList.add("watermark");
  21. toggle_text.textContent = "Diep Mod Menu | Press [R] to toggle";
  22.  
  23. backdrop.appendChild(toggle_text);
  24.  
  25. const panel = document.createElement("div");
  26. panel.id = "panel";
  27.  
  28. const side_panel = document.createElement("nav");
  29. panel.appendChild(side_panel);
  30.  
  31. const separator = document.createElement("div");
  32. separator.classList.add("separator");
  33. panel.appendChild(separator);
  34.  
  35. const display_panel = document.createElement("div");
  36. display_panel.classList.add("inner_panel");
  37. panel.appendChild(display_panel);
  38.  
  39. const view_line = document.createElement("div");
  40. view_line.classList.add("view-option");
  41.  
  42. const view_line_text = document.createElement("span");
  43. view_line_text.textContent = "Aim line";
  44.  
  45. const view_line_label = document.createElement("label");
  46. view_line_label.classList.add("switch");
  47.  
  48. const view_line_toggle = document.createElement("input");
  49. view_line_toggle.setAttribute("type", "checkbox");
  50. view_line_label.appendChild(view_line_toggle);
  51.  
  52. const view_line_div = document.createElement("div");
  53. view_line_label.appendChild(view_line_div);
  54. view_line.appendChild(view_line_label);
  55. view_line.appendChild(view_line_text);
  56.  
  57. const view_circle = document.createElement("div");
  58. view_circle.classList.add("view-option");
  59.  
  60. const view_circle_text = document.createElement("span");
  61. view_circle_text.textContent = "Factory circle";
  62.  
  63. const view_circle_label = document.createElement("label");
  64. view_circle_label.classList.add("switch");
  65.  
  66. const view_circle_toggle = document.createElement("input");
  67. view_circle_toggle.setAttribute("type", "checkbox");
  68. view_circle_label.appendChild(view_circle_toggle);
  69.  
  70. const view_circle_div = document.createElement("div");
  71. view_circle_label.appendChild(view_circle_div);
  72. view_circle.appendChild(view_circle_label);
  73. view_circle.appendChild(view_circle_text);
  74.  
  75. // Visual Tab
  76. const visual_tab = document.createElement("button");
  77. visual_tab.classList.add("tab_button", "active");
  78. side_panel.appendChild(visual_tab);
  79.  
  80. const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
  81. svg.setAttribute("width", "32");
  82. svg.setAttribute("height", "32");
  83. svg.setAttribute("viewBox", "0 0 24 24");
  84. svg.setAttribute("fill", "none");
  85. svg.setAttribute("stroke", "#BBBBBB");
  86. svg.setAttribute("stroke-width", "2.5");
  87. svg.setAttribute("stroke-linecap", "round");
  88. svg.setAttribute("stroke-linejoin", "round");
  89.  
  90. svg.innerHTML =
  91. '<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/>';
  92.  
  93. visual_tab.appendChild(svg);
  94.  
  95. visual_tab.onclick = function () {
  96. display_panel.innerHTML = ``;
  97. display_panel.appendChild(view_line);
  98. display_panel.appendChild(view_circle);
  99. setActiveTab(visual_tab);
  100. };
  101.  
  102. const au_label = document.createElement("span");
  103. au_label.classList.add("subheading");
  104. au_label.textContent = "Custom Build";
  105.  
  106. const au_input = document.createElement("input");
  107. au_input.ariaReadOnly = "true";
  108. au_input.setAttribute("type", "text");
  109. au_input.classList.add("custom-input");
  110. au_input.placeholder = "000000000000000000000000000000000";
  111. au_input.maxLength = 33;
  112.  
  113. const au_autoset = document.createElement("div");
  114. au_autoset.classList.add("view-option");
  115.  
  116. const au_autoset_text = document.createElement("span");
  117. au_autoset_text.textContent = "Auto-build enabled";
  118.  
  119. const au_autoset_label = document.createElement("label");
  120. au_autoset_label.classList.add("switch");
  121.  
  122. const au_autoset_toggle = document.createElement("input");
  123. au_autoset_toggle.setAttribute("type", "checkbox");
  124. au_autoset_label.appendChild(au_autoset_toggle);
  125.  
  126. const au_autoset_div = document.createElement("div");
  127. au_autoset_label.appendChild(au_autoset_div);
  128. au_autoset.appendChild(au_autoset_label);
  129. au_autoset.appendChild(au_autoset_text);
  130.  
  131. // Auto Upgrade Tab
  132. const auto_upgrades_tab = document.createElement("button");
  133. auto_upgrades_tab.classList.add("tab_button");
  134. side_panel.appendChild(auto_upgrades_tab);
  135.  
  136. const au_svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
  137. au_svg.setAttribute("width", "32");
  138. au_svg.setAttribute("height", "32");
  139. au_svg.setAttribute("viewBox", "0 0 24 24");
  140. au_svg.setAttribute("fill", "none");
  141. au_svg.setAttribute("stroke", "#BBBBBB");
  142. au_svg.setAttribute("stroke-width", "2.5");
  143. au_svg.setAttribute("stroke-linecap", "round");
  144. au_svg.setAttribute("stroke-linejoin", "round");
  145.  
  146. au_svg.innerHTML =
  147. '<path d="M12 2a10 10 0 0 1 7.38 16.75"/><path d="m16 12-4-4-4 4"/><path d="M12 16V8"/><path d="M2.5 8.875a10 10 0 0 0-.5 3"/><path d="M2.83 16a10 10 0 0 0 2.43 3.4"/><path d="M4.636 5.235a10 10 0 0 1 .891-.857"/><path d="M8.644 21.42a10 10 0 0 0 7.631-.38"/>';
  148.  
  149. auto_upgrades_tab.appendChild(au_svg);
  150.  
  151. auto_upgrades_tab.onclick = function () {
  152. display_panel.innerHTML = ``;
  153. display_panel.appendChild(au_label);
  154. display_panel.appendChild(au_input);
  155. display_panel.appendChild(au_autoset);
  156. setActiveTab(auto_upgrades_tab);
  157. };
  158.  
  159. const credits_tab = document.createElement("button");
  160. credits_tab.classList.add("tab_button");
  161. side_panel.appendChild(credits_tab);
  162.  
  163. const credit_svg = document.createElementNS(
  164. "http://www.w3.org/2000/svg",
  165. "svg",
  166. );
  167. credit_svg.setAttribute("width", "32");
  168. credit_svg.setAttribute("height", "32");
  169. credit_svg.setAttribute("viewBox", "0 0 24 24");
  170. credit_svg.setAttribute("fill", "none");
  171. credit_svg.setAttribute("stroke", "#BBBBBB");
  172. credit_svg.setAttribute("stroke-width", "2.5");
  173. credit_svg.setAttribute("stroke-linecap", "round");
  174. credit_svg.setAttribute("stroke-linejoin", "round");
  175.  
  176. credit_svg.innerHTML =
  177. '<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>';
  178.  
  179. credits_tab.appendChild(credit_svg);
  180.  
  181. credits_tab.onclick = function () {
  182. display_panel.innerHTML = `<span><span class="text-muted">Discord:</span> <code>@someplace</code></span>
  183. <span><span class="text-muted">Github:</span> <code>@x032205</code></span>`;
  184. setActiveTab(credits_tab);
  185. };
  186.  
  187. const style = document.createElement("style");
  188. style.textContent = `
  189. * {
  190. font-family: 'Inter', sans-serif;
  191. color: #EEEEEE;
  192. font-size: 16px;
  193. }
  194.  
  195. code { font-family: monospace; }
  196.  
  197. #panel {
  198. display: flex;
  199. flex-direction: row;
  200. max-width: 600px;
  201. max-height: 400px;
  202. width: 100%;
  203. height: 100%;
  204. padding: 12px;
  205. position: absolute;
  206. top: 50%;
  207. left: 50%;
  208. transform: translate(-50%, -50%);
  209. gap: 6px;
  210. background: hsla(0, 0%, 10%, 0.7);
  211. backdrop-filter: blur(7px);
  212. -webkit-backdrop-filter: blur(7px);
  213. border: 1px solid hsla(0, 0%, 100%, 0.1);
  214. border-radius: 8px;
  215. z-index: 10;
  216. }
  217.  
  218. .separator {
  219. width: 1px;
  220. height: 100%;
  221. background-color: hsla(0, 0%, 100%, 0.1);
  222. }
  223.  
  224. .switch {
  225. display: inline-block;
  226. font-size: 20px;
  227. height: 1em;
  228. width: 2em;
  229. background: rgb(50, 50, 50);
  230. border-radius: 1em;
  231. margin-right: 10px;
  232. cursor: pointer;
  233. }
  234.  
  235. .switch input {
  236. position: absolute;
  237. opacity: 0;
  238. cursor: pointer;
  239. }
  240.  
  241. .switch div {
  242. font-size: 20px;
  243. height: 1em;
  244. width: 1em;
  245. border-radius: 1em;
  246. background: rgb(100, 100, 100);
  247. transition: all 100ms;
  248. cursor: pointer;
  249. }
  250.  
  251. .switch input:checked + div {
  252. transform: translate3d(100%, 0, 0);
  253. background: #EEEEEE;
  254. }
  255.  
  256. nav {
  257. display: flex;
  258. flex-direction: column;
  259. gap: 6px;
  260. }
  261.  
  262. .inner_panel {
  263. display: flex;
  264. flex-direction: column;
  265. gap: 6px;
  266. padding: 4px;
  267. width: 100%;
  268. margin-left: 4px;
  269. }
  270.  
  271. .tab_button {
  272. display: flex;
  273. width: 48px;
  274. height: 48px;
  275. justify-content: center;
  276. align-items: center;
  277. background: hsla(0, 0%, 20%, 0.5);
  278. border-radius: 4px;
  279. border: none;
  280. transition: all 100ms cubic-bezier(0.4, 0, 0.2, 1);
  281. }
  282.  
  283. .tab_button:hover,
  284. .tab_button.active {
  285. background: hsla(0, 0%, 40%, 0.5);
  286. }
  287.  
  288. #backdrop {
  289. position: fixed;
  290. top: 0;
  291. left: 0;
  292. width: 100%;
  293. height: 100%;
  294. background-color: rgba(0, 0, 0, 0.5);
  295. z-index: 9;
  296. backdrop-filter: blur(5px);
  297. -webkit-backdrop-filter: blur(5px);
  298. }
  299.  
  300. .watermark {
  301. position: fixed;
  302. top: 8px;
  303. left: 50%;
  304. transform: translateX(-50%);
  305. }
  306.  
  307. .subheading { font-weight: 600; }
  308.  
  309. .view-option {
  310. text-align: left;
  311. align-items: center;
  312. height: 28px;
  313. display: flex;
  314. }
  315.  
  316. .custom-input {
  317. background: hsla(0, 0%, 10%, 0.7);
  318. border: 1px solid hsla(0, 0%, 100%, 0.1);
  319. border-radius: 4px;
  320. padding: 6px;
  321. outline: none;
  322. }
  323.  
  324. .text-muted { color: #BBBBBB; }
  325. `;
  326.  
  327. backdrop.appendChild(panel);
  328. document.body.appendChild(backdrop);
  329. document.head.appendChild(style);
  330.  
  331. function toggleDisplay(elementId) {
  332. const element = document.getElementById(elementId);
  333. const backdrop = document.getElementById("backdrop");
  334. const isHidden = element.style.display === "none";
  335. element.style.display = isHidden ? "block" : "none";
  336. backdrop.style.display = isHidden ? "block" : "none";
  337. }
  338.  
  339. function setActiveTab(activeTab) {
  340. [visual_tab, auto_upgrades_tab, credits_tab].forEach((tab) =>
  341. tab.classList.remove("active"),
  342. );
  343. activeTab.classList.add("active");
  344. }
  345.  
  346. let X, Y, x, y;
  347. let Z = false;
  348. let radius = [];
  349.  
  350. document.body.onkeyup = function (ctx) {
  351. if (ctx.keyCode === 82) {
  352. toggleDisplay("backdrop");
  353. } else if (document.activeElement === au_input) {
  354. const key = parseInt(ctx.key);
  355. if (key >= 1 && key <= 8) {
  356. au_input.value += ctx.key;
  357. } else if (ctx.keyCode === 8) {
  358. au_input.value = au_input.value.slice(0, -1);
  359. }
  360. }
  361. };
  362.  
  363. document.onmousemove = (event) => {
  364. x = event.clientX;
  365. y = event.clientY;
  366. };
  367. document.onmousedown = (e) => {
  368. if (e.button === 2) Z = true;
  369. };
  370. document.onmouseup = (e) => {
  371. if (e.button === 2) Z = false;
  372. };
  373.  
  374. const canvas = document.createElement("canvas");
  375. canvas.style.zIndex = "11";
  376. canvas.style.position = "absolute";
  377. canvas.style.top = "0px";
  378. canvas.style.left = "0px";
  379. canvas.style.pointerEvents = "none";
  380.  
  381. function getRadius() {
  382. X = window.innerWidth / 2;
  383. Y = window.innerHeight / 2;
  384. canvas.width = window.innerWidth;
  385. canvas.height = window.innerHeight;
  386.  
  387. radius = [
  388. window.innerWidth * 0.17681239669,
  389. window.innerWidth * 0.06545454545,
  390. window.innerWidth * 0.16751239669,
  391. window.innerWidth * 0.36,
  392. ];
  393. }
  394.  
  395. getRadius();
  396. window.addEventListener("resize", getRadius);
  397.  
  398. document.body.appendChild(canvas);
  399. const ctx = canvas.getContext("2d");
  400.  
  401. function draw() {
  402. ctx.clearRect(0, 0, canvas.width, canvas.height);
  403.  
  404. if (view_line_toggle.checked) {
  405. ctx.beginPath();
  406. ctx.moveTo(X, Y);
  407. ctx.lineTo(x, y);
  408. ctx.lineWidth = 50;
  409. ctx.strokeStyle = "rgba(0, 0, 0, 0.05)";
  410. ctx.stroke();
  411.  
  412. ctx.beginPath();
  413. ctx.moveTo(X, Y);
  414. ctx.lineTo(x, y);
  415. ctx.lineWidth = 2;
  416. ctx.strokeStyle = "rgba(0, 0, 0, 0.7)";
  417. ctx.stroke();
  418. }
  419.  
  420. if (view_circle_toggle.checked) {
  421. ctx.lineWidth = 2;
  422. ctx.strokeStyle = "rgba(0, 0, 0, 0.7)";
  423.  
  424. ctx.beginPath();
  425. ctx.arc(X, Y, radius[3], 0, 2 * Math.PI);
  426. ctx.stroke();
  427.  
  428. ctx.beginPath();
  429. ctx.arc(x, y, radius[1], 0, 2 * Math.PI);
  430. ctx.stroke();
  431.  
  432. ctx.beginPath();
  433. ctx.arc(x, y, Z ? radius[0] : radius[2], 0, 2 * Math.PI);
  434. ctx.stroke();
  435. }
  436.  
  437. if (au_autoset_toggle.checked) {
  438. input.execute("game_stats_build " + au_input.value);
  439. }
  440. requestAnimationFrame(draw);
  441. }
  442. draw();
  443.  
  444. visual_tab.click();
  445. })();