Diep.io+ (added Custom Auto Spin)

Quick Tank Upgrades, Highscore saver, Team Switcher, Advanced Auto Respawn, Anti Aim, Zoom hack, Anti AFK Timeout, Sandbox Auto K, Sandbox Arena Increase

目前為 2025-03-13 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Diep.io+ (added Custom Auto Spin)
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.2.2.0
  5. // @description Quick Tank Upgrades, Highscore saver, Team Switcher, Advanced Auto Respawn, Anti Aim, Zoom hack, Anti AFK Timeout, Sandbox Auto K, Sandbox Arena Increase
  6. // @author r!PsAw
  7. // @match https://diep.io/*
  8. // @icon https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQFMDAvSZe2hsFwAIeAPcDSNx8X2lUMp-rLPA&s
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. //inner script settings
  14. let deep_debug_properties = {
  15. active: false, //display information in console
  16. canvas: false, //display information on screen
  17. }
  18.  
  19. function deep_debug(...args) {
  20. if (deep_debug_properties.active) {
  21. console.log(...args);
  22. }
  23. }
  24.  
  25. //Information for script
  26. let _c = window.__common__;
  27. function is_fullscreen(){
  28. return ((window.innerHeight == screen.height) && (window.innerWidth == screen.width));
  29. }
  30.  
  31. const diep_keys = [ //document has to be focused to execute these, also C and E don't work right now
  32. "KeyA", "KeyB", "KeyC", "KeyD", "KeyE", "KeyF", "KeyG", "KeyH", "KeyI", "KeyJ", "KeyK", "KeyL", "KeyM", "KeyN", "KeyO", "KeyP", "KeyQ", "KeyR", "KeyS", "KeyT", "KeyU", "KeyV", "KeyW", "KeyX", "KeyY", "KeyZ",
  33. "ArrowUp", "ArrowLeft", "ArrowDown", "ArrowRight", "Tab", "Enter", "NumpadEnter", "ShiftLeft", "ShiftRight", "Space", "Numpad0", "Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9",
  34. "Digit0", "Digit1", "Digit2", "Digit3", "Digit4", "Digit5", "Digit6", "Digit7", "Digit8", "Digit9", "F2", "End", "Home", "Semicolon", "Comma", "NumpadComma", "Period", "Backslash"
  35. ].reduce((n, e, c) => {
  36. n[e] = c + 1;
  37. return n;
  38. }, {});
  39.  
  40. let player = {
  41. connected: false,
  42. inGame: false,
  43. name: '',
  44. team: null,
  45. gamemode: null,
  46. ui_scale: 1,
  47. dpr: 1,
  48. base_value: 1,
  49. };
  50.  
  51. let inputs = {
  52. mouse: {
  53. real: {
  54. x: 0,
  55. y: 0,
  56. },
  57. game: {
  58. x: 0,
  59. y: 0,
  60. },
  61. force: {
  62. x: 0,
  63. y: 0,
  64. },
  65. isForced: false, //input mouse operations flag (overwrites your inputs to forced one's)
  66. isFrozen: false, //Mouse Freeze flag
  67. isShooting: false, //Anti Aim flag
  68. isPaused: false, //Anti Aim flag (different from isFrozen & isForced for better readability)
  69. original: {
  70. onTouchMove: null,
  71. onTouchStart: null,
  72. onTouchEnd: null,
  73. }
  74. },
  75. keys_pressed: [],
  76. };
  77.  
  78. function windowScaling() {
  79. const a = canvas.height / 1080;
  80. const b = canvas.width / 1920;
  81. return b < a ? a : b;
  82. }
  83.  
  84. //basic function to construct links
  85. function link(baseUrl, lobby, gamemode, team) {
  86. let str = "";
  87. str += baseUrl + "?s=" + lobby + "&g=" + gamemode + "&l=" + team;
  88. return str;
  89. }
  90.  
  91. function get_baseUrl() {
  92. return location.origin + location.pathname;
  93. }
  94.  
  95. function get_your_lobby() {
  96. return window.lobby_ip;
  97. }
  98.  
  99. function get_gamemode() {
  100. //return window.__common__.active_gamemode;
  101. return window.lobby_gamemode;
  102. }
  103.  
  104. function get_team() {
  105. return window.__common__.party_link;
  106. }
  107.  
  108. //all team links
  109. function get_links(gamemode, lobby, team = get_team()) {
  110. let baseUrl = get_baseUrl();
  111. let colors = ["🔵", "🔴", "🟣", "🟢", "👥❌"];
  112. let final_links = [];
  113. switch (gamemode) {
  114. case "4teams":
  115. for (let i = 0; i < 4; i++) {
  116. final_links.push([colors[i], link(baseUrl, lobby, gamemode, team.split("x")[0] + `x${i}`)]);
  117. }
  118. break
  119. case "teams":
  120. for (let i = 0; i < 2; i++) {
  121. final_links.push([colors[i], link(baseUrl, lobby, gamemode, team.split("x")[0] + `x${i}`)]);
  122. }
  123. break
  124. default:
  125. final_links.push([colors[colors.length - 1], link(baseUrl, lobby, gamemode, team)]);
  126. }
  127. return final_links;
  128. }
  129.  
  130. //dimensions
  131.  
  132. class dimensions_converter {
  133. constructor() {
  134. this.scalingFactor = null; //undetectable without bypass
  135. this.fieldFactor = null; //undetectable without bypass
  136. }
  137. canvas_2_window(a) {
  138. let b = a / (canvas.width / window.innerWidth);
  139. return b;
  140. }
  141.  
  142. window_2_canvas(a) {
  143. let b = a * (canvas.width / window.innerWidth);
  144. return b;
  145. }
  146.  
  147. windowScaling_2_window(a) {
  148. let b = (this.windowScaling_2_canvas(a)) / (canvas.width / window.innerWidth);
  149. return b;
  150. }
  151.  
  152. windowScaling_2_canvas(a) {
  153. let b = a * windowScaling();
  154. deep_debug('windowScaling_2_canvas called! a, b', a, b);
  155. return b;
  156. }
  157. /* DISABLED FOR NOW
  158. diepUnits_2_canvas(a) {
  159. let b = a / scalingFactor;
  160. return b;
  161. }
  162.  
  163. diepUnits_2_window(a) {
  164. let b = (this.diepUnits_2_canvas(a)) / (canvas.width / window.innerWidth);
  165. return b;
  166. }
  167.  
  168. window_2_diepUnits(a) {
  169. let b = (this.canvas_2_diepUnits(a)) * (canvas.width / window.innerWidth);
  170. return b;
  171. }
  172.  
  173. canvas_2_diepUnits(a) {
  174. let b = a * this.scalingFactor;
  175. return b;
  176. }
  177. */
  178.  
  179. window_2_windowScaling(a) {
  180. let b = (this.canvas_2_windowScaling(a)) * (canvas.width / window.innerWidth) * player.ui_scale;
  181. return b;
  182. }
  183.  
  184. canvas_2_windowScaling(a) {
  185. let b = a * windowScaling();
  186. return b;
  187. }
  188. /* DISABLED FOR NOW
  189. diepUnits_2_windowScaling(a) {
  190. let b = (this.diepUnits_2_canvas(a)) * this.fieldFactor;
  191. return b;
  192. }
  193.  
  194. windowScaling_2_diepUntis(a) {
  195. let b = (a / this.fieldFactor) * this.scalingFactor;
  196. return b;
  197. }
  198. */
  199. }
  200.  
  201. let dim_c = new dimensions_converter();
  202.  
  203. function i_e(type, key, ...args) {
  204. switch (type) {
  205. case "input":
  206. input[key](...args);
  207. break
  208. case "extern":
  209. extern[key](...args);
  210. break
  211. }
  212. }
  213.  
  214. function apply_force(x, y) {
  215. inputs.mouse.force = {
  216. x: x,
  217. y: y,
  218. }
  219. inputs.mouse.isForced = true;
  220. }
  221.  
  222. function disable_force() {
  223. inputs.mouse.isForced = false;
  224. }
  225.  
  226. const touchMethods = ['onTouchMove', 'onTouchStart', 'onTouchEnd'];
  227. let canvas = document.getElementById("canvas");
  228. let ctx = canvas.getContext('2d');
  229.  
  230. function define_onTouch() {
  231. touchMethods.forEach(function(method) {
  232. inputs.mouse.original[method] = input[method];
  233. deep_debug('defined input.', method);
  234. });
  235. }
  236.  
  237. function clear_onTouch() {
  238. touchMethods.forEach(function(method) {
  239. input[method] = () => {};
  240. });
  241. }
  242.  
  243. function redefine_onTouch() {
  244. touchMethods.forEach(function(method) {
  245. input[method] = inputs.mouse.original[method];
  246. });
  247. }
  248.  
  249. function start_input_proxies(_filter = false, _single = false, _method = null) {
  250. ((_filter || _single) && !_method) ? console.warn("missing _method at start_input_proxies"): null;
  251. let temp_methods = touchMethods;
  252. if (_filter) {
  253. temp_methods.filter((item) => item != _method);
  254. } else if (_single) {
  255. temp_methods = [_method];
  256. }
  257. temp_methods.forEach(function(method) {
  258. input[method] = new Proxy(input[method], {
  259. apply: function(definition, input_obj, args) {
  260. let x, y, type, new_args;
  261. if (inputs.mouse.isForced) {
  262. x = inputs.mouse.force.x;
  263. y = inputs.mouse.force.y;
  264. } else {
  265. x = args[1];
  266. y = args[2];
  267. }
  268. type = args[0];
  269. new_args = [type, dim_c.window_2_canvas(x / player.dpr), dim_c.window_2_canvas(y / player.dpr)];
  270. inputs.mouse.game = {
  271. x: new_args[1],
  272. y: new_args[2],
  273. }
  274. return Reflect.apply(definition, input_obj, new_args);
  275. }
  276. });
  277. });
  278. }
  279.  
  280. //create ingame Notifications
  281. function rgbToNumber(r, g, b) {
  282. return (r << 16) | (g << 8) | b;
  283. }
  284. const notification_rgbs = {
  285. require: [255, 165, 0], //orange
  286. warning: [255, 0, 0], //red
  287. normal: [0, 0, 128] //blue
  288. }
  289.  
  290. let notifications = [];
  291.  
  292. function new_notification(text, color, duration) {
  293. input.inGameNotification(text, rgbToNumber(...color), duration);
  294. }
  295.  
  296. function one_time_notification(text, color, duration){
  297. if(notifications.includes(text)){
  298. return;
  299. }
  300. if(player.inGame){
  301. new_notification(text, color, duration);
  302. notifications.push(text);
  303. }else{
  304. notifications = [];
  305. }
  306. }
  307.  
  308. //GUI
  309. function n2id(string) {
  310. return string.toLowerCase().replace(/ /g, "-");
  311. }
  312.  
  313. class El {
  314. constructor(
  315. name,
  316. type,
  317. el_color,
  318. width,
  319. height,
  320. opacity = "1",
  321. zindex = "100"
  322. ) {
  323. this.el = document.createElement(type);
  324. this.el.style.backgroundColor = el_color;
  325. this.el.style.width = width;
  326. this.el.style.height = height;
  327. this.el.style.opacity = opacity;
  328. this.el.style.zIndex = zindex;
  329. this.el.id = n2id(name);
  330. this.display = "block"; // store default display
  331. }
  332.  
  333. setBorder(type, width, color, radius = 0) {
  334. const borderStyle = `${width} solid ${color}`;
  335. switch (type) {
  336. case "normal":
  337. this.el.style.border = borderStyle;
  338. break;
  339. case "top":
  340. this.el.style.borderTop = borderStyle;
  341. break;
  342. case "left":
  343. this.el.style.borderLeft = borderStyle;
  344. break;
  345. case "right":
  346. this.el.style.borderRight = borderStyle;
  347. break;
  348. case "bottom":
  349. this.el.style.borderBottom = borderStyle;
  350. break;
  351. }
  352. this.el.style.borderRadius = radius;
  353. }
  354.  
  355. setPosition(
  356. position,
  357. display,
  358. top,
  359. left,
  360. flexDirection,
  361. justifyContent,
  362. translate
  363. ) {
  364. this.el.style.position = position;
  365. this.el.style.display = display;
  366. if (top) this.el.style.top = top;
  367. if (left) this.el.style.left = left;
  368. // Flex properties
  369. if (flexDirection) this.el.style.flexDirection = flexDirection;
  370. if (justifyContent) this.el.style.justifyContent = justifyContent;
  371. if (translate) this.el.style.transform = `translate(${translate})`;
  372. this.display = display;
  373. }
  374.  
  375. margin(top, left, right, bottom) {
  376. this.el.style.margin = `${top} ${right} ${bottom} ${left}`;
  377. }
  378.  
  379. setText(
  380. text,
  381. txtColor,
  382. font,
  383. weight,
  384. fontSize,
  385. stroke,
  386. alignContent,
  387. textAlign
  388. ) {
  389. this.el.innerHTML = text;
  390. this.el.style.color = txtColor;
  391. this.el.style.fontFamily = font;
  392. this.el.style.fontWeight = weight;
  393. this.el.style.fontSize = fontSize;
  394. this.el.style.textShadow = stroke;
  395. this.el.style.alignContent = alignContent;
  396. this.el.style.textAlign = textAlign;
  397. }
  398.  
  399. add(parent) {
  400. parent.appendChild(this.el);
  401. }
  402.  
  403. remove(parent) {
  404. parent.removeChild(this.el);
  405. }
  406.  
  407. toggle(showOrHide) {
  408. this.el.style.display = showOrHide === "hide" ? "none" : this.display;
  409. }
  410. }
  411.  
  412. let mainCont, header, subContGray, subContBlack, modCont, settCont;
  413.  
  414. class Setting {
  415. constructor(name, type, options) {
  416. this.name = name;
  417. this.options = options;
  418. this.elements = [];
  419. this.desc = new El(
  420. name + " Setting",
  421. "div",
  422. "transparent",
  423. "170px",
  424. "50px"
  425. );
  426. this.desc.setPosition("relative", "block");
  427. this.desc.setText(
  428. name,
  429. "white",
  430. "Calibri",
  431. "bold",
  432. "15px",
  433. "2px",
  434. "center",
  435. "center"
  436. );
  437. this.elements.push(this.desc.el);
  438.  
  439. switch (type) {
  440. case "title":
  441. this.desc.el.style.backgroundColor = "rgb(50, 50, 50)";
  442. this.desc.setText(
  443. name,
  444. "lightgray",
  445. "Calibri",
  446. "bold",
  447. "20px",
  448. "2px",
  449. "center",
  450. "center"
  451. );
  452. this.desc.setBorder("normal", "2px", "gray", "5px");
  453. break;
  454. case "select": {
  455. if (!this.options) return console.warn("Missing Options!");
  456. let index = 0;
  457. this.selected = options[index];
  458. //temp cont
  459. let temp_container = new El(
  460. name + " temp Container",
  461. "div",
  462. "transparent"
  463. );
  464. temp_container.el.style.display = "flex";
  465. temp_container.el.style.alignItems = "center";
  466. temp_container.el.style.justifyContent = "center";
  467. temp_container.el.style.gap = "10px";
  468.  
  469. //displ
  470. let displ = new El(
  471. name + " Setting Display",
  472. "div",
  473. "lightgray",
  474. "125px",
  475. "25px"
  476. );
  477. displ.setText(
  478. this.selected,
  479. "black",
  480. "Calibri",
  481. "bold",
  482. "15px",
  483. "2px",
  484. "center",
  485. "center"
  486. );
  487.  
  488. //left Arrow
  489. let l_arrow = new El(
  490. name + " left Arrow",
  491. "div",
  492. "transparent",
  493. "0px",
  494. "0px"
  495. );
  496. l_arrow.setBorder("bottom", "8px", "transparent");
  497. l_arrow.setBorder("left", "0px", "transparent");
  498. l_arrow.setBorder("right", "16px", "blue");
  499. l_arrow.setBorder("top", "8px", "transparent");
  500.  
  501. l_arrow.el.addEventListener("mouseover", () => {
  502. l_arrow.el.style.cursor = "pointer";
  503. l_arrow.setBorder("right", "16px", "darkblue");
  504. });
  505.  
  506. l_arrow.el.addEventListener("mouseout", () => {
  507. l_arrow.el.style.cursor = "normal";
  508. l_arrow.setBorder("right", "16px", "blue");
  509. });
  510.  
  511. l_arrow.el.addEventListener("mousedown", (e) => {
  512. if (e.button != 0) return;
  513. let limit = options.length - 1;
  514. if (index - 1 < 0) {
  515. index = limit;
  516. } else {
  517. index--;
  518. }
  519. this.selected = options[index];
  520. displ.el.innerHTML = this.selected;
  521. });
  522.  
  523. //right Arrow
  524. let r_arrow = new El(
  525. name + " right Arrow",
  526. "div",
  527. "transparent",
  528. "0px",
  529. "0px"
  530. );
  531. r_arrow.setBorder("bottom", "8px", "transparent");
  532. r_arrow.setBorder("left", "16px", "blue");
  533. r_arrow.setBorder("right", "0px", "transparent");
  534. r_arrow.setBorder("top", "8px", "transparent");
  535.  
  536. r_arrow.el.addEventListener("mouseover", () => {
  537. r_arrow.el.style.cursor = "pointer";
  538. r_arrow.setBorder("left", "16px", "darkblue");
  539. });
  540.  
  541. r_arrow.el.addEventListener("mouseout", () => {
  542. r_arrow.el.style.cursor = "normal";
  543. r_arrow.setBorder("left", "16px", "blue");
  544. });
  545.  
  546. r_arrow.el.addEventListener("mousedown", (e) => {
  547. if (e.button != 0) return;
  548. let limit = options.length - 1;
  549. if (index + 1 > limit) {
  550. index = 0;
  551. } else {
  552. index++;
  553. }
  554. this.selected = options[index];
  555. displ.el.innerHTML = this.selected;
  556. });
  557.  
  558. //connect together
  559. temp_container.el.appendChild(l_arrow.el);
  560. temp_container.el.appendChild(displ.el);
  561. temp_container.el.appendChild(r_arrow.el);
  562.  
  563. //remember them
  564. this.elements.push(temp_container.el);
  565. break;
  566. }
  567. case "toggle": {
  568. this.active = false;
  569. this.desc.el.style.display = "flex";
  570. this.desc.el.style.alignItems = "center";
  571. this.desc.el.style.justifyContent = "space-between";
  572. let empty_checkbox = new El(
  573. this.name + " Setting checkbox",
  574. "div",
  575. "lightgray",
  576. "20px",
  577. "20px"
  578. );
  579. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  580. //event listeners
  581. empty_checkbox.el.addEventListener("mousedown", (e) => {
  582. if (e.button != 0) return;
  583. this.active = !this.active;
  584. if (this.active) {
  585. empty_checkbox.el.innerHTML = "✔";
  586. empty_checkbox.el.style.backgroundColor = "green";
  587. empty_checkbox.setBorder("normal", "2px", "lime", "4px");
  588. } else {
  589. empty_checkbox.el.innerHTML = "";
  590. empty_checkbox.el.style.backgroundColor = "lightgray";
  591. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  592. }
  593. });
  594. empty_checkbox.el.addEventListener("mouseover", () => {
  595. empty_checkbox.el.style.backgroundColor = this.active
  596. ? "darkgreen"
  597. : "darkgray";
  598. empty_checkbox.el.style.cursor = "pointer";
  599. });
  600. empty_checkbox.el.addEventListener("mouseout", () => {
  601. empty_checkbox.el.style.backgroundColor = this.active
  602. ? "green"
  603. : "lightgray";
  604. });
  605. this.desc.el.appendChild(empty_checkbox.el);
  606. break;
  607. }
  608. }
  609. }
  610. load() {
  611. this.elements.forEach((element) => settCont.el.appendChild(element));
  612. }
  613.  
  614. unload() {
  615. this.elements.forEach((element) => {
  616. if (settCont.el.contains(element)) {
  617. settCont.el.removeChild(element);
  618. }
  619. });
  620. }
  621. }
  622.  
  623. class Module {
  624. constructor(name, type, settings, callback) {
  625. this.name = name;
  626. this.type = type;
  627. this.callbackFunc = callback;
  628. this.settings = settings;
  629. this.title = new El(name, "div", "transparent", "100%", "50px");
  630. this.title.setPosition("relative", "block");
  631. this.title.setText(
  632. name,
  633. "white",
  634. "Calibri",
  635. "bold",
  636. "15px",
  637. "2px",
  638. "center",
  639. "center"
  640. );
  641. this.elements = [];
  642. this.elements.push(this.title.el);
  643. switch (type) {
  644. case "toggle": {
  645. this.active = false;
  646. this.title.el.style.display = "flex";
  647. this.title.el.style.alignItems = "center";
  648. this.title.el.style.justifyContent = "space-between";
  649. let empty_checkbox = new El(
  650. this.name + " checkbox",
  651. "div",
  652. "lightgray",
  653. "20px",
  654. "20px"
  655. );
  656. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  657. //event listeners
  658. empty_checkbox.el.addEventListener("mousedown", (e) => {
  659. if (e.button != 0) return;
  660. this.active = !this.active;
  661. if (this.active) {
  662. empty_checkbox.el.innerHTML = "✔";
  663. empty_checkbox.el.style.backgroundColor = "green";
  664. empty_checkbox.setBorder("normal", "2px", "lime", "4px");
  665. } else {
  666. empty_checkbox.el.innerHTML = "";
  667. empty_checkbox.el.style.backgroundColor = "lightgray";
  668. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  669. }
  670. });
  671. empty_checkbox.el.addEventListener("mouseover", () => {
  672. empty_checkbox.el.style.backgroundColor = this.active
  673. ? "darkgreen"
  674. : "darkgray";
  675. empty_checkbox.el.style.cursor = "pointer";
  676. });
  677. empty_checkbox.el.addEventListener("mouseout", () => {
  678. empty_checkbox.el.style.backgroundColor = this.active
  679. ? "green"
  680. : "lightgray";
  681. });
  682. this.title.el.appendChild(empty_checkbox.el);
  683. break;
  684. }
  685. case "slider": {
  686. this.value = 100;
  687. this.title.el.innerHTML = `${this.name}: ${this.value} %`;
  688. const slider = document.createElement("input");
  689. slider.type = "range";
  690. slider.value = this.value;
  691. slider.min = 0;
  692. slider.max = 100;
  693.  
  694. slider.addEventListener("input", () => {
  695. this.value = slider.value;
  696. this.title.el.innerHTML = `${this.name}: ${this.value} %`;
  697. });
  698.  
  699. this.elements.push(slider);
  700. break;
  701. }
  702. case "button":
  703. this.title.el.style.width = "100%";
  704. this.title.el.style.boxSizing = "border-box";
  705. this.title.el.style.whiteSpace = "normal"; // Allows text wrapping
  706. this.title.setBorder("normal", "2px", "white", "10px");
  707. this.title.el.style.cursor = "pointer";
  708. this.title.el.addEventListener("mousedown", () => {
  709. if (this.callbackFunc) {
  710. this.callbackFunc();
  711. }
  712. });
  713. break;
  714. case "open": {
  715. this.active = false;
  716. this.title.el.style.display = "flex";
  717. this.title.el.style.alignItems = "center";
  718. this.title.el.style.justifyContent = "space-between";
  719. let opener_box = new El(
  720. this.name + " opener box",
  721. "div",
  722. "rgb(75, 75, 75)",
  723. "20px",
  724. "20px"
  725. );
  726. opener_box.setBorder("normal", "2px", "gray", "4px");
  727. opener_box.el.style.display = "flex";
  728. opener_box.el.style.alignItems = "center";
  729. opener_box.el.style.justifyContent = "center";
  730. //
  731. let triangle = new El(
  732. name + " triangle",
  733. "div",
  734. "transparent",
  735. "0px",
  736. "0px"
  737. );
  738. triangle.setBorder("bottom", "16px", "lime");
  739. triangle.setBorder("left", "8px", "transparent");
  740. triangle.setBorder("right", "8px", "transparent");
  741. triangle.setBorder("top", "0px", "transparent");
  742. //
  743. //event listeners
  744. opener_box.el.addEventListener("mousedown", (e) => {
  745. if (e.button != 0) return;
  746. this.active = !this.active;
  747. if (this.active) {
  748. triangle.setBorder("bottom", "0px", "transparent");
  749. triangle.setBorder("left", "8px", "transparent");
  750. triangle.setBorder("right", "8px", "transparent");
  751. triangle.setBorder("top", "16px", "red");
  752. this.loadSettings();
  753. } else {
  754. triangle.setBorder("bottom", "16px", "lime");
  755. triangle.setBorder("left", "8px", "transparent");
  756. triangle.setBorder("right", "8px", "transparent");
  757. triangle.setBorder("top", "0px", "transparent");
  758. this.unloadSettings();
  759. }
  760. });
  761. opener_box.el.addEventListener("mouseover", () => {
  762. opener_box.el.style.backgroundColor = "rgb(50, 50, 50)";
  763. opener_box.el.style.cursor = "pointer";
  764. });
  765. opener_box.el.addEventListener("mouseout", () => {
  766. opener_box.el.style.backgroundColor = "rgb(75, 75, 75)";
  767. });
  768. opener_box.el.appendChild(triangle.el);
  769. this.title.el.appendChild(opener_box.el);
  770. break;
  771. }
  772. }
  773. }
  774. load() {
  775. this.elements.forEach((element) => modCont.el.appendChild(element));
  776. }
  777.  
  778. unload() {
  779. this.elements.forEach((element) => {
  780. if (modCont.el.contains(element)) {
  781. modCont.el.removeChild(element);
  782. }
  783. });
  784. }
  785.  
  786. loadSettings() {
  787. if (!this.settings) return;
  788. for (let _sett in this.settings) {
  789. this.settings[_sett].load();
  790. }
  791. }
  792.  
  793. unloadSettings() {
  794. if (!this.settings) return;
  795. for (let _sett in this.settings) {
  796. this.settings[_sett].unload();
  797. }
  798. }
  799. }
  800.  
  801. class Category {
  802. constructor(name, modules) {
  803. this.name = name;
  804. this.element = new El(name, "div", "rgb(38, 38, 38)", "90px", "50px");
  805. this.element.setPosition("relative", "block");
  806. this.element.setText(
  807. name,
  808. "white",
  809. "Calibri",
  810. "bold",
  811. "20px",
  812. "2px",
  813. "center",
  814. "center"
  815. );
  816. this.element.setBorder("normal", "2px", "transparent", "10px");
  817. this.selected = false;
  818. this.modules = modules;
  819.  
  820. this.element.el.addEventListener("mousedown", (e) => {
  821. if (e.button !== 0) return;
  822. this.selected = !this.selected;
  823. this.element.el.style.backgroundColor = this.selected
  824. ? "lightgray"
  825. : "rgb(38, 38, 38)";
  826. handle_categories_selection(this.name);
  827. if (!this.selected) unload_modules(this.name);
  828. });
  829.  
  830. this.element.el.addEventListener("mouseover", () => {
  831. if (!this.selected) {
  832. this.element.el.style.backgroundColor = "rgb(58, 58, 58)";
  833. this.element.el.style.cursor = "pointer";
  834. }
  835. });
  836.  
  837. this.element.el.addEventListener("mouseout", () => {
  838. if (!this.selected)
  839. this.element.el.style.backgroundColor = "rgb(38, 38, 38)";
  840. });
  841. }
  842. unselect() {
  843. this.selected = false;
  844. this.element.el.style.backgroundColor = "rgb(38, 38, 38)";
  845. }
  846. }
  847.  
  848. //1travel
  849. let modules = {
  850. Info: {
  851. hall_of_Fame: new Module("Hall of Fame", "open", {
  852. darkdealer_00249: new Setting("darkdealer_00249", "title"),
  853. }),
  854. q_a1: new Module(
  855. "Where is the rest of the scripts?",
  856. "button",
  857. null,
  858. () => {
  859. alert(
  860. "They're patched, I can't make the bypass public for now, because it will be patched too"
  861. );
  862. }
  863. ),
  864. q_a2: new Module("Why no updates so long?", "button", null, () => {
  865. alert(
  866. "I had some things to do in the university + I was working on a big canvas API, that no longer works due to the patch"
  867. );
  868. }),
  869. q_a3: new Module(
  870. "I have a problem/question where can I contact you?",
  871. "button",
  872. null,
  873. () => {
  874. alert("Dm me on discord. My tag is: h3llside");
  875. }
  876. ),
  877. q_a4: new Module(
  878. "What will happen to Diep.io+ after Diep Police Department?",
  879. "button",
  880. null,
  881. () => {
  882. alert(`
  883. There are two possbile outcomes:
  884. 1. I will make it a Ghost client, meaning it will contain helpful functions that make your life easier, but don't give you any advantages public and move everything else to Addons (make it private) OR
  885. 2. I will make bannable cheats less detectable
  886. `);
  887. }
  888. ),
  889. q_a5: new Module(
  890. "I really want to have access for Addons, can I have it?",
  891. "button",
  892. null,
  893. () => {
  894. alert(`
  895. No, unless you give me something in return. For example some useful information for bypassing or someone's private script
  896. `);
  897. }
  898. ),
  899. q_a6: new Module(
  900. "I want you to make a script for me, can you do it?",
  901. "button",
  902. null,
  903. () => {
  904. alert(`
  905. If it's simple - yes. If not, well I want a reward then in any form, because my time and energy are limited, to waste hours on someone who wants some personalised script
  906. `);
  907. }
  908. ),
  909. },
  910.  
  911. Visual: {
  912. Key_inputs_visualiser: new Module("Key Inputs Visualiser", "toggle"),
  913. destroyer_cooldown: new Module("Destroyer Cooldown", "open", {
  914. Title: new Setting("Destroyer Cooldown", "title"),
  915. reload: new Setting("Reload?", "select", [0, 1, 2, 3, 4, 5, 6, 7]),
  916. destroyer_cooldown: new Setting("enable Destroyer Cooldown", "toggle"),
  917. }),
  918. },
  919.  
  920. Functional: {
  921. CopyLink: new Module("Copy Party Link", "button", null, () => {
  922. document.getElementById("copy-party-link").click();
  923. }),
  924. Predator_stack: new Module("Predator Stack", "button", null, () => {
  925. predator_stack(get_reload());
  926. }),
  927. Sandbox_lvl_up: new Module("Sandbox Auto Level Up", "toggle"),
  928. Auto_respawn: new Module("Auto Respawn", "open", {
  929. Title: new Setting("Auto Respawn", "title"),
  930. Remember: new Setting("Remember and store Killer Names", "toggle"),
  931. Prevent: new Setting("Prevent respawning after 300k score", "toggle"),
  932. Name: new Setting("Spawn Name Type: ", "select", [
  933. "Normal",
  934. "Glitched",
  935. "N A M E",
  936. "Random Killer",
  937. "Random Symbols",
  938. "Random Numbers",
  939. "Random Letters",
  940. ]),
  941. Auto_respawn: new Setting("Auto Respawn", "toggle"),
  942. }),
  943. Bot_tab: new Module("Sandbox Arena size increase", "toggle"),
  944. Tank_upgrades: new Module("Tank Upgrades Keybinds", "open", {
  945. Title: new Setting("Tank Upgrades Keybinds", "title"),
  946. visualise: new Setting("Show positions and keys", "toggle"),
  947. Tank_upgrades: new Setting("enable Tank Upgrades Keybinds", "toggle"),
  948. }),
  949. Zoom: new Module("Zoom Out", "slider"),
  950. },
  951.  
  952. Mouse: {
  953. Anti_aim: new Module("Anti Aim", "open", {
  954. Title: new Setting("Anti Aim", "title"),
  955. Timing: new Setting(
  956. "Follow mouse on click, how long?",
  957. "select",
  958. [50, 100, 150, 200, 250, 300]
  959. ),
  960. Anti_aim: new Setting("enable Anti Aim", "toggle"),
  961. }),
  962. Freeze_mouse: new Module("Freeze Mouse", "toggle"),
  963. Anti_timeout: new Module("Anti AFK Timeout", "toggle"),
  964. Move_2_mouse: new Module("Move to mouse", "open", {
  965. Title: new Setting("Move to mouse", "title"),
  966. Approximation: new Setting(
  967. "Approximation Factor (lower = smoother)",
  968. "select",
  969. [10, 25, 40, 65, 80, 100]
  970. ),
  971. Time_factor: new Setting(
  972. "Time Factor (higher = longer)",
  973. "select",
  974. [10, 20, 30, 40, 50]
  975. ),
  976. Move_2_mouse: new Setting("enable Move to Mouse", "toggle"),
  977. }),
  978. Custom_auto_spin: new Module("Custom Auto Spin", "open", {
  979. Title: new Setting("Custom Auto Spin", "title"),
  980. Interval: new Setting("Movement Interval", "select", [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2500, 3000, 3500, 4000, 5000, 10000]),
  981. Smoothness: new Setting("Smoothness", "select", [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),
  982. Replace_auto_spin: new Setting("replace Auto Spin", "toggle"),
  983. Custom_auto_spin: new Setting("enable Custom Auto Spin", "toggle"),
  984. }),
  985. },
  986.  
  987. DiepConsole: {
  988. con_toggle: new Module("Show/hide Diep Console", "toggle"),
  989. net_predict_movement: new Module("predict movement", "toggle"),
  990. Render: new Module("Render things", "open", {
  991. Title: new Setting("Rendering", "title"),
  992. ren_scoreboard: new Setting("Leaderboard", "toggle"),
  993. ren_scoreboard_names: new Setting("Scoreboard Names", "toggle"),
  994. ren_fps: new Setting("FPS", "toggle"),
  995. ren_upgrades: new Setting("Tank Upgrades", "toggle"),
  996. ren_stats: new Setting("Stat Upgrades", "toggle"),
  997. ren_names: new Setting("Names", "toggle"),
  998. }),
  999. //game builds
  1000. },
  1001.  
  1002. Addons: {},
  1003. };
  1004.  
  1005. console.log(modules);
  1006.  
  1007. let categories = [];
  1008.  
  1009. function create_categories() {
  1010. for (let key in modules) {
  1011. categories.push(new Category(key, modules[key]));
  1012. }
  1013. }
  1014. create_categories();
  1015.  
  1016. //loading / unloading modules
  1017. function load_modules(category_name) {
  1018. const current_category = categories.find(
  1019. (category) => category.name === category_name
  1020. );
  1021. for (let moduleName in current_category.modules) {
  1022. let module = current_category.modules[moduleName];
  1023. module.load();
  1024. if (module.type === "open" && module.active) module.loadSettings();
  1025. }
  1026. }
  1027.  
  1028. function unload_modules(category_name) {
  1029. const current_category = categories.find(
  1030. (category) => category.name === category_name
  1031. );
  1032. for (let moduleName in current_category.modules) {
  1033. let module = current_category.modules[moduleName];
  1034. module.unload();
  1035. module.unloadSettings();
  1036. }
  1037. }
  1038.  
  1039. function find_module_path(_name) {
  1040. for (let category in modules) {
  1041. for (let module in modules[category]) {
  1042. // Iterate over actual modules
  1043. if (modules[category][module].name === _name) {
  1044. return [category, module]; // Return actual category and module
  1045. }
  1046. }
  1047. }
  1048. return -1; // Return -1 if not found
  1049. }
  1050.  
  1051. function handle_categories_selection(current_name) {
  1052. categories.forEach((category) => {
  1053. if (category.name !== current_name && category.selected) {
  1054. category.unselect();
  1055. unload_modules(category.name);
  1056. }
  1057. });
  1058.  
  1059. load_modules(current_name);
  1060. }
  1061.  
  1062. function loadCategories() {
  1063. const categoryCont = document.querySelector("#sub-container-gray");
  1064. categories.forEach((category) =>
  1065. categoryCont.appendChild(category.element.el)
  1066. );
  1067. }
  1068.  
  1069. function load_selected() {
  1070. categories.forEach((category) => {
  1071. if (category.selected) {
  1072. load_modules(category.name);
  1073. }
  1074. });
  1075. }
  1076.  
  1077. function loadGUI() {
  1078. document.body.style.margin = "0";
  1079. document.body.style.display = "flex";
  1080. document.body.style.justifyContent = "left";
  1081.  
  1082. mainCont = new El("Main Cont", "div", "rgb(38, 38, 38)", "500px", "400px");
  1083. mainCont.setBorder("normal", "2px", "lime", "10px");
  1084. mainCont.el.style.display = "flex";
  1085. mainCont.el.style.minHeight = "min-content";
  1086. mainCont.el.style.flexDirection = "column";
  1087. mainCont.add(document.body);
  1088.  
  1089. header = new El("Headline Dp", "div", "transparent", "100%", "40px");
  1090. header.setBorder("bottom", "2px", "rgb(106, 173, 84)");
  1091. header.setText(
  1092. "Diep.io+ by r!PsAw (Hide GUI with J)",
  1093. "white",
  1094. "Calibri",
  1095. "bold",
  1096. "20px",
  1097. "2px",
  1098. "center",
  1099. "center"
  1100. );
  1101. header.add(mainCont.el);
  1102.  
  1103. const contentWrapper = document.createElement("div");
  1104. contentWrapper.style.display = "flex";
  1105. contentWrapper.style.gap = "10px";
  1106. contentWrapper.style.padding = "10px";
  1107. contentWrapper.style.flex = "1";
  1108. mainCont.el.appendChild(contentWrapper);
  1109.  
  1110. subContGray = new El(
  1111. "Sub Container Gray",
  1112. "div",
  1113. "transparent",
  1114. "100px",
  1115. "100%"
  1116. );
  1117. subContGray.el.style.display = "flex";
  1118. subContGray.el.style.flexDirection = "column";
  1119. subContGray.el.style.overflowY = "auto";
  1120. subContGray.add(contentWrapper);
  1121.  
  1122. subContBlack = new El("Sub Container Black", "div", "black", "360px", "100%");
  1123. subContBlack.el.style.display = "flex";
  1124. subContBlack.el.style.gap = "10px";
  1125. subContBlack.add(contentWrapper);
  1126.  
  1127. modCont = new El("Module Container", "div", "transparent", "50%", "100%");
  1128. modCont.el.style.display = "flex";
  1129. modCont.el.style.flexDirection = "column";
  1130. modCont.el.style.overflowY = "auto";
  1131. modCont.setBorder("right", "2px", "white");
  1132. modCont.add(subContBlack.el);
  1133.  
  1134. settCont = new El("Settings Container", "div", "transparent", "50%", "100%");
  1135. settCont.el.style.display = "flex";
  1136. settCont.el.style.flexDirection = "column";
  1137. settCont.el.style.overflowY = "auto";
  1138. settCont.add(subContBlack.el);
  1139.  
  1140. loadCategories();
  1141. load_selected();
  1142. }
  1143.  
  1144. loadGUI();
  1145. document.addEventListener("keydown", toggleGUI);
  1146.  
  1147. function toggleGUI(e) {
  1148. if (e.key === "j" || e.key === "J") {
  1149. if (mainCont.el) {
  1150. mainCont.remove(document.body);
  1151. mainCont.el = null;
  1152. } else {
  1153. loadGUI();
  1154. }
  1155. }
  1156. }
  1157.  
  1158.  
  1159. //actual logic
  1160.  
  1161. //allow user to interact with the gui while in game
  1162. Event.prototype.preventDefault = new Proxy(Event.prototype.preventDefault, {
  1163. apply: function(target, thisArgs, args){
  1164. //console.log(thisArgs.type);
  1165. if(thisArgs.type === "mousedown" || thisArgs.type === "mouseup") return; //console.log('successfully canceled');
  1166. return Reflect.apply(target, thisArgs, args);
  1167. }
  1168. });
  1169.  
  1170. //Move to Mouse
  1171. let approximation_factor = modules.Mouse.Move_2_mouse.settings.Approximation.selected; // Higher = faster movement, but less smooth Lower = slower movement, but more smooth
  1172. let distance_time_factor = modules.Mouse.Move_2_mouse.settings.Time_factor.selected; // transform the distance into Time
  1173. let moving_active = false;
  1174. let current_direction = 'none';
  1175.  
  1176. function calculate_distance(x1, y1, x2, y2) {
  1177. return Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
  1178. }
  1179.  
  1180. function get_mouse_move_steps() {
  1181. let center = { x: canvas.width / 2, y: canvas.height / 2 };
  1182. let target = { x: inputs.mouse.real.x, y: inputs.mouse.real.y };
  1183. let full_distance = calculate_distance(center.x, center.y, target.x, target.y);
  1184. let partial_distance = full_distance / approximation_factor;
  1185. let step = { x: (target.x - center.x) / partial_distance, y: (target.y - center.y) / partial_distance };
  1186. return step;
  1187. }
  1188.  
  1189. function move_in_direction(direction, time) {
  1190. moving_active = true;
  1191. current_direction = direction;
  1192. let directions = {
  1193. 'Up': 'KeyW',
  1194. 'Left': 'KeyA',
  1195. 'Down': 'KeyS',
  1196. 'Right': 'KeyD',
  1197. }
  1198. for (let _dir in directions) {
  1199. if (directions[_dir] === undefined) return console.warn("Invalid direction");
  1200. if (_dir === direction) {
  1201. extern.onKeyDown(diep_keys[directions[_dir]]);
  1202. } else {
  1203. extern.onKeyUp(diep_keys[directions[_dir]]);
  1204. }
  1205. }
  1206. setTimeout(() => {
  1207. moving_active = false;
  1208. }, time);
  1209. }
  1210.  
  1211. function move_to_mouse() {
  1212. window.requestAnimationFrame(move_to_mouse);
  1213. if (!modules.Mouse.Move_2_mouse.settings.Move_2_mouse.active || moving_active || !player.inGame || !document.hasFocus()) return;
  1214. //update factors
  1215. approximation_factor = modules.Mouse.Move_2_mouse.settings.Approximation.selected;
  1216. distance_time_factor = modules.Mouse.Move_2_mouse.settings.Time_factor.selected;
  1217. //logic
  1218. let step = get_mouse_move_steps();
  1219. let horizontal = step.x > 0 ? 'Right' : 'Left';
  1220. let vertical = step.y > 0 ? 'Down' : 'Up';
  1221.  
  1222. switch (current_direction) {
  1223. case "none":
  1224. move_in_direction(horizontal, Math.abs(step.x) * distance_time_factor);
  1225. break;
  1226. case 'Right':
  1227. move_in_direction(vertical, Math.abs(step.y) * distance_time_factor);
  1228. break;
  1229. case 'Left':
  1230. move_in_direction(vertical, Math.abs(step.y) * distance_time_factor);
  1231. break;
  1232. case 'Up':
  1233. move_in_direction(horizontal, Math.abs(step.x) * distance_time_factor);
  1234. break
  1235. case 'Down':
  1236. move_in_direction(horizontal, Math.abs(step.x) * distance_time_factor);
  1237. break
  1238. }
  1239. }
  1240. window.requestAnimationFrame(move_to_mouse);
  1241.  
  1242.  
  1243. // ]-[ HTML RELATED STUFF
  1244. let homescreen = document.getElementById("home-screen");
  1245. let ingamescreen = document.getElementById("in-game-screen");
  1246. let gameOverScreen = document.getElementById('game-over-screen');
  1247. let gameOverScreenContainer = document.querySelector("#game-over-screen > div > div.game-details > div:nth-child(1)");
  1248. function update_scale_option(selector, label, min, max) {
  1249. let element = document.querySelector(selector);
  1250. let label_element = element.closest("div").querySelector("span");
  1251. label_element.innerHTML = `[DIEP.IO+] ${label}`;
  1252. label_element.style.background = "black";
  1253. label_element.style.color = "purple";
  1254. element.min = min;
  1255. element.max = max;
  1256. }
  1257.  
  1258. function new_ranges_for_scales() {
  1259. update_scale_option("#subsetting-option-ui_scale", "UI Scale", '0.01', '1000');
  1260. update_scale_option("#subsetting-option-border_radius", "UI Border Radius", '0.01', '1000');
  1261. update_scale_option("#subsetting-option-border_intensity", "UI Border Intensity", '0.01', '1000');
  1262. }
  1263.  
  1264. new_ranges_for_scales();
  1265.  
  1266. //VISUAL TEAM SWITCH
  1267. //create container
  1268. let team_select_container = document.createElement("div");
  1269. team_select_container.classList.add("labelled");
  1270. team_select_container.id = "team-selector";
  1271. document.querySelector("#server-selector").appendChild(team_select_container);
  1272.  
  1273. //create Text "Team"
  1274. let team_select_label = document.createElement("label");
  1275. team_select_label.innerText = "[Diep.io+] Team Selector";
  1276. team_select_label.style.color = "purple";
  1277. team_select_label.style.backgroundColor = "black";
  1278. team_select_container.appendChild(team_select_label);
  1279.  
  1280. //create Selector
  1281. let team_select_selector = document.createElement("div");
  1282. team_select_selector.classList.add("selector");
  1283. team_select_container.appendChild(team_select_selector);
  1284.  
  1285. //create placeholder "Choose Team"
  1286. let teams_visibility = true;
  1287. let ph_div = document.createElement("div");
  1288. let ph_text_div = document.createElement("div");
  1289. let sel_state;
  1290. ph_text_div.classList.add("dropdown-label");
  1291. ph_text_div.innerHTML = "Choose Team";
  1292. ph_div.style.backgroundColor = "gray";
  1293. ph_div.classList.add("selected");
  1294. ph_div.addEventListener("click", () => {
  1295. //toggle Team List
  1296. toggle_team_list(teams_visibility);
  1297. teams_visibility = !teams_visibility;
  1298. });
  1299.  
  1300. team_select_selector.appendChild(ph_div);
  1301. ph_div.appendChild(document.createElement("div"));
  1302. ph_div.appendChild(ph_text_div);
  1303.  
  1304. // Create refresh button
  1305. /*
  1306. let refresh_btn = document.createElement("button");
  1307. refresh_btn.style.width = "30%";
  1308. refresh_btn.style.height = "10%";
  1309. refresh_btn.style.backgroundColor = "black";
  1310. refresh_btn.textContent = "Refresh";
  1311.  
  1312. refresh_btn.onclick = () => {
  1313. remove_previous_teams();
  1314. links_to_teams_GUI_convert();
  1315. };
  1316.  
  1317. team_select_container.appendChild(refresh_btn);
  1318. */
  1319.  
  1320. //create actual teams
  1321. let team_values = [];
  1322.  
  1323. function create_team_div(text, color, link) {
  1324. team_values.push(text);
  1325. let team_div = document.createElement("div");
  1326. let text_div = document.createElement("div");
  1327. let sel_state;
  1328. text_div.classList.add("dropdown-label");
  1329. text_div.innerHTML = text;
  1330. team_div.style.backgroundColor = color;
  1331. team_div.classList.add("unselected");
  1332. team_div.value = text;
  1333. team_div.addEventListener("click", () => {
  1334. const answer = confirm("You're about to open the link in a new tab, do you want to continue?");
  1335. if (answer) {
  1336. window.open(link, "_blank");
  1337. }
  1338. });
  1339.  
  1340. team_select_selector.appendChild(team_div);
  1341. team_div.appendChild(document.createElement("div"));
  1342. team_div.appendChild(text_div);
  1343. }
  1344.  
  1345. function toggle_team_list(boolean) {
  1346. if (boolean) {
  1347. //true
  1348. team_select_selector.classList.remove("selector");
  1349. team_select_selector.classList.add("selector-active");
  1350. } else {
  1351. //false
  1352. team_select_selector.classList.remove("selector-active");
  1353. team_select_selector.classList.add("selector");
  1354. }
  1355. }
  1356.  
  1357. //example
  1358. //create_team_div("RedTeam", "Red", "https://diep.io/");
  1359. //create_team_div("OrangeTeam", "Orange", "https://diep.io/");
  1360. //create_team_div("YellowTeam", "Yellow", "https://diep.io/");
  1361. function links_to_teams_GUI_convert() {
  1362. let gamemode = get_gamemode();
  1363. let lobby = get_your_lobby();
  1364. let links = get_links(gamemode, lobby);
  1365. let team_names = ["Team-Blue", "Team-Red", "Team-Purple", "Team-Green", "Teamless-Gamemode"];
  1366. let team_colors = ["blue", "red", "purple", "green", "orange"];
  1367. for (let i = 0; i < links.length; i++) {
  1368. !gamemode.includes("teams") ? create_team_div(team_names[team_names.length - 1], team_colors[team_colors.length - 1], links[0][1]) : create_team_div(team_names[i], team_colors[i], links[i][1]);
  1369. }
  1370. }
  1371.  
  1372. function remove_previous_teams() {
  1373. for (let i = team_select_selector.childNodes.length - 1; i >= 0; i--) {
  1374. console.log(team_select_selector);
  1375. let child = team_select_selector.childNodes[i];
  1376. if (child.nodeType === Node.ELEMENT_NODE && child.innerText !== "Choose Team") {
  1377. child.remove();
  1378. }
  1379. }
  1380. }
  1381.  
  1382. let party_link_info = {
  1383. old_link: null,
  1384. current_link: null
  1385. }
  1386. function detect_refresh(){
  1387. if(!party_link_info.old_link || !party_link_info.current_link) return;
  1388. party_link_info.current_link = window.lobby_ip + _c.party_link;
  1389. if(party_link_info.current_link != party_link_info.old_link){
  1390. console.log('Link change detected!');
  1391. remove_previous_teams();
  1392. links_to_teams_GUI_convert();
  1393. party_link_info.old_link = party_link_info.current_link;
  1394. }
  1395. }
  1396. setInterval(detect_refresh, 100);
  1397.  
  1398. function wait_For_Link() {
  1399. if (_c.party_link === '') {
  1400. setTimeout(() => {
  1401. console.log("[Diep.io+] LOADING...");
  1402. wait_For_Link();
  1403. }, 100);
  1404. } else {
  1405. console.log("[Diep.io+] link loaded!");
  1406. remove_previous_teams();
  1407. links_to_teams_GUI_convert();
  1408. party_link_info.current_link = window.lobby_ip + _c.party_link;
  1409. party_link_info.old_link = party_link_info.current_link;
  1410. }
  1411. }
  1412.  
  1413. wait_For_Link();
  1414.  
  1415. //detect gamemode
  1416. let gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  1417. let last_gamemode = localStorage.getItem(`[Diep.io+] last_gm`);
  1418. localStorage.setItem(`[Diep.io+] last_gm`, gamemode);
  1419.  
  1420. function check_gamemode() {
  1421. gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  1422. save_gm();
  1423. }
  1424.  
  1425. setInterval(check_gamemode, 250);
  1426.  
  1427. function save_gm() {
  1428. let saved_gm = localStorage.getItem(`[Diep.io+] last_gm`);
  1429. if (saved_gm != null && saved_gm != gamemode) {
  1430. last_gamemode = saved_gm;
  1431. }
  1432. saved_gm === null ? localStorage.setItem(`[Diep.io+] last_gm}`, gamemode) : null;
  1433. }
  1434.  
  1435. //personal best
  1436. let your_final_score = 0;
  1437. const personal_best = document.createElement('div');
  1438. const gameDetail = document.createElement('div');
  1439. const label = document.createElement('div');
  1440. //applying class
  1441. gameDetail.classList.add("game-detail");
  1442. label.classList.add("label");
  1443. personal_best.classList.add("value");
  1444. //text context
  1445. label.textContent = "Best:";
  1446. //adding to html
  1447. gameOverScreenContainer.appendChild(gameDetail);
  1448. gameDetail.appendChild(label);
  1449. gameDetail.appendChild(personal_best);
  1450.  
  1451. function load_ls() {
  1452. return localStorage.getItem(gamemode);
  1453. }
  1454.  
  1455. function save_ls() {
  1456. localStorage.setItem(gamemode, your_final_score);
  1457. }
  1458.  
  1459. function check_final_score() {
  1460. if (_c.screen_state === "game-over") {
  1461. your_final_score = _c.death_score;
  1462. let saved_score = parseFloat(load_ls());
  1463. personal_best.textContent = saved_score;
  1464. if (saved_score < your_final_score) {
  1465. personal_best.textContent = your_final_score;
  1466. save_ls();
  1467. }
  1468. }
  1469. }
  1470.  
  1471. setInterval(check_final_score, 100);
  1472.  
  1473. //remove annoying html elements
  1474. function instant_remove() {
  1475. // Define selectors for elements to remove
  1476. const selectors = [
  1477. "#cmpPersistentLink",
  1478. "#apes-io-promo",
  1479. "#apes-io-promo > img",
  1480. "#last-updated",
  1481. "#diep-io_300x250"
  1482. ];
  1483.  
  1484. // Remove each selected element
  1485. selectors.forEach(selector => {
  1486. const element = document.querySelector(selector);
  1487. if (element) {
  1488. element.remove();
  1489. }
  1490. });
  1491.  
  1492. // If all elements have been removed, clear the interval
  1493. if (selectors.every(selector => !document.querySelector(selector))) {
  1494. deep_debug("Removed all ads, quitting...");
  1495. clearInterval(interval);
  1496. }
  1497. }
  1498.  
  1499. // Set an interval to check for ads
  1500. const interval = setInterval(instant_remove, 100);
  1501.  
  1502. // ]-[
  1503.  
  1504. //Predator Stack
  1505. let predator_reloads = [
  1506. //0
  1507. {
  1508. scd2: 600,
  1509. scd3: 1000,
  1510. wcd1: 1500,
  1511. wcd2: 2900,
  1512. },
  1513. //1
  1514. {
  1515. scd2: 500,
  1516. scd3: 900,
  1517. wcd1: 1400,
  1518. wcd2: 2800,
  1519. },
  1520. //2
  1521. {
  1522. scd2: 500,
  1523. scd3: 900,
  1524. wcd1: 1200,
  1525. wcd2: 2400,
  1526. },
  1527. //3
  1528. {
  1529. scd2: 400,
  1530. scd3: 900,
  1531. wcd1: 1200,
  1532. wcd2: 2300,
  1533. },
  1534. //4
  1535. {
  1536. scd2: 400,
  1537. scd3: 900,
  1538. wcd1: 1000,
  1539. wcd2: 2000,
  1540. },
  1541. //5
  1542. {
  1543. scd2: 400,
  1544. scd3: 800,
  1545. wcd1: 900,
  1546. wcd2: 1800,
  1547. },
  1548. //6
  1549. {
  1550. scd2: 300,
  1551. scd3: 800,
  1552. wcd1: 900,
  1553. wcd2: 1750,
  1554. },
  1555. //7
  1556. {
  1557. scd2: 300,
  1558. scd3: 800,
  1559. wcd1: 750,
  1560. wcd2: 1500,
  1561. },
  1562. ];
  1563.  
  1564.  
  1565. function shoot(cooldown = 100) {
  1566. deep_debug("Shoot started!", cooldown);
  1567. extern.onKeyDown(36);
  1568. setTimeout(() => {
  1569. deep_debug("Ending Shoot!", cooldown);
  1570. extern.onKeyUp(36);
  1571. }, cooldown);
  1572. }
  1573.  
  1574. function get_reload(){
  1575. let arr = [...extern.get_convar("game_stats_build")];
  1576. let counter = 0;
  1577. let l = arr.length;
  1578. for(let i = 0; i < l; i++){
  1579. if(arr[i] === '7'){
  1580. counter++;
  1581. }
  1582. }
  1583. return counter;
  1584. }
  1585.  
  1586. function predator_stack(reload) {
  1587. deep_debug("func called");
  1588. let current = predator_reloads[reload];
  1589. deep_debug(current);
  1590. shoot();
  1591. setTimeout(() => {
  1592. shoot(current.scd2);
  1593. }, current.wcd1);
  1594. setTimeout(() => {
  1595. shoot(current.scd3);
  1596. }, current.wcd2);
  1597. }
  1598.  
  1599. //Bot tab
  1600.  
  1601. //iframe creation
  1602. function createInvisibleIframe(url) {
  1603. let existingIframe = document.getElementById('hiddenIframe');
  1604. if (existingIframe) {
  1605. return;
  1606. }
  1607.  
  1608. let iframe = document.createElement('iframe');
  1609. iframe.src = url;
  1610. iframe.id = 'hiddenIframe';
  1611. document.body.appendChild(iframe);
  1612. }
  1613.  
  1614. function removeIframe() {
  1615. let iframe = document.getElementById('hiddenIframe');
  1616. if (iframe) {
  1617. iframe.remove();
  1618. }
  1619. }
  1620.  
  1621. function bot_tab_active_check(){
  1622. if(modules.Functional.Bot_tab.active){
  1623. createInvisibleIframe(link(get_baseUrl(), get_your_lobby(), get_gamemode(), get_team()));
  1624. }else{
  1625. removeIframe();
  1626. }
  1627. }
  1628. setInterval(bot_tab_active_check, 1000);
  1629.  
  1630. //DiepConsole
  1631. function active_diepconsole_render_default(){
  1632. let defaults = ['ren_scoreboard', 'ren_upgrades', 'ren_stats', 'ren_names', 'ren_scoreboard_names'];
  1633. for(let _def of defaults){
  1634. let _setting = modules.DiepConsole.Render.settings[_def]
  1635. _setting.active = true;
  1636. }
  1637. }
  1638. active_diepconsole_render_default();
  1639.  
  1640. function handle_con_toggle(state){
  1641. if(!extern.isConActive() && state && player.inGame){
  1642. one_time_notification('canceled, due to a bug. Make sure to not enable it while in game', notification_rgbs.warning, 5000);
  1643. return;
  1644. }
  1645. if(extern.isConActive() != state){
  1646. extern.execute('con_toggle');
  1647. }
  1648. }
  1649.  
  1650. function update_diep_console(){
  1651. //Modules
  1652. for(let param in modules.DiepConsole){
  1653. let state = modules.DiepConsole[param].active;
  1654. if(param === "con_toggle"){
  1655. handle_con_toggle(state)
  1656. }else if(modules.DiepConsole[param].name != "Render things"){
  1657. extern.set_convar(param, state);
  1658. }
  1659. }
  1660. //Render Settings
  1661. for(let ren_param in modules.DiepConsole.Render.settings){
  1662. let state = modules.DiepConsole.Render.settings[ren_param].active;
  1663. if(modules.DiepConsole.Render.settings[ren_param].name != "Rendering"){
  1664. extern.set_convar(ren_param, state);
  1665. }
  1666. }
  1667. }
  1668. setInterval(update_diep_console, 100);
  1669.  
  1670.  
  1671. //////
  1672. //mouse functions
  1673.  
  1674. window.addEventListener('mousemove', function(event) {
  1675. inputs.mouse.real.x = event.clientX;
  1676. inputs.mouse.real.y = event.clientY;
  1677. });
  1678.  
  1679. window.addEventListener('mousedown', function(event) {
  1680. if (modules.Mouse.Anti_aim.settings.Anti_aim.active) {
  1681. if (inputs.mouse.shooting) {
  1682. return;
  1683. }
  1684. inputs.mouse.shooting = true;
  1685. pauseMouseMove();
  1686. //freezeMouseMove();
  1687. setTimeout(function() {
  1688. inputs.mouse.shooting = false;
  1689. mouse_move('extern', inputs.mouse.real.x, inputs.mouse.real.y);
  1690. click_at('extern', inputs.mouse.real.x, inputs.mouse.real.y);
  1691. }, modules.Mouse.Anti_aim.settings.Timing.selected);
  1692. };
  1693. });
  1694.  
  1695. function handle_mouse_functions() {
  1696. window.requestAnimationFrame(handle_mouse_functions);
  1697. if (!player.connected) {
  1698. return;
  1699. }
  1700. modules.Mouse.Freeze_mouse.active ? freezeMouseMove() : unfreezeMouseMove();
  1701. modules.Mouse.Anti_aim.settings.Anti_aim.active ? anti_aim("On") : anti_aim("Off");
  1702. }
  1703. window.requestAnimationFrame(handle_mouse_functions);
  1704.  
  1705. //anti aim
  1706. function detect_corner() {
  1707. deep_debug('corner detect called');
  1708. let w = window.innerWidth;
  1709. let h = window.innerHeight;
  1710. let center = {
  1711. x: w / 2,
  1712. y: h / 2
  1713. };
  1714. let lr, ud;
  1715. inputs.mouse.real.x > center.x ? lr = "r" : lr = "l";
  1716. inputs.mouse.real.y > center.y ? ud = "d" : ud = "u";
  1717. deep_debug('output: ', lr + ud);
  1718. return lr + ud;
  1719. }
  1720.  
  1721. function look_at_corner(corner) {
  1722. deep_debug('look at corner called with corner', corner);
  1723. if (!inputs.mouse.shooting) {
  1724. let w = window.innerWidth;
  1725. let h = window.innerHeight;
  1726. deep_debug('w and h', w, h);
  1727. deep_debug('inputs: ', inputs);
  1728. switch (corner) {
  1729. case "lu":
  1730. anti_aim_at('extern', w, h);
  1731. break
  1732. case "ld":
  1733. anti_aim_at('extern', w, 0);
  1734. break
  1735. case "ru":
  1736. anti_aim_at('extern', 0, h);
  1737. break
  1738. case "rd":
  1739. anti_aim_at('extern', 0, 0);
  1740. break
  1741. }
  1742. }
  1743. }
  1744.  
  1745. function anti_aim(toggle) {
  1746. deep_debug('anti aim called with:', toggle);
  1747. if(!player.inGame) return;
  1748. switch (toggle) {
  1749. case "On":
  1750. if (modules.Mouse.Anti_aim.settings.Anti_aim.active && !inputs.mouse.isFrozen) {
  1751. deep_debug('condition !modules.Mouse.Anti_aim.settings.active met');
  1752. look_at_corner(detect_corner());
  1753. }
  1754. break
  1755. case "Off":
  1756. //(inputs.mouse.isFrozen && !modules.Mouse.Freeze_mouse.active) ? unfreezeMouseMove() : null;
  1757. (inputs.mouse.isPaused && !modules.Mouse.Freeze_mouse.active) ? unpauseMouseMove() : null;
  1758. break
  1759. }
  1760. }
  1761.  
  1762. // Example: Freeze and unfreeze
  1763. function pauseMouseMove() {
  1764. if(!inputs.mouse.isPaused){
  1765. inputs.mouse.isForced = true;
  1766. inputs.mouse.force.x = inputs.mouse.real.x
  1767. inputs.mouse.force.y = inputs.mouse.real.y;
  1768. inputs.mouse.isPaused = true; //tell the script that freezing finished
  1769. }
  1770. }
  1771.  
  1772. function freezeMouseMove() {
  1773. if(!inputs.mouse.isFrozen){
  1774. inputs.mouse.isForced = true;
  1775. inputs.mouse.force.x = inputs.mouse.real.x
  1776. inputs.mouse.force.y = inputs.mouse.real.y;
  1777. inputs.mouse.isFrozen = true; //tell the script that freezing finished
  1778. }
  1779. /*
  1780. if (!inputs.mouse.isFrozen) {
  1781. inputs.mouse.isFrozen = true;
  1782. clear_onTouch();
  1783. deep_debug("Mousemove events are frozen.");
  1784. }
  1785. */
  1786. }
  1787.  
  1788. function unpauseMouseMove(){
  1789. if (inputs.mouse.isPaused && !inputs.mouse.isShooting) {
  1790. inputs.mouse.isForced = false;
  1791. inputs.mouse.isPaused = false; //tell the script that unfreezing finished
  1792. }
  1793. }
  1794.  
  1795. function unfreezeMouseMove() {
  1796. if (inputs.mouse.isFrozen) {
  1797. inputs.mouse.isForced = false;
  1798. inputs.mouse.isFrozen = false; //tell the script that unfreezing finished
  1799. }
  1800. /*
  1801. if (inputs.mouse.isFrozen && !inputs.mouse.isShooting) {
  1802. inputs.mouse.isFrozen = false;
  1803. redefine_onTouch();
  1804. deep_debug("Mousemove events are active.");
  1805. }
  1806. */
  1807. }
  1808.  
  1809. function click_at(input_or_extern, x, y, delay1 = 150, delay2 = 500) {
  1810. i_e(input_or_extern, 'onTouchStart', -1, x, y);
  1811. setTimeout(() => {
  1812. i_e(input_or_extern, 'onTouchEnd', -1, x, y);
  1813. }, delay1);
  1814. setTimeout(() => {
  1815. inputs.mouse.shooting = false;
  1816. }, delay2);
  1817. }
  1818.  
  1819. /* it was a bug and is now patched
  1820. function ghost_click_at(input_or_extern, x, y, delay1 = 150, delay2 = 500) {
  1821. i_e(input_or_extern, 'onTouchStart', -2, x, y);
  1822. setTimeout(() => {
  1823. i_e(input_or_extern, 'onTouchEnd', -2, x, y);
  1824. }, delay1);
  1825. setTimeout(() => {
  1826. inputs.mouse.shooting = false;
  1827. }, delay2);
  1828. }
  1829. */
  1830.  
  1831. function mouse_move(input_or_extern, x, y) {
  1832. deep_debug('mouse move called with', x, y);
  1833. apply_force(x, y);
  1834. i_e(input_or_extern, 'onTouchMove', -1, x, y);
  1835. disable_force();
  1836. }
  1837.  
  1838. function anti_aim_at(input_or_extern, x, y) {
  1839. deep_debug('frozen, shooting', inputs.mouse.isFrozen, inputs.mouse.isShooting);
  1840. deep_debug('anti aim at called with:', x, y);
  1841. if (inputs.mouse.shooting) {
  1842. deep_debug('quit because inputs.mouse.shooting');
  1843. return;
  1844. }
  1845. mouse_move(input_or_extern, x, y);
  1846. }
  1847. //////
  1848.  
  1849. //Custom Auto Spin
  1850. function getMouseAngle(x, y) {
  1851. const centerX = window.innerWidth / 2;
  1852. const centerY = window.innerHeight / 2;
  1853.  
  1854. const dx = x - centerX;
  1855. const dy = y - centerY;
  1856.  
  1857. let angle = Math.atan2(dy, dx) * (180 / Math.PI);
  1858.  
  1859. return angle < 0 ? angle + 360 : angle;
  1860. }
  1861.  
  1862. function offset_Angle(angle){
  1863. let _angle;
  1864. if(angle <= 360){
  1865. _angle = angle;
  1866. }else{
  1867. _angle = angle-360;
  1868. while(_angle > 360){
  1869. _angle -= 360;
  1870. }
  1871. }
  1872. return _angle;
  1873. }
  1874.  
  1875. function getPointOnCircle(degrees) {
  1876. const centerX = window.innerWidth / 2;
  1877. const centerY = window.innerHeight / 2;
  1878. const radius = Math.min(window.innerWidth, window.innerHeight) / 2;
  1879.  
  1880. const radians = degrees * (Math.PI / 180);
  1881. const x = centerX + radius * Math.cos(radians);
  1882. const y = centerY + radius * Math.sin(radians);
  1883.  
  1884. return { x:x, y:y };
  1885. }
  1886.  
  1887. let cas_force = false;
  1888. let cas_active = false;
  1889. let starting_angle = 0;
  1890. let temp_interval = setInterval(start_custom_spin, modules.Mouse.Custom_auto_spin.settings.Interval.selected);
  1891. function start_keyDown_Proxy(){
  1892. extern.onKeyDown = new Proxy(extern.onKeyDown, {
  1893. apply: function (target, thisArgs, args){
  1894. if(modules.Mouse.Custom_auto_spin.settings.Replace_auto_spin.active && args[0] === diep_keys.KeyC){
  1895. cas_active = !cas_active;
  1896. new_notification(`Custom Auto Spin: ${cas_active?'On':'Off'}`, notification_rgbs.normal, 4000);
  1897. return;
  1898. }
  1899. return Reflect.apply(target, thisArgs, args);
  1900. }
  1901. });
  1902. }
  1903.  
  1904. function start_custom_spin(){
  1905. clearInterval(temp_interval);
  1906. temp_interval = setInterval(start_custom_spin, modules.Mouse.Custom_auto_spin.settings.Interval.selected);
  1907. if(!player.inGame) return;
  1908. if(!modules.Mouse.Custom_auto_spin.settings.Replace_auto_spin.active) cas_active = modules.Mouse.Custom_auto_spin.settings.Custom_auto_spin.active;
  1909. if(!cas_active){
  1910. starting_angle = getMouseAngle(inputs.mouse.real.x, inputs.mouse.real.y);
  1911. if(inputs.mouse.isForced && cas_force){
  1912. disable_force();
  1913. cas_force = false;
  1914. }
  1915. }else{
  1916. cas_force = true;
  1917. let l = Math.pow(2, modules.Mouse.Custom_auto_spin.settings.Smoothness.selected);
  1918. let angle_peace = 360/l;
  1919. let time_peace = modules.Mouse.Custom_auto_spin.settings.Interval.selected/l;
  1920. for(let i = 0; i < l; i++){
  1921. setTimeout(() => {
  1922. let temp_angle = offset_Angle(starting_angle + angle_peace * i);
  1923. console.log('temp', temp_angle);
  1924. console.log('mouse', starting_angle);
  1925. let temp_coords = getPointOnCircle(temp_angle);
  1926. apply_force(temp_coords.x, temp_coords.y);
  1927. i_e('extern', 'onTouchMove', -1, temp_coords.x, temp_coords.y);
  1928. }, time_peace*i);
  1929. }
  1930. }
  1931. }
  1932.  
  1933. //Sandbox Auto Lvl up
  1934. function sandbox_lvl_up() {
  1935. if (modules.Functional.Sandbox_lvl_up.active && player.connected && player.inGame && player.gamemode === "sandbox") {
  1936. document.querySelector("#sandbox-max-level").click();
  1937. }
  1938. }
  1939. setInterval(sandbox_lvl_up, 500);
  1940.  
  1941. //START, autorespawn Module
  1942.  
  1943. //name saving logic
  1944. let killer_names = localStorage.getItem("[Diep.io+] saved names") ? JSON.parse(localStorage.getItem("[Diep.io+] saved names")) : ['r!PsAw', 'TestTank'];
  1945. let banned_names = ["Pentagon", "Triangle", "Square", "Crasher", "Mothership", "Guardian of Pentagons", "Fallen Booster", "Fallen Overlord", "Necromancer", "Defender", "Unnamed Tank"];
  1946. function check_and_save_name(){
  1947. deep_debug(_c.killer_name, !killer_names.includes(_c.killer_name));
  1948. if(_c.screen_state === 'game-over' && !banned_names.includes(_c.killer_name) && !killer_names.includes(_c.killer_name)){
  1949. deep_debug("Condition met!");
  1950. killer_names.push(_c.killer_name);
  1951. deep_debug("Added");
  1952. killer_names = [...new Set(killer_names)];
  1953. if(modules.Functional.Auto_respawn.settings.Remember.active){
  1954. localStorage.setItem("[Diep.io+] saved names", JSON.stringify(killer_names));
  1955. deep_debug("saved list");
  1956. }
  1957. }
  1958. }
  1959.  
  1960. function get_random_killer_name(){
  1961. let l = killer_names.length;
  1962. let index = Math.floor(Math.random() * l);
  1963. return killer_names[index];
  1964. }
  1965.  
  1966. //Random Symbols/Numbers/Letters
  1967. function generate_random_name_string(type){
  1968. let final_result = '';
  1969. let chars = '';
  1970. switch(type){
  1971. case "Symbols":
  1972. chars = '!@#$%^&*()_+=-.,][';
  1973. break
  1974. case "Numbers":
  1975. chars = '1234567890';
  1976. break
  1977. case "Letters":
  1978. chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  1979. break
  1980. }
  1981. for (let i = 0; i < 16; i++) {
  1982. final_result += chars[Math.floor(Math.random() * chars.length)];
  1983. }
  1984. return final_result;
  1985. }
  1986. //ascii inject
  1987. function get_ascii_inject(type){
  1988. let asciiArray = [];
  1989. switch(type){
  1990. case "Glitched":
  1991. asciiArray = [0x110000];
  1992. break
  1993. case "N A M E":
  1994. asciiArray = player.name.split("").flatMap(char => [char.charCodeAt(0), 10]).slice(0, -1);
  1995. break
  1996. }
  1997. let interesting = {
  1998. length: asciiArray.length,
  1999. charCodeAt(i) {
  2000. return asciiArray[i];
  2001. },
  2002. };
  2003. const argument = {
  2004. toString() {
  2005. return interesting;
  2006. },
  2007. };
  2008. return argument;
  2009. }
  2010.  
  2011. //main Loop
  2012. function get_respawn_name_by_type(type){
  2013. let temp_name = '';
  2014. switch(type){
  2015. case "Normal":
  2016. temp_name = player.name;
  2017. break
  2018. case "Glitched":
  2019. temp_name = get_ascii_inject(type);
  2020. break
  2021. case "N A M E":
  2022. temp_name = get_ascii_inject(type);
  2023. break
  2024. case "Random Killer":
  2025. temp_name = get_random_killer_name();
  2026. break
  2027. case "Random Symbols":
  2028. temp_name = generate_random_name_string('Symbols');
  2029. break
  2030. case "Random Numbers":
  2031. temp_name = generate_random_name_string('Numbers');
  2032. break
  2033. case "Random Letters":
  2034. temp_name = generate_random_name_string('Letters');
  2035. break
  2036. }
  2037. return temp_name;
  2038. }
  2039. function respawn() {
  2040. check_and_save_name();
  2041. if (modules.Functional.Auto_respawn.settings.Auto_respawn.active && player.connected && !player.inGame) {
  2042. //prevent respawn after 300k flag
  2043. if(modules.Functional.Auto_respawn.settings.Prevent.active && _c.death_score >= 300000){
  2044. return;
  2045. }
  2046. let type = modules.Functional.Auto_respawn.settings.Name.selected;
  2047. let temp_name = get_respawn_name_by_type(type);
  2048. extern.try_spawn(temp_name);
  2049. }
  2050. }
  2051.  
  2052. setInterval(respawn, 1000);
  2053.  
  2054. //END
  2055.  
  2056. //AntiAfk Timeout
  2057. function AntiAfkTimeout() {
  2058. if (modules.Mouse.Anti_timeout.active && player.connected) {
  2059. extern.onTouchMove(inputs.mouse.real.x, inputs.mouse.real.y);
  2060. }
  2061. }
  2062. setInterval(AntiAfkTimeout, 1000);
  2063.  
  2064. //Zoom
  2065. function start_zoom_proxy(){
  2066. input.setScreensizeZoom = new Proxy(input.setScreensizeZoom, {
  2067. apply: function(target, thisArgs, args){
  2068. player.base_value = args[1];
  2069. let factor = modules.Functional.Zoom.value / 100;
  2070. player.dpr = player.base_value * factor;
  2071. let newargs = [args[0], player.dpr];
  2072. return Reflect.apply(target, thisArgs, newargs);
  2073. }
  2074. });
  2075. }
  2076. function HandleZoom() {
  2077. if(player.connected){
  2078. //let base_value = 1;
  2079. //let factor = modules.Functional.Zoom.value / 100;
  2080. //player.dpr = base_value * factor;
  2081. let diepScale = player.base_value * Math.floor(player.ui_scale * windowScaling() * 25) / 25;
  2082. extern.setScreensizeZoom(diepScale, player.base_value);
  2083. extern.updateDPR(player.dpr);
  2084. }
  2085. }
  2086. setInterval(HandleZoom, 100);
  2087.  
  2088. //ctx helper functions
  2089. function ctx_arc(x, y, r, sAngle, eAngle, counterclockwise, c, stroke_or_fill = 'fill', _globalAlpha=1, _lineWidth = '2px') {
  2090. let original_ga = ctx.globalAlpha;
  2091. let original_lw = ctx.lineWidth;
  2092. ctx.beginPath();
  2093. ctx.arc(x, y, r, sAngle, eAngle, counterclockwise);
  2094. ctx.globalAlpha = _globalAlpha;
  2095. switch(stroke_or_fill){
  2096. case "fill":
  2097. ctx.fillStyle = c;
  2098. ctx.fill();
  2099. break
  2100. case "stroke":
  2101. ctx.lineWidth = _lineWidth;
  2102. ctx.strokeStyle = c;
  2103. ctx.stroke();
  2104. ctx.lineWidth = original_lw;
  2105. break
  2106. }
  2107. ctx.globalAlpha = original_ga;
  2108. }
  2109.  
  2110. function ctx_text(fcolor, scolor, lineWidth, font, text, textX, textY) {
  2111. deep_debug('called crx_text with: ', fcolor, scolor, lineWidth, font, text, textX, textY);
  2112. ctx.fillStyle = fcolor;
  2113. ctx.lineWidth = lineWidth;
  2114. ctx.font = font;
  2115. ctx.strokeStyle = scolor;
  2116. ctx.strokeText(`${text}`, textX, textY)
  2117. ctx.fillText(`${text}`, textX, textY)
  2118. }
  2119.  
  2120. function ctx_rect(x, y, a, b, c) {
  2121. deep_debug('called ctx_rect with: ', x, y, a, b, c);
  2122. ctx.beginPath();
  2123. ctx.strokeStyle = c;
  2124. ctx.strokeRect(x, y, a, b);
  2125. }
  2126.  
  2127. function transparent_rect_fill(x, y, a, b, scolor, fcolor, opacity){
  2128. deep_debug('called transparent_rect_fill with: ', x, y, a, b, scolor, fcolor, opacity);
  2129. ctx.beginPath();
  2130. ctx.rect(x, y, a, b);
  2131.  
  2132. // Set stroke opacity
  2133. ctx.globalAlpha = 1;// Reset to 1 for stroke, or set as needed
  2134. ctx.strokeStyle = scolor;
  2135. ctx.stroke();
  2136.  
  2137. // Set fill opacity
  2138. ctx.globalAlpha = opacity;// Set the opacity for the fill color
  2139. ctx.fillStyle = fcolor;
  2140. ctx.fill();
  2141.  
  2142. // Reset globalAlpha back to 1 for future operations
  2143. ctx.globalAlpha = 1;
  2144. }
  2145.  
  2146. //key visualiser
  2147. let ctx_wasd = {
  2148. square_sizes: { //in windowScaling
  2149. a: 50,
  2150. b: 50
  2151. },
  2152. text_props: {
  2153. lineWidth: 3,
  2154. font: 1 + "em Ubuntu",
  2155. },
  2156. square_colors: {
  2157. stroke: "black",
  2158. unpressed: "yellow",
  2159. pressed: "orange"
  2160. },
  2161. text_colors: {
  2162. stroke: "black",
  2163. unpressed: "orange",
  2164. pressed: "red"
  2165. },
  2166. w: {
  2167. x: 300,
  2168. y: 200,
  2169. pressed: false,
  2170. text: 'W'
  2171. },
  2172. a: {
  2173. x: 350,
  2174. y: 150,
  2175. pressed: false,
  2176. text: 'A'
  2177. },
  2178. s: {
  2179. x: 300,
  2180. y: 150,
  2181. pressed: false,
  2182. text: 'S'
  2183. },
  2184. d: {
  2185. x: 250,
  2186. y: 150,
  2187. pressed: false,
  2188. text: 'D'
  2189. },
  2190. l_m: {
  2191. x: 350,
  2192. y: 75,
  2193. pressed: false,
  2194. text: 'LMC'
  2195. },
  2196. r_m: {
  2197. x: 250,
  2198. y: 75,
  2199. pressed: false,
  2200. text: 'RMC'
  2201. },
  2202. }
  2203.  
  2204. function visualise_keys(){
  2205. let keys = ['w', 'a', 's', 'd', 'l_m', 'r_m'];
  2206. let l = keys.length;
  2207. for(let i = 0; i < l; i++){
  2208. let args = {
  2209. x: canvas.width - dim_c.windowScaling_2_canvas(ctx_wasd[keys[i]].x),
  2210. y: canvas.height - dim_c.windowScaling_2_canvas(ctx_wasd[keys[i]].y),
  2211. a: dim_c.windowScaling_2_canvas(ctx_wasd.square_sizes.a),
  2212. b: dim_c.windowScaling_2_canvas(ctx_wasd.square_sizes.b),
  2213. s_c: ctx_wasd.square_colors.stroke,
  2214. f_c: ctx_wasd[keys[i]].pressed? ctx_wasd.square_colors.pressed : ctx_wasd.square_colors.unpressed,
  2215. t_s: ctx_wasd.text_colors.stroke,
  2216. t_f: ctx_wasd[keys[i]].pressed? ctx_wasd.text_colors.pressed : ctx_wasd.text_colors.unpressed,
  2217. t_lineWidth: ctx_wasd.text_props.lineWidth,
  2218. t_font: ctx_wasd.text_props.font,
  2219. text: ctx_wasd[keys[i]].text,
  2220. opacity: 0.25
  2221. }
  2222. deep_debug(args);
  2223. transparent_rect_fill(
  2224. args.x,
  2225. args.y,
  2226. args.a,
  2227. args.b,
  2228. args.s_c,
  2229. args.f_c,
  2230. args.opacity
  2231. );
  2232. ctx_text(
  2233. args.t_f,
  2234. args.t_s,
  2235. args.t_lineWidth,
  2236. args.t_font,
  2237. args.text,
  2238. args.x+(args.a/2),
  2239. args.y+(args.b/2)
  2240. );
  2241. }
  2242. }
  2243.  
  2244. //Key Binds for Tank Upgrading
  2245. let selected_box = null;
  2246. let _bp = { //box parameters
  2247. startX: 47,
  2248. startY: 67,
  2249. distX: 13,
  2250. distY: 9,
  2251. width: 86,
  2252. height: 86,
  2253. outer_xy: 2
  2254. }
  2255.  
  2256. let _bo = { //box offsets
  2257. offsetX: _bp.width + (_bp.outer_xy * 2) + _bp.distX,
  2258. offsetY: _bp.height + (_bp.outer_xy * 2) + _bp.distY
  2259. }
  2260.  
  2261. function step_offset(steps, offset){
  2262. let final_offset = 0;
  2263. switch(offset){
  2264. case "x":
  2265. final_offset = _bp.startX + (steps * _bo.offsetX);
  2266. break
  2267. case "y":
  2268. final_offset = _bp.startY + (steps * _bo.offsetY);
  2269. break
  2270. }
  2271. return final_offset;
  2272. }
  2273.  
  2274. const boxes = [
  2275. {
  2276. color: "lightblue",
  2277. LUcornerX: _bp.startX,
  2278. LUcornerY: _bp.startY,
  2279. KeyBind: "R"
  2280. },
  2281. {
  2282. color: "green",
  2283. LUcornerX: _bp.startX + _bo.offsetX,
  2284. LUcornerY: _bp.startY,
  2285. KeyBind: "T"
  2286. },
  2287. {
  2288. color: "red",
  2289. LUcornerX: _bp.startX,
  2290. LUcornerY: _bp.startY + _bo.offsetY,
  2291. KeyBind: "F"
  2292. },
  2293. {
  2294. color: "yellow",
  2295. LUcornerX: _bp.startX + _bo.offsetX,
  2296. LUcornerY: _bp.startY + _bo.offsetY,
  2297. KeyBind: "G"
  2298. },
  2299. {
  2300. color: "blue",
  2301. LUcornerX: _bp.startX,
  2302. LUcornerY: step_offset(2, "y"),
  2303. KeyBind: "V"
  2304. },
  2305. {
  2306. color: "purple",
  2307. LUcornerX: _bp.startX + _bo.offsetX,
  2308. LUcornerY: step_offset(2, "y"),
  2309. KeyBind: "B"
  2310. }
  2311. ]
  2312.  
  2313. //upgrading Tank logic
  2314. function upgrade_get_coords(color){
  2315. let l = boxes.length;
  2316. let upgrade_coords = {x: "not defined", y: "not defined"};
  2317. for(let i = 0; i < l; i++){
  2318. if(boxes[i].color === color){
  2319. upgrade_coords.x = dim_c.windowScaling_2_window(boxes[i].LUcornerX + (_bp.width/2));
  2320. upgrade_coords.y = dim_c.windowScaling_2_window(boxes[i].LUcornerY + (_bp.height/2));
  2321. }
  2322. }
  2323. deep_debug(upgrade_coords);
  2324. return upgrade_coords;
  2325. }
  2326.  
  2327. function upgrade(color, delay = 100, cdelay1, cdelay2){
  2328. let u_coords = upgrade_get_coords(color);
  2329. //ghost_click_at('extern', u_coords.x, u_coords.y, cdelay1, cdelay2);
  2330. click_at('extern', u_coords.x, u_coords.y, cdelay1, cdelay2); //using this since ghost_click was patched
  2331. }
  2332.  
  2333. function visualise_tank_upgrades(){
  2334. let l = boxes.length;
  2335. for (let i = 0; i < l; i++) {
  2336. let coords = upgrade_get_coords(boxes[i].color);
  2337. ctx_text(boxes[i].color, "black", 6, 1.5 + "em Ubuntu", `[${boxes[i].KeyBind}]`, coords.x, coords.y);
  2338. }
  2339. }
  2340.  
  2341. function check_tu_KeyBind(_KeyBind){
  2342. let l = boxes.length;
  2343. for (let i = 0; i < l; i++) {
  2344. if(_KeyBind === `Key${boxes[i].KeyBind}`){
  2345. deep_debug(_KeyBind, `Key${boxes[i].KeyBind}`, _KeyBind === `Key${boxes[i].KeyBind}`);
  2346. upgrade(boxes[i].color);
  2347. }
  2348. }
  2349. }
  2350.  
  2351. document.body.addEventListener("keydown", function(e) {
  2352. switch(e.code){
  2353. case "KeyW":
  2354. ctx_wasd.w.pressed = true;
  2355. break
  2356. case "KeyA":
  2357. ctx_wasd.a.pressed = true;
  2358. break
  2359. case "KeyS":
  2360. ctx_wasd.s.pressed = true;
  2361. break
  2362. case "KeyD":
  2363. ctx_wasd.d.pressed = true;
  2364. break
  2365. }
  2366. if(modules.Functional.Tank_upgrades.settings.Tank_upgrades.active){
  2367. check_tu_KeyBind(e.code);
  2368. }
  2369. });
  2370.  
  2371. document.body.addEventListener("keyup", function(e) {
  2372. deep_debug(`unpressed ${e.code}`);
  2373. switch(e.code){
  2374. case "KeyW":
  2375. ctx_wasd.w.pressed = false;
  2376. break
  2377. case "KeyA":
  2378. ctx_wasd.a.pressed = false;
  2379. break
  2380. case "KeyS":
  2381. ctx_wasd.s.pressed = false;
  2382. break
  2383. case "KeyD":
  2384. ctx_wasd.d.pressed = false;
  2385. break
  2386. }
  2387. deep_debug('====DID UNPRESS??', ctx_wasd.w.pressed, ctx_wasd.a.pressed, ctx_wasd.s.pressed, ctx_wasd.d.pressed);
  2388. });
  2389.  
  2390. document.body.addEventListener("mousedown", function(e) {
  2391. switch(e.button){
  2392. case 0:
  2393. ctx_wasd.l_m.pressed = true;
  2394. break
  2395. case 2:
  2396. ctx_wasd.r_m.pressed = true;
  2397. break
  2398. }
  2399. });
  2400.  
  2401. document.body.addEventListener("mouseup", function(e) {
  2402. switch(e.button){
  2403. case 0:
  2404. ctx_wasd.l_m.pressed = false;
  2405. break
  2406. case 2:
  2407. ctx_wasd.r_m.pressed = false;
  2408. break
  2409. }
  2410. });
  2411. //destroyer cooldown visualiser
  2412. let times_watcher = {
  2413. waiting: false,
  2414. cooldowns: [2540, 2311, 2201, 1911, 1760, 1681, 1560, 1381],
  2415. }
  2416.  
  2417. function draw_destroyer_cooldown(){
  2418. let c = times_watcher.waiting? 'red' : 'lime' ;
  2419. ctx_arc(inputs.mouse.real.x, inputs.mouse.real.y, 50*player.dpr, 0, 2 * Math.PI, false, c, 'fill', 0.3);
  2420. }
  2421.  
  2422. function handle_cooldown(_cd){
  2423. times_watcher.waiting = true;
  2424. setTimeout(() => {
  2425. times_watcher.waiting = false;
  2426. }, _cd);
  2427. }
  2428. document.body.addEventListener("mousedown", function(e) {
  2429. if(e.button === 0 && !times_watcher.waiting && player.inGame){
  2430. let _cd = times_watcher.cooldowns[modules.Visual.destroyer_cooldown.settings.reload.selected];
  2431. handle_cooldown(_cd);
  2432. }
  2433. });
  2434.  
  2435. document.body.addEventListener("keydown", function(e){
  2436. if(e.keyCode === 32 && !times_watcher.waiting && player.inGame){
  2437. let _cd = times_watcher.cooldowns[modules.Visual.destroyer_cooldown.settings.reload.selected];
  2438. handle_cooldown(_cd);
  2439. }
  2440. });
  2441.  
  2442. //debug function
  2443. function draw_canvas_debug(){
  2444. let temp_textX = canvas.width/2, temp_textY = canvas.height/2;
  2445. let temp_texts = [
  2446. `Your Real mouse position! x: ${inputs.mouse.real.x} y: ${inputs.mouse.real.y}`,
  2447. `Scaled down for the game! x: ${(inputs.mouse.game.x).toFixed(2)} y: ${(inputs.mouse.game.y).toFixed(2)}`,
  2448. `player values! DPR: ${player.dpr} base value: ${player.base_value} ui scale: ${player.ui_scale}`,
  2449. `window Scaling: ${windowScaling()}`,
  2450. `Canvas! width: ${canvas.width} height: ${canvas.height}`,
  2451. `Window! width: ${window.innerWidth} height: ${window.innerHeight}`,
  2452. `Ratio between Window and Canvas: ${dim_c.window_2_canvas(1)}`
  2453. ];
  2454. let l = temp_texts.length;
  2455. let _d = (canvas.height/3)/l;
  2456. for(let i = 0; i < l; i++){
  2457. ctx_text('yellow', 'black', 5, 1.5 + "em Ubuntu", temp_texts[i], temp_textX, temp_textY + (i * _d));
  2458. }
  2459. //drawing line from your real mouse position, to your ingame mouse position
  2460. ctx.beginPath();
  2461. ctx.strokeStyle = "Red";
  2462. ctx.moveTo(inputs.mouse.real.x, inputs.mouse.real.y);
  2463. ctx.lineTo(inputs.mouse.game.x*player.dpr, inputs.mouse.game.y*player.dpr);
  2464. ctx.stroke();
  2465. }
  2466.  
  2467. //canvas gui (try to keep this in the end
  2468. setTimeout(() => {
  2469. let gui = () => {
  2470. if (player.inGame) {
  2471. //DEBUG start
  2472. if(deep_debug_properties.canvas){
  2473. draw_canvas_debug();
  2474. }
  2475. //DEBUG end
  2476. if(modules.Functional.Tank_upgrades.settings.visualise.active){
  2477. visualise_tank_upgrades();
  2478. }
  2479. if (modules.Visual.Key_inputs_visualiser.active) {
  2480. visualise_keys();
  2481. }
  2482. if (modules.Visual.destroyer_cooldown.settings.destroyer_cooldown.active){
  2483. draw_destroyer_cooldown();
  2484. }
  2485. }
  2486. window.requestAnimationFrame(gui); // Start animation loop
  2487. };
  2488. gui();
  2489. }, 500); // Delay before starting the rendering
  2490.  
  2491. //init
  2492.  
  2493. function update_information() {
  2494. window.requestAnimationFrame(update_information);
  2495. let teams = ["blue", "red", "purple", "green"];
  2496. player.connected = !!window.lobby_ip;
  2497. player.connected? player.inGame = !!extern.doesHaveTank() : null;
  2498. player.name = document.getElementById("spawn-nickname").value;
  2499. player.team = teams[parseInt(_c.party_link.split('x')[1])];
  2500. player.gamemode = _c.active_gamemode;
  2501. player.ui_scale = parseFloat(localStorage.getItem("d:ui_scale"));
  2502. }
  2503. window.requestAnimationFrame(update_information);
  2504.  
  2505. function waitForConnection() {
  2506. if (player.connected) {
  2507. define_onTouch();
  2508. start_input_proxies();
  2509. start_zoom_proxy();
  2510. start_keyDown_Proxy()
  2511. } else {
  2512. setTimeout(waitForConnection, 100);
  2513. }
  2514. }
  2515. waitForConnection();