Diep.io+ (added Trashbin & World coords)

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

  1. // ==UserScript==
  2. // @name Diep.io+ (added Trashbin & World coords)
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.2.8.1
  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, Tank Aim lines, Farm Bot
  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 Mi300 don't steal my scripts ;)
  11. // ==/UserScript==
  12.  
  13. const fingerprint = {sdfouhi152037892348iuaosfhuiasfDAJSP: 'This Object exists to differentiate between user inputs and script inputs since both use same functions'};
  14.  
  15. //inner script settings
  16. let deep_debug_properties = {
  17. active: false, //display information in console
  18. canvas: false, //display information on screen
  19. }
  20.  
  21. function deep_debug(...args) {
  22. if (deep_debug_properties.active) {
  23. console.log(...args);
  24. }
  25. }
  26.  
  27. //Information for script
  28. let _c = window.__common__;
  29. function is_fullscreen(){
  30. return ((window.innerHeight == screen.height) && (window.innerWidth == screen.width));
  31. }
  32.  
  33. const diep_keys = [ //document has to be focused to execute these, also C and E don't work right now
  34. "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",
  35. "ArrowUp", "ArrowLeft", "ArrowDown", "ArrowRight", "Tab", "Enter", "NumpadEnter", "ShiftLeft", "ShiftRight", "Space", "Numpad0", "Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9",
  36. "Digit0", "Digit1", "Digit2", "Digit3", "Digit4", "Digit5", "Digit6", "Digit7", "Digit8", "Digit9", "F2", "End", "Home", "Semicolon", "Comma", "NumpadComma", "Period", "Backslash"
  37. ].reduce((n, e, c) => {
  38. n[e] = c + 1;
  39. return n;
  40. }, {});
  41.  
  42. let player = {
  43. connected: false,
  44. inGame: false,
  45. name: '',
  46. team: null,
  47. gamemode: null,
  48. ui_scale: 1,
  49. dpr: 1,
  50. base_value: 1,
  51. };
  52.  
  53. let inputs = {
  54. mouse: {
  55. real: {
  56. x: 0,
  57. y: 0,
  58. },
  59. game: {
  60. x: 0,
  61. y: 0,
  62. },
  63. force: {
  64. x: 0,
  65. y: 0,
  66. },
  67. isForced: false, //input mouse operations flag (overwrites your inputs to forced one's)
  68. isFrozen: false, //Mouse Freeze flag
  69. isShooting: false, //Anti Aim flag
  70. isPaused: false, //Anti Aim flag (different from isFrozen & isForced for better readability)
  71. original: {
  72. onTouchMove: null,
  73. onTouchStart: null,
  74. onTouchEnd: null,
  75. }
  76. },
  77. moving_game: {
  78. KeyW: false,
  79. KeyA: false,
  80. KeyS: false,
  81. KeyD: false,
  82. ArrowUp: false,
  83. ArrowRight: false,
  84. ArrowDown: false,
  85. ArrowLeft: false,
  86. },
  87. moving_real: {
  88. KeyW: false,
  89. KeyA: false,
  90. KeyS: false,
  91. KeyD: false,
  92. ArrowUp: false,
  93. ArrowRight: false,
  94. ArrowDown: false,
  95. ArrowLeft: false,
  96. },
  97. keys_pressed: [],
  98. };
  99.  
  100. function windowScaling() {
  101. const a = canvas.height / 1080;
  102. const b = canvas.width / 1920;
  103. return b < a ? a : b;
  104. }
  105.  
  106. //basic function to construct links
  107. function link(baseUrl, lobby, gamemode, team) {
  108. let str = "";
  109. str += baseUrl + "?s=" + lobby + "&g=" + gamemode + "&l=" + team;
  110. return str;
  111. }
  112.  
  113. function get_baseUrl() {
  114. return location.origin + location.pathname;
  115. }
  116.  
  117. function get_your_lobby() {
  118. return window.lobby_ip;
  119. }
  120.  
  121. function get_gamemode() {
  122. //return window.__common__.active_gamemode;
  123. return window.lobby_gamemode;
  124. }
  125.  
  126. function get_team() {
  127. return window.__common__.party_link;
  128. }
  129.  
  130. //all team links
  131. function get_links(gamemode, lobby, team = get_team()) {
  132. let baseUrl = get_baseUrl();
  133. let colors = ["🔵", "🔴", "🟣", "🟢", "👥❌"];
  134. let final_links = [];
  135. switch (gamemode) {
  136. case "4teams":
  137. for (let i = 0; i < 4; i++) {
  138. final_links.push([colors[i], link(baseUrl, lobby, gamemode, team.split("x")[0] + `x${i}`)]);
  139. }
  140. break
  141. case "teams":
  142. for (let i = 0; i < 2; i++) {
  143. final_links.push([colors[i], link(baseUrl, lobby, gamemode, team.split("x")[0] + `x${i}`)]);
  144. }
  145. break
  146. default:
  147. final_links.push([colors[colors.length - 1], link(baseUrl, lobby, gamemode, team)]);
  148. }
  149. return final_links;
  150. }
  151.  
  152. //dimensions
  153.  
  154. class dimensions_converter {
  155. constructor() {
  156. this.scalingFactor = null; //undetectable without bypass
  157. this.fieldFactor = null; //undetectable without bypass
  158. }
  159. canvas_2_window(a) {
  160. let b = a / (canvas.width / window.innerWidth);
  161. return b;
  162. }
  163.  
  164. window_2_canvas(a) {
  165. let b = a * (canvas.width / window.innerWidth);
  166. return b;
  167. }
  168.  
  169. windowScaling_2_window(a) {
  170. let b = (this.windowScaling_2_canvas(a)) / (canvas.width / window.innerWidth);
  171. return b;
  172. }
  173.  
  174. windowScaling_2_canvas(a) {
  175. let b = a * windowScaling();
  176. deep_debug('windowScaling_2_canvas called! a, b', a, b);
  177. return b;
  178. }
  179. /* DISABLED FOR NOW
  180. diepUnits_2_canvas(a) {
  181. let b = a / scalingFactor;
  182. return b;
  183. }
  184.  
  185. diepUnits_2_window(a) {
  186. let b = (this.diepUnits_2_canvas(a)) / (canvas.width / window.innerWidth);
  187. return b;
  188. }
  189.  
  190. window_2_diepUnits(a) {
  191. let b = (this.canvas_2_diepUnits(a)) * (canvas.width / window.innerWidth);
  192. return b;
  193. }
  194.  
  195. canvas_2_diepUnits(a) {
  196. let b = a * this.scalingFactor;
  197. return b;
  198. }
  199. */
  200.  
  201. window_2_windowScaling(a) {
  202. let b = (this.canvas_2_windowScaling(a)) * (canvas.width / window.innerWidth) * player.ui_scale;
  203. return b;
  204. }
  205.  
  206. canvas_2_windowScaling(a) {
  207. let b = a * windowScaling();
  208. return b;
  209. }
  210. /* DISABLED FOR NOW
  211. diepUnits_2_windowScaling(a) {
  212. let b = (this.diepUnits_2_canvas(a)) * this.fieldFactor;
  213. return b;
  214. }
  215.  
  216. windowScaling_2_diepUntis(a) {
  217. let b = (a / this.fieldFactor) * this.scalingFactor;
  218. return b;
  219. }
  220. */
  221. }
  222.  
  223. let dim_c = new dimensions_converter();
  224.  
  225. function i_e(type, key, ...args) {
  226. switch (type) {
  227. case "input":
  228. input[key](...args);
  229. break
  230. case "extern":
  231. extern[key](...args);
  232. break
  233. }
  234. }
  235.  
  236. function apply_force(x, y) {
  237. inputs.mouse.force = {
  238. x: x,
  239. y: y,
  240. }
  241. inputs.mouse.isForced = true;
  242. }
  243.  
  244. function disable_force() {
  245. inputs.mouse.isForced = false;
  246. }
  247.  
  248. const touchMethods = ['onTouchMove', 'onTouchStart', 'onTouchEnd'];
  249. let canvas = document.getElementById("canvas");
  250. let ctx = canvas.getContext('2d');
  251.  
  252. function define_onTouch() {
  253. touchMethods.forEach(function(method) {
  254. inputs.mouse.original[method] = input[method];
  255. deep_debug('defined input.', method);
  256. });
  257. }
  258.  
  259. function clear_onTouch() {
  260. touchMethods.forEach(function(method) {
  261. input[method] = () => {};
  262. });
  263. }
  264.  
  265. function redefine_onTouch() {
  266. touchMethods.forEach(function(method) {
  267. input[method] = inputs.mouse.original[method];
  268. });
  269. }
  270.  
  271. function start_input_proxies(_filter = false, _single = false, _method = null) {
  272. ((_filter || _single) && !_method) ? console.warn("missing _method at start_input_proxies"): null;
  273. let temp_methods = touchMethods;
  274. if (_filter) {
  275. temp_methods.filter((item) => item != _method);
  276. } else if (_single) {
  277. temp_methods = [_method];
  278. }
  279. temp_methods.forEach(function(method) {
  280. input[method] = new Proxy(input[method], {
  281. apply: function(definition, input_obj, args) {
  282. let x, y, type, new_args;
  283. if (inputs.mouse.isForced) {
  284. x = inputs.mouse.force.x;
  285. y = inputs.mouse.force.y;
  286. } else {
  287. x = args[1];
  288. y = args[2];
  289. }
  290. type = args[0];
  291. new_args = [type, dim_c.window_2_canvas(x / player.dpr), dim_c.window_2_canvas(y / player.dpr)];
  292. inputs.mouse.game = {
  293. x: new_args[1],
  294. y: new_args[2],
  295. }
  296. return Reflect.apply(definition, input_obj, new_args);
  297. }
  298. });
  299. });
  300. }
  301.  
  302. //create ingame Notifications
  303. function rgbToNumber(r, g, b) {
  304. return (r << 16) | (g << 8) | b;
  305. }
  306. const notification_rgbs = {
  307. require: [255, 165, 0], //orange
  308. warning: [255, 0, 0], //red
  309. normal: [0, 0, 128] //blue
  310. }
  311.  
  312. let notifications = [];
  313.  
  314. function new_notification(text, color, duration) {
  315. input.inGameNotification(text, rgbToNumber(...color), duration);
  316. }
  317.  
  318. function one_time_notification(text, color, duration){
  319. if(notifications.includes(text)){
  320. return;
  321. }
  322. if(player.inGame){
  323. new_notification(text, color, duration);
  324. notifications.push(text);
  325. }else{
  326. notifications = [];
  327. }
  328. }
  329.  
  330. //GUI
  331. function n2id(string) {
  332. return string.toLowerCase().replace(/ /g, "-");
  333. }
  334.  
  335. class El {
  336. constructor(
  337. name,
  338. type,
  339. el_color,
  340. width,
  341. height,
  342. opacity = "1",
  343. zindex = "100"
  344. ) {
  345. this.el = document.createElement(type);
  346. this.el.style.backgroundColor = el_color;
  347. this.el.style.width = width;
  348. this.el.style.height = height;
  349. this.el.style.opacity = opacity;
  350. this.el.style.zIndex = zindex;
  351. this.el.id = n2id(name);
  352. this.display = "block"; // store default display
  353. }
  354.  
  355. setBorder(type, width, color, radius = 0) {
  356. const borderStyle = `${width} solid ${color}`;
  357. switch (type) {
  358. case "normal":
  359. this.el.style.border = borderStyle;
  360. break;
  361. case "top":
  362. this.el.style.borderTop = borderStyle;
  363. break;
  364. case "left":
  365. this.el.style.borderLeft = borderStyle;
  366. break;
  367. case "right":
  368. this.el.style.borderRight = borderStyle;
  369. break;
  370. case "bottom":
  371. this.el.style.borderBottom = borderStyle;
  372. break;
  373. }
  374. this.el.style.borderRadius = radius;
  375. }
  376.  
  377. setPosition(
  378. position,
  379. display,
  380. top,
  381. left,
  382. flexDirection,
  383. justifyContent,
  384. translate
  385. ) {
  386. this.el.style.position = position;
  387. this.el.style.display = display;
  388. if (top) this.el.style.top = top;
  389. if (left) this.el.style.left = left;
  390. // Flex properties
  391. if (flexDirection) this.el.style.flexDirection = flexDirection;
  392. if (justifyContent) this.el.style.justifyContent = justifyContent;
  393. if (translate) this.el.style.transform = `translate(${translate})`;
  394. this.display = display;
  395. }
  396.  
  397. margin(top, left, right, bottom) {
  398. this.el.style.margin = `${top} ${right} ${bottom} ${left}`;
  399. }
  400.  
  401. setText(
  402. text,
  403. txtColor,
  404. font,
  405. weight,
  406. fontSize,
  407. stroke,
  408. alignContent,
  409. textAlign
  410. ) {
  411. this.el.innerHTML = text;
  412. this.el.style.color = txtColor;
  413. this.el.style.fontFamily = font;
  414. this.el.style.fontWeight = weight;
  415. this.el.style.fontSize = fontSize;
  416. this.el.style.textShadow = stroke;
  417. this.el.style.alignContent = alignContent;
  418. this.el.style.textAlign = textAlign;
  419. }
  420.  
  421. add(parent) {
  422. parent.appendChild(this.el);
  423. }
  424.  
  425. remove(parent) {
  426. parent.removeChild(this.el);
  427. }
  428.  
  429. toggle(showOrHide) {
  430. this.el.style.display = showOrHide === "hide" ? "none" : this.display;
  431. }
  432. }
  433.  
  434. let mainCont,
  435. header,
  436. subContGray,
  437. subContBlack,
  438. modCont,
  439. settCont,
  440. activeCategory;
  441.  
  442. //logic for saving
  443. let trashed_module_names = (() => {
  444. const saved = localStorage.getItem("[Diep.io+] Trashed names");
  445. if (saved) {
  446. return new Set(JSON.parse(saved));
  447. }
  448. return new Set();
  449. })();
  450.  
  451. let saved_trash_content = [];
  452.  
  453. class Trashbin {
  454. constructor(trash_content) {
  455. this.active = {
  456. trashbin: false,
  457. mover: false,
  458. };
  459. this.trash_content = trash_content;
  460. //element creation
  461.  
  462. //outside
  463. this.trash_container = new El(
  464. "TrashBin Container",
  465. "div",
  466. "rgb(100, 0, 0)",
  467. "100%",
  468. "50px"
  469. );
  470. this.trash_container.setPosition("sticky", "flex", "0", "0", "row");
  471. this.trash_container.el.style.overflowX = "auto";
  472. this.trash_container.el.style.overflowY = "hidden";
  473. this.trash_container.el.style.paddingBottom = "20px";
  474.  
  475. //inside
  476. let temp_cont = new El(
  477. "TrashBinContainer",
  478. "div",
  479. "transparent",
  480. "90px",
  481. "50px"
  482. );
  483. let trashbin = new El("TrashBin", "div", "transparent", "45px", "50px");
  484. trashbin.setPosition("relative", "inline-block");
  485. trashbin.setText(
  486. `${this.trash_content.length}🗑️`,
  487. "white",
  488. "Calibri",
  489. "bold",
  490. "20px",
  491. "2px",
  492. "center",
  493. "center"
  494. );
  495. trashbin.setBorder("normal", "0px", "transparent", "10px");
  496. trashbin.el.addEventListener("mouseover", (e) => {
  497. trashbin.el.style.cursor = "pointer";
  498. trashbin.el.style.backgroundColor = this.active.trashbin
  499. ? "rgb(200, 0, 0)"
  500. : "rgb(50, 0, 0)";
  501. });
  502. trashbin.el.addEventListener("mouseout", (e) => {
  503. trashbin.el.style.cursor = "normal";
  504. trashbin.el.style.backgroundColor = this.active.trashbin
  505. ? "rgb(150, 0, 0)"
  506. : "transparent";
  507. });
  508. trashbin.el.addEventListener("mousedown", (e) => {
  509. if (e.button != 0) return;
  510. this.active.trashbin = !this.active.trashbin;
  511. if (this.active.trashbin) {
  512. trashbin.el.style.backgroundColor = "rgb(100, 0, 0)";
  513. this.show_deleted_buttons();
  514. this.trash_container.add(mainCont.el);
  515. } else {
  516. trashbin.el.style.backgroundColor = "transparent";
  517. this.trash_container.el.innerHTML = ""; //clear previous items first
  518. this.trash_container.remove(mainCont.el);
  519. }
  520. });
  521.  
  522. let mover = new El("Mover", "div", "transparent", "45px", "50px");
  523. mover.setPosition("relative", "inline-block");
  524. mover.setText(
  525. `⬅️`,
  526. "white",
  527. "Calibri",
  528. "bold",
  529. "20px",
  530. "2px",
  531. "center",
  532. "center"
  533. );
  534. mover.setBorder("normal", "0px", "transparent", "10px");
  535. mover.el.addEventListener("mouseover", (e) => {
  536. mover.el.style.cursor = "pointer";
  537. mover.el.style.backgroundColor = this.active.mover
  538. ? "rgb(0, 0, 200)"
  539. : "rgb(0, 0, 50)";
  540. });
  541. mover.el.addEventListener("mouseout", (e) => {
  542. mover.el.style.cursor = "normal";
  543. mover.el.style.backgroundColor = this.active.mover
  544. ? "rgb(0, 0, 150)"
  545. : "transparent";
  546. });
  547. mover.el.addEventListener("mousedown", (e) => {
  548. if (e.button != 0) return;
  549. this.active.mover = !this.active.mover;
  550. mover.el.style.backgroundColor = "rgb(0, 0, 100)";
  551. });
  552. //elements fusion
  553. temp_cont.el.appendChild(trashbin.el);
  554. temp_cont.el.appendChild(mover.el);
  555. this.element = temp_cont.el;
  556. }
  557. add_content(content) {
  558. this.trash_content.push(content);
  559. this.update_text();
  560. }
  561. remove_content(content) {
  562. let index = this.trash_content.indexOf(content);
  563. if (index === -1) return;
  564. this.trash_content.splice(index, 1);
  565. this.update_text();
  566. }
  567. update_text() {
  568. this.element.children[0].innerHTML = `${this.trash_content.length}🗑️`;
  569. }
  570. create_deleted_button(obj) {
  571. let temp = new El(obj.name, "div", "transparent", "170px", "50px");
  572. temp.el.style.backgroundColor = "rgb(200, 100, 0)";
  573. temp.setText(
  574. obj.name,
  575. "lightgray",
  576. "Calibri",
  577. "bold",
  578. "20px",
  579. "2px",
  580. "center",
  581. "center"
  582. );
  583. temp.setBorder("normal", "2px", "rgb(200, 200, 0)", "5px");
  584. temp.el.style.flexShrink = "0";
  585. temp.el.addEventListener("mouseover", (e) => {
  586. temp.el.style.cursor = "pointer";
  587. temp.el.style.backgroundColor = "rgb(250, 150, 0)";
  588. });
  589. temp.el.addEventListener("mouseout", (e) => {
  590. temp.el.style.cursor = "normal";
  591. temp.el.style.backgroundColor = "rgb(200, 100, 0)";
  592. });
  593. temp.el.addEventListener("mousedown", (e) => {
  594. if (e.button != 0) return;
  595. let path = find_module_path(obj.name);
  596. let target_module = modules[path[0]][path[1]];
  597. target_module.trashed = false;
  598. trashed_module_names.delete(target_module.name);
  599. localStorage.setItem(
  600. "[Diep.io+] Trashed names",
  601. JSON.stringify(Array.from(trashed_module_names))
  602. );
  603. if (path[0] === activeCategory) {
  604. for (let child of obj.children) {
  605. modCont.el.appendChild(child);
  606. }
  607. }
  608. this.trash_container.el.removeChild(temp.el);
  609. this.remove_content(obj);
  610. this.update_text();
  611. });
  612. return temp;
  613. }
  614. show_deleted_buttons() {
  615. this.trash_container.el.innerHTML = "";
  616. if (this.trash_content.length > 0) {
  617. for (let obj of this.trash_content) {
  618. let btn = this.create_deleted_button(obj);
  619. btn.add(this.trash_container.el);
  620. }
  621. }
  622. }
  623. }
  624.  
  625. function trash_module(module_name, class_elements) {
  626. if (modCont.el.children.length === 0)
  627. return console.warn("Currently no modules loaded");
  628. let temp_storage = {
  629. name: module_name,
  630. children: [],
  631. };
  632. for (let child of modCont.el.children) {
  633. for (let class_el of class_elements) {
  634. if (child === class_el) {
  635. temp_storage.children.push(child);
  636. }
  637. }
  638. }
  639. for (let element of temp_storage.children) {
  640. modCont.el.removeChild(element);
  641. }
  642. trash.add_content(temp_storage);
  643. }
  644.  
  645. //creation of trashbin class instance
  646. let trash = new Trashbin(saved_trash_content);
  647.  
  648. //new keybinds logic
  649. let keybinds = new Set();
  650.  
  651. class Setting {
  652. constructor(name, type, options, target_class) {
  653. this.name = name;
  654. this.options = options;
  655. this.elements = [];
  656. this.desc = new El(
  657. name + " Setting",
  658. "div",
  659. "transparent",
  660. "170px",
  661. "50px"
  662. );
  663. this.desc.setPosition("relative", "block");
  664. this.desc.setText(
  665. name,
  666. "white",
  667. "Calibri",
  668. "bold",
  669. "15px",
  670. "2px",
  671. "center",
  672. "center"
  673. );
  674. this.elements.push(this.desc.el);
  675.  
  676. switch (type) {
  677. case "title":
  678. this.desc.el.style.backgroundColor = "rgb(50, 50, 50)";
  679. this.desc.setText(
  680. name,
  681. "lightgray",
  682. "Calibri",
  683. "bold",
  684. "20px",
  685. "2px",
  686. "center",
  687. "center"
  688. );
  689. this.desc.setBorder("normal", "2px", "gray", "5px");
  690. break;
  691. case "keybind":
  692. this.kb_state = "idle";
  693. this.previous_key = "";
  694. this.desc.el.style.backgroundColor = "rgb(103, 174, 110)";
  695. this.desc.setText(
  696. name.length > 0 ? name : "Click to Select Keybind",
  697. "rgb(225, 238, 188)",
  698. "Calibri",
  699. "bold",
  700. "15px",
  701. "2px",
  702. "center",
  703. "center"
  704. );
  705. this.desc.setBorder("normal", "2px", "rgb(50, 142, 110)", "5px");
  706. this.desc.el.addEventListener("mouseover", (e) => {
  707. this.desc.el.style.backgroundColor = "rgb(144, 198, 124)";
  708. target_class.desc.setBorder("normal", "2px", "red", "5px");
  709. });
  710. this.desc.el.addEventListener("mouseout", (e) => {
  711. this.desc.el.style.backgroundColor = "rgb(103, 174, 110)";
  712. target_class.desc.setBorder("normal", "0px", "transparent", "0px");
  713. });
  714. this.desc.el.addEventListener("mousedown", (e) => {
  715. if (e.button != 0) return;
  716. this.desc.el.innerHTML = "Press a key";
  717. this.kb_state = "listening";
  718. });
  719. document.addEventListener("keydown", (e) => {
  720. switch (this.kb_state) {
  721. case "set":
  722. if (e.code === this.previous_key) {
  723. target_class.active = !target_class.active;
  724. target_class.update_toggle(target_class.checkbox);
  725. }
  726. break;
  727. case "listening":
  728. if (this.previous_key === e.code) {
  729. this.desc.el.innerHTML = e.code;
  730. this.kb_state = "set";
  731. } else if (keybinds.has(e.code)) {
  732. this.desc.el.innerHTML =
  733. "Keybind already being used, try again!";
  734. } else {
  735. if (e.code === "Backspace" || e.code === "Escape") {
  736. this.desc.el.innerHTML = "Click to Select Keybind";
  737. this.kb_state = "set";
  738. return;
  739. }
  740. keybinds.add(e.code);
  741. if (keybinds.has(this.previous_key))
  742. keybinds.delete(this.previous_key);
  743. this.desc.el.innerHTML = e.code;
  744. this.previous_key = e.code;
  745. this.kb_state = "set";
  746. }
  747. break;
  748. default:
  749. return;
  750. }
  751. });
  752. break;
  753. case "select": {
  754. if (!this.options) return console.warn("Missing Options!");
  755. let index = 0;
  756. this.selected = options[index];
  757. //temp cont
  758. let temp_container = new El(
  759. name + " temp Container",
  760. "div",
  761. "transparent"
  762. );
  763. temp_container.el.style.display = "flex";
  764. temp_container.el.style.alignItems = "center";
  765. temp_container.el.style.justifyContent = "center";
  766. temp_container.el.style.gap = "10px";
  767.  
  768. //displ
  769. let displ = new El(
  770. name + " Setting Display",
  771. "div",
  772. "lightgray",
  773. "125px",
  774. "25px"
  775. );
  776. displ.setText(
  777. this.selected,
  778. "black",
  779. "Calibri",
  780. "bold",
  781. "15px",
  782. "2px",
  783. "center",
  784. "center"
  785. );
  786.  
  787. //left Arrow
  788. let l_arrow = new El(
  789. name + " left Arrow",
  790. "div",
  791. "transparent",
  792. "0px",
  793. "0px"
  794. );
  795. l_arrow.setBorder("bottom", "8px", "transparent");
  796. l_arrow.setBorder("left", "0px", "transparent");
  797. l_arrow.setBorder("right", "16px", "blue");
  798. l_arrow.setBorder("top", "8px", "transparent");
  799.  
  800. l_arrow.el.addEventListener("mouseover", () => {
  801. l_arrow.el.style.cursor = "pointer";
  802. l_arrow.setBorder("right", "16px", "darkblue");
  803. });
  804.  
  805. l_arrow.el.addEventListener("mouseout", () => {
  806. l_arrow.el.style.cursor = "normal";
  807. l_arrow.setBorder("right", "16px", "blue");
  808. });
  809.  
  810. l_arrow.el.addEventListener("mousedown", (e) => {
  811. if (e.button != 0) return;
  812. let limit = options.length - 1;
  813. if (index - 1 < 0) {
  814. index = limit;
  815. } else {
  816. index--;
  817. }
  818. this.selected = options[index];
  819. displ.el.innerHTML = this.selected;
  820. });
  821.  
  822. //right Arrow
  823. let r_arrow = new El(
  824. name + " right Arrow",
  825. "div",
  826. "transparent",
  827. "0px",
  828. "0px"
  829. );
  830. r_arrow.setBorder("bottom", "8px", "transparent");
  831. r_arrow.setBorder("left", "16px", "blue");
  832. r_arrow.setBorder("right", "0px", "transparent");
  833. r_arrow.setBorder("top", "8px", "transparent");
  834.  
  835. r_arrow.el.addEventListener("mouseover", () => {
  836. r_arrow.el.style.cursor = "pointer";
  837. r_arrow.setBorder("left", "16px", "darkblue");
  838. });
  839.  
  840. r_arrow.el.addEventListener("mouseout", () => {
  841. r_arrow.el.style.cursor = "normal";
  842. r_arrow.setBorder("left", "16px", "blue");
  843. });
  844.  
  845. r_arrow.el.addEventListener("mousedown", (e) => {
  846. if (e.button != 0) return;
  847. let limit = options.length - 1;
  848. if (index + 1 > limit) {
  849. index = 0;
  850. } else {
  851. index++;
  852. }
  853. this.selected = options[index];
  854. displ.el.innerHTML = this.selected;
  855. });
  856.  
  857. //connect together
  858. temp_container.el.appendChild(l_arrow.el);
  859. temp_container.el.appendChild(displ.el);
  860. temp_container.el.appendChild(r_arrow.el);
  861.  
  862. //remember them
  863. this.elements.push(temp_container.el);
  864. break;
  865. }
  866. case "toggle": {
  867. this.active = false;
  868. this.desc.el.style.display = "flex";
  869. this.desc.el.style.alignItems = "center";
  870. this.desc.el.style.justifyContent = "space-between";
  871. let empty_checkbox = new El(
  872. this.name + " Setting checkbox",
  873. "div",
  874. "lightgray",
  875. "20px",
  876. "20px"
  877. );
  878. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  879. //event listeners
  880. empty_checkbox.el.addEventListener("mousedown", (e) => {
  881. if (e.button != 0) return;
  882. this.active = !this.active;
  883. this.update_toggle(empty_checkbox);
  884. });
  885. empty_checkbox.el.addEventListener("mouseover", () => {
  886. empty_checkbox.el.style.backgroundColor = this.active
  887. ? "darkgreen"
  888. : "darkgray";
  889. empty_checkbox.el.style.cursor = "pointer";
  890. });
  891. empty_checkbox.el.addEventListener("mouseout", () => {
  892. empty_checkbox.el.style.backgroundColor = this.active
  893. ? "green"
  894. : "lightgray";
  895. });
  896. this.desc.el.appendChild(empty_checkbox.el);
  897. this.checkbox = empty_checkbox;
  898. break;
  899. }
  900. }
  901. }
  902. update_toggle(empty_checkbox) {
  903. if (this.active) {
  904. empty_checkbox.el.innerHTML = "✔";
  905. empty_checkbox.el.style.backgroundColor = "green";
  906. empty_checkbox.setBorder("normal", "2px", "lime", "4px");
  907. } else {
  908. empty_checkbox.el.innerHTML = "";
  909. empty_checkbox.el.style.backgroundColor = "lightgray";
  910. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  911. }
  912. }
  913. load() {
  914. this.elements.forEach((element) => settCont.el.appendChild(element));
  915. }
  916.  
  917. unload() {
  918. this.elements.forEach((element) => {
  919. if (settCont.el.contains(element)) {
  920. settCont.el.removeChild(element);
  921. }
  922. });
  923. }
  924. }
  925.  
  926. class Module {
  927. constructor(name, type, settings, callback) {
  928. this.name = name;
  929. this.type = type;
  930. this.trashed = trashed_module_names.has(this.name);
  931. this.callbackFunc = callback;
  932. this.settings = settings;
  933. this.title = new El(name, "div", "transparent", "100%", "50px");
  934. this.title.setPosition("relative", "block");
  935. this.title.setText(
  936. name,
  937. "white",
  938. "Calibri",
  939. "bold",
  940. "15px",
  941. "2px",
  942. "center",
  943. "center"
  944. );
  945. this.title.el.addEventListener("mouseover", (e) => {
  946. if (!trash.active.mover) return;
  947. this.title.el.style.color = "rgb(200, 0, 0)";
  948. });
  949. this.title.el.addEventListener("mouseout", (e) => {
  950. if (this.title.el.style.color === "rgb(200, 0, 0)") {
  951. this.title.el.style.color = "white";
  952. }
  953. });
  954. this.elements = [];
  955. this.elements.push(this.title.el);
  956. switch (type) {
  957. case "toggle": {
  958. this.active = false;
  959. this.title.el.style.display = "flex";
  960. this.title.el.style.alignItems = "center";
  961. this.title.el.style.justifyContent = "space-between";
  962. let empty_checkbox = new El(
  963. this.name + " checkbox",
  964. "div",
  965. "lightgray",
  966. "20px",
  967. "20px"
  968. );
  969. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  970. //event listeners
  971. empty_checkbox.el.addEventListener("mousedown", (e) => {
  972. if (e.button != 0) return;
  973. this.active = !this.active;
  974. if (this.active) {
  975. empty_checkbox.el.innerHTML = "✔";
  976. empty_checkbox.el.style.backgroundColor = "green";
  977. empty_checkbox.setBorder("normal", "2px", "lime", "4px");
  978. } else {
  979. empty_checkbox.el.innerHTML = "";
  980. empty_checkbox.el.style.backgroundColor = "lightgray";
  981. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  982. }
  983. });
  984. empty_checkbox.el.addEventListener("mouseover", () => {
  985. empty_checkbox.el.style.backgroundColor = this.active
  986. ? "darkgreen"
  987. : "darkgray";
  988. empty_checkbox.el.style.cursor = "pointer";
  989. });
  990. empty_checkbox.el.addEventListener("mouseout", () => {
  991. empty_checkbox.el.style.backgroundColor = this.active
  992. ? "green"
  993. : "lightgray";
  994. });
  995. this.title.el.appendChild(empty_checkbox.el);
  996. break;
  997. }
  998. case "slider": {
  999. this.value = 100;
  1000. this.title.el.innerHTML = `${this.name}: ${this.value} %`;
  1001. const slider = document.createElement("input");
  1002. slider.type = "range";
  1003. slider.value = this.value;
  1004. slider.min = 0;
  1005. slider.max = 100;
  1006.  
  1007. slider.addEventListener("input", () => {
  1008. this.value = slider.value;
  1009. this.title.el.innerHTML = `${this.name}: ${this.value} %`;
  1010. });
  1011.  
  1012. this.elements.push(slider);
  1013. break;
  1014. }
  1015. case "button":
  1016. this.title.el.style.width = "100%";
  1017. this.title.el.style.boxSizing = "border-box";
  1018. this.title.el.style.whiteSpace = "normal"; // Allows text wrapping
  1019. this.title.setBorder("normal", "2px", "white", "10px");
  1020. this.title.el.style.cursor = "pointer";
  1021. this.title.el.addEventListener("mousedown", () => {
  1022. if (trash.active.mover) return;
  1023. if (this.callbackFunc) {
  1024. this.callbackFunc();
  1025. }
  1026. });
  1027. break;
  1028. case "open": {
  1029. this.active = false;
  1030. this.title.el.style.display = "flex";
  1031. this.title.el.style.alignItems = "center";
  1032. this.title.el.style.justifyContent = "space-between";
  1033. let opener_box = new El(
  1034. this.name + " opener box",
  1035. "div",
  1036. "rgb(75, 75, 75)",
  1037. "20px",
  1038. "20px"
  1039. );
  1040. opener_box.setBorder("normal", "2px", "gray", "4px");
  1041. opener_box.el.style.display = "flex";
  1042. opener_box.el.style.alignItems = "center";
  1043. opener_box.el.style.justifyContent = "center";
  1044. //
  1045. let triangle = new El(
  1046. name + " triangle",
  1047. "div",
  1048. "transparent",
  1049. "0px",
  1050. "0px"
  1051. );
  1052. triangle.setBorder("bottom", "16px", "lime");
  1053. triangle.setBorder("left", "8px", "transparent");
  1054. triangle.setBorder("right", "8px", "transparent");
  1055. triangle.setBorder("top", "0px", "transparent");
  1056. //
  1057. //event listeners
  1058. opener_box.el.addEventListener("mousedown", (e) => {
  1059. if (e.button != 0) return;
  1060. if (trash.active.mover) return;
  1061. this.active = !this.active;
  1062. if (this.active) {
  1063. triangle.setBorder("bottom", "0px", "transparent");
  1064. triangle.setBorder("left", "8px", "transparent");
  1065. triangle.setBorder("right", "8px", "transparent");
  1066. triangle.setBorder("top", "16px", "red");
  1067. this.loadSettings();
  1068. } else {
  1069. triangle.setBorder("bottom", "16px", "lime");
  1070. triangle.setBorder("left", "8px", "transparent");
  1071. triangle.setBorder("right", "8px", "transparent");
  1072. triangle.setBorder("top", "0px", "transparent");
  1073. this.unloadSettings();
  1074. }
  1075. });
  1076. opener_box.el.addEventListener("mouseover", () => {
  1077. opener_box.el.style.backgroundColor = "rgb(50, 50, 50)";
  1078. opener_box.el.style.cursor = "pointer";
  1079. });
  1080. opener_box.el.addEventListener("mouseout", () => {
  1081. opener_box.el.style.backgroundColor = "rgb(75, 75, 75)";
  1082. });
  1083. opener_box.el.appendChild(triangle.el);
  1084. this.title.el.appendChild(opener_box.el);
  1085. break;
  1086. }
  1087. }
  1088. if (trashed_module_names.has(this.name)) {
  1089. saved_trash_content.push({ name: this.name, children: this.elements });
  1090. trash.update_text();
  1091. }
  1092. this.title.el.addEventListener("mousedown", (e) => {
  1093. if (!trash.active.mover) return;
  1094. trash_module(this.name, this.elements);
  1095. this.trashed = true;
  1096. trashed_module_names.add(this.name);
  1097. localStorage.setItem(
  1098. "[Diep.io+] Trashed names",
  1099. JSON.stringify(Array.from(trashed_module_names))
  1100. );
  1101. this.title.el.style.color = "white";
  1102. trash.show_deleted_buttons();
  1103. });
  1104. }
  1105. load() {
  1106. this.elements.forEach((element) => modCont.el.appendChild(element));
  1107. }
  1108.  
  1109. unload() {
  1110. this.elements.forEach((element) => {
  1111. if (modCont.el.contains(element)) {
  1112. modCont.el.removeChild(element);
  1113. }
  1114. });
  1115. }
  1116.  
  1117. loadSettings() {
  1118. if (!this.settings) return;
  1119. for (let _sett in this.settings) {
  1120. this.settings[_sett].load();
  1121. }
  1122. }
  1123.  
  1124. unloadSettings() {
  1125. if (!this.settings) return;
  1126. for (let _sett in this.settings) {
  1127. this.settings[_sett].unload();
  1128. }
  1129. }
  1130. }
  1131.  
  1132. class Category {
  1133. constructor(name, modules) {
  1134. this.name = name;
  1135. this.element = new El(name, "div", "rgb(38, 38, 38)", "90px", "50px");
  1136. this.element.setPosition("relative", "block");
  1137. this.element.setText(
  1138. name,
  1139. "white",
  1140. "Calibri",
  1141. "bold",
  1142. "20px",
  1143. "2px",
  1144. "center",
  1145. "center"
  1146. );
  1147. this.element.setBorder("normal", "2px", "transparent", "10px");
  1148. this.selected = false;
  1149. this.modules = modules;
  1150.  
  1151. this.element.el.addEventListener("mousedown", (e) => {
  1152. if (e.button !== 0) return;
  1153. this.selected = !this.selected;
  1154. this.element.el.style.backgroundColor = this.selected
  1155. ? "lightgray"
  1156. : "rgb(38, 38, 38)";
  1157. handle_categories_selection(this.name);
  1158. if (!this.selected) unload_modules(this.name);
  1159. });
  1160.  
  1161. this.element.el.addEventListener("mouseover", () => {
  1162. if (!this.selected) {
  1163. this.element.el.style.backgroundColor = "rgb(58, 58, 58)";
  1164. this.element.el.style.cursor = "pointer";
  1165. }
  1166. });
  1167.  
  1168. this.element.el.addEventListener("mouseout", () => {
  1169. if (!this.selected)
  1170. this.element.el.style.backgroundColor = "rgb(38, 38, 38)";
  1171. });
  1172. }
  1173. unselect() {
  1174. this.selected = false;
  1175. this.element.el.style.backgroundColor = "rgb(38, 38, 38)";
  1176. }
  1177. }
  1178.  
  1179. //1travel
  1180. let modules = {
  1181. Info: {
  1182. hall_of_Fame: new Module("Hall of Fame", "open", {
  1183. darkdealer_00249: new Setting("darkdealer_00249", "title"),
  1184. Sguanto: new Setting("Sguanto", "title"),
  1185. }),
  1186. q_a1: new Module(
  1187. "Where are the old scripts from diep.io+?",
  1188. "button",
  1189. null,
  1190. () => {
  1191. alert("They're either patched, or not fully integrated yet.");
  1192. }
  1193. ),
  1194. q_a2: new Module("Can you make me a script?", "button", null, () => {
  1195. alert(
  1196. "If it's simple - yes, if not give me a donation or a private script and I will do it for you, unless I don't know how to implement it."
  1197. );
  1198. }),
  1199. q_a3: new Module("This script is so confusing!", "button", null, () => {
  1200. alert(
  1201. "Maybe I will make full tutorial, but for now ask me anything about it. Discord: h3llside"
  1202. );
  1203. }),
  1204. q_a4: new Module(
  1205. "How can I join your discord server?",
  1206. "button",
  1207. null,
  1208. () => {
  1209. alert(
  1210. "Join and follow instructions: https://discord.gg/S3ZzgDNAuG please dm me if the link doesn't work, discord: h3llside"
  1211. );
  1212. }
  1213. ),
  1214. q_a5: new Module("Why do you update it so often?", "button", null, () => {
  1215. alert(
  1216. "I get it, it can be annoying to constantly update the script, but sometimes new ideas come, sometimes game updates and breaks this script so I have no choice but to update frequently"
  1217. );
  1218. }),
  1219. q_a6: new Module("What is the import, export for?", "button", null, () => {
  1220. alert(
  1221. "it's for auto respawn+, mainly spawn type: Random Killer. It basically chooses random saved name and you can share those saved names with each other :)"
  1222. );
  1223. }),
  1224. },
  1225.  
  1226. Visual: {
  1227. Key_inputs_visualiser: new Module("Key Inputs Visualiser", "toggle"),
  1228. destroyer_cooldown: new Module("Destroyer Cooldown", "open", {
  1229. Title: new Setting("Destroyer Cooldown", "title"),
  1230. keybind: new Setting(
  1231. "",
  1232. "keybind",
  1233. null,
  1234. (this.temp = new Setting("enable Destroyer Cooldown", "toggle"))
  1235. ),
  1236. reload: new Setting("Reload?", "select", [0, 1, 2, 3, 4, 5, 6, 7]),
  1237. destroyer_cooldown: this.temp,
  1238. }),
  1239. },
  1240.  
  1241. Functional: {
  1242. CopyLink: new Module("Copy Party Link", "button", null, () => {
  1243. document.getElementById("copy-party-link").click();
  1244. }),
  1245. Predator_stack: new Module("Predator Stack", "button", null, () => {
  1246. predator_stack(get_reload());
  1247. }),
  1248. Sandbox_lvl_up: new Module("Sandbox Auto Level Up", "toggle"),
  1249. Auto_respawn: new Module("Auto Respawn", "open", {
  1250. Title: new Setting("Auto Respawn", "title"),
  1251. keybind: new Setting(
  1252. "",
  1253. "keybind",
  1254. null,
  1255. (this.temp = new Setting("Auto Respawn", "toggle"))
  1256. ),
  1257. Remember: new Setting("Remember and store Killer Names", "toggle"),
  1258. Prevent: new Setting("Prevent respawning after 300k score", "toggle"),
  1259. Name: new Setting("Spawn Name Type: ", "select", [
  1260. "Normal",
  1261. "Glitched",
  1262. "N A M E",
  1263. "Random Killer",
  1264. "Random Symbols",
  1265. "Random Numbers",
  1266. "Random Letters",
  1267. ]),
  1268. Auto_respawn: this.temp,
  1269. }),
  1270. Import_names: new Module(
  1271. "Import Killer Names",
  1272. "button",
  1273. null,
  1274. import_killer_names
  1275. ),
  1276. Export_names: new Module("Export Killer Names", "button", null, () => {
  1277. let exported_string = localStorage.getItem("[Diep.io+] saved names")
  1278. ? localStorage.getItem("[Diep.io+] saved names")
  1279. : -1;
  1280. if (exported_string < 0)
  1281. return alert("not copied, because 0 saved names");
  1282. navigator.clipboard.writeText("'" + exported_string + "'");
  1283. alert(`copied ${JSON.parse(exported_string).length} saved names`);
  1284. }),
  1285. Bot_tab: new Module("Sandbox Arena size increase", "toggle"),
  1286. Tank_upgrades: new Module("Tank Upgrades Keybinds", "open", {
  1287. Title: new Setting("Tank Upgrades Keybinds", "title"),
  1288. visualise: new Setting("Show positions and keys", "toggle"),
  1289. Tank_upgrades: new Setting("enable Tank Upgrades Keybinds", "toggle"),
  1290. }),
  1291. Zoom: new Module("Zoom Out", "slider"),
  1292. },
  1293.  
  1294. Mouse: {
  1295. Anti_aim: new Module("Anti Aim", "open", {
  1296. Title: new Setting("Anti Aim", "title"),
  1297. keybind: new Setting(
  1298. "",
  1299. "keybind",
  1300. null,
  1301. (this.temp = new Setting("enable Anti Aim", "toggle"))
  1302. ),
  1303. Timing: new Setting(
  1304. "Follow mouse on click, how long?",
  1305. "select",
  1306. [50, 100, 150, 200, 250, 300]
  1307. ),
  1308. Anti_aim: this.temp,
  1309. }),
  1310. Freeze_mouse: new Module("Freeze Mouse", "toggle"),
  1311. Anti_timeout: new Module("Anti AFK Timeout", "toggle"),
  1312. Move_2_mouse: new Module("Move to mouse", "open", {
  1313. Title: new Setting("Move to mouse", "title"),
  1314. keybind: new Setting(
  1315. "",
  1316. "keybind",
  1317. null,
  1318. (this.temp = new Setting("enable Move to Mouse", "toggle"))
  1319. ),
  1320. toggle_debug: new Setting("Watch how the script works", "toggle"),
  1321. Approximation: new Setting(
  1322. "Approximation Factor (lower = smoother)",
  1323. "select",
  1324. [10, 25, 40, 65, 80, 100]
  1325. ),
  1326. Time_factor: new Setting(
  1327. "Time Factor (higher = longer)",
  1328. "select",
  1329. [10, 20, 30, 40, 50]
  1330. ),
  1331. Move_2_mouse: this.temp,
  1332. }),
  1333. Custom_auto_spin: new Module("Custom Auto Spin", "open", {
  1334. Title: new Setting("Custom Auto Spin", "title"),
  1335. keybind: new Setting(
  1336. "",
  1337. "keybind",
  1338. null,
  1339. (this.temp = new Setting("enable Custom Auto Spin", "toggle"))
  1340. ),
  1341. Interval: new Setting(
  1342. "Movement Interval",
  1343. "select",
  1344. [
  1345. 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300,
  1346. 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2500, 3000, 3500, 4000,
  1347. 5000,
  1348. ]
  1349. ),
  1350. Smoothness: new Setting("Smoothness", "select", [3, 4, 5, 6, 7, 8]),
  1351. Replace_auto_spin: new Setting("replace Auto Spin", "toggle"),
  1352. Custom_auto_spin: this.temp,
  1353. }),
  1354. },
  1355.  
  1356. DiepConsole: {
  1357. con_toggle: new Module("Show/hide Diep Console", "toggle"),
  1358. net_predict_movement: new Module("predict movement", "toggle"),
  1359. Render: new Module("Render things", "open", {
  1360. Title: new Setting("Rendering", "title"),
  1361. ren_scoreboard: new Setting("Leaderboard", "toggle"),
  1362. ren_scoreboard_names: new Setting("Scoreboard Names", "toggle"),
  1363. ren_fps: new Setting("FPS", "toggle"),
  1364. ren_upgrades: new Setting("Tank Upgrades", "toggle"),
  1365. ren_stats: new Setting("Stat Upgrades", "toggle"),
  1366. ren_names: new Setting("Names", "toggle"),
  1367. }),
  1368. //game builds
  1369. },
  1370.  
  1371. Addons: {
  1372. aim_lines: new Module("Tank Aim lines", "open", {
  1373. Title: new Setting("Tank Aim lines", "title"),
  1374. keybind: new Setting(
  1375. "",
  1376. "keybind",
  1377. null,
  1378. (this.temp = new Setting("Toggle Aim Lines", "toggle"))
  1379. ),
  1380. adjust_length: new Setting(
  1381. "Adjust aim line length",
  1382. "select",
  1383. [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 5, 7.5, 10]
  1384. ),
  1385. toggle_aim_lines: this.temp,
  1386. }),
  1387. farm_bot: new Module("Farm Bot", "open", {
  1388. Title: new Setting("Farm Bot", "title"),
  1389. keybind: new Setting(
  1390. "",
  1391. "keybind",
  1392. null,
  1393. (this.temp = new Setting("Toggle Farm Bot", "toggle"))
  1394. ),
  1395. ignore_shapes: new Setting("Shapes you want to ignore:"),
  1396. toggle_squares: new Setting("Squares", "toggle"),
  1397. toggle_crashers: new Setting("Crashers", "toggle"),
  1398. toggle_pentagons: new Setting("Pentagons", "toggle"),
  1399. toggle_triangles: new Setting("Triangles", "toggle"),
  1400. other_setts: new Setting("Movement:"),
  1401. move_to_shape: new Setting("Move to Shapes", "toggle"),
  1402. visuals: new Setting("Visuals:"),
  1403. toggle_lines: new Setting("Toggle Line to Shape", "toggle"),
  1404. toggle_debug: new Setting("See how script works", "toggle"),
  1405. activation: new Setting("Activation:"),
  1406. toggle_farm_bot: this.temp,
  1407. }),
  1408. world_coords: new Module("World Coordinates", "open", {
  1409. Title: new Setting("World Coordinates", "title"),
  1410. precision: new Setting("Precision Factor", "select", [0, 1, 2, 3, 4]),
  1411. toggle_world_coords: new Setting("Toggle World Coordinates", "toggle"),
  1412. }),
  1413. },
  1414. };
  1415.  
  1416. console.log(modules);
  1417.  
  1418. let categories = [];
  1419.  
  1420. function create_categories() {
  1421. for (let key in modules) {
  1422. categories.push(new Category(key, modules[key]));
  1423. }
  1424. }
  1425. create_categories();
  1426.  
  1427. //loading / unloading modules
  1428. function load_modules(category_name) {
  1429. activeCategory = category_name;
  1430. const current_category = categories.find(
  1431. (category) => category.name === category_name
  1432. );
  1433. for (let moduleName in current_category.modules) {
  1434. let module = current_category.modules[moduleName];
  1435. if (!module.trashed) module.load();
  1436. if (module.type === "open" && module.active) module.loadSettings();
  1437. }
  1438. }
  1439.  
  1440. function unload_modules(category_name) {
  1441. if (activeCategory === category_name) activeCategory = undefined;
  1442. const current_category = categories.find(
  1443. (category) => category.name === category_name
  1444. );
  1445. for (let moduleName in current_category.modules) {
  1446. let module = current_category.modules[moduleName];
  1447. module.unload();
  1448. module.unloadSettings();
  1449. }
  1450. }
  1451.  
  1452. function find_module_path(_name) {
  1453. for (let category in modules) {
  1454. for (let module in modules[category]) {
  1455. // Iterate over actual modules
  1456. if (modules[category][module].name === _name) {
  1457. return [category, module]; // Return actual category and module
  1458. }
  1459. }
  1460. }
  1461. return -1; // Return -1 if not found
  1462. }
  1463.  
  1464. function handle_categories_selection(current_name) {
  1465. categories.forEach((category) => {
  1466. if (category.name !== current_name && category.selected) {
  1467. category.unselect();
  1468. unload_modules(category.name);
  1469. }
  1470. });
  1471.  
  1472. load_modules(current_name);
  1473. }
  1474.  
  1475. function loadCategories() {
  1476. const categoryCont = document.querySelector("#sub-container-gray");
  1477. categories.forEach((category) =>
  1478. categoryCont.appendChild(category.element.el)
  1479. );
  1480. }
  1481.  
  1482. function load_selected() {
  1483. categories.forEach((category) => {
  1484. if (category.selected) {
  1485. load_modules(category.name);
  1486. }
  1487. });
  1488. }
  1489.  
  1490. function loadGUI() {
  1491. document.body.style.margin = "0";
  1492. document.body.style.display = "flex";
  1493. document.body.style.justifyContent = "left";
  1494.  
  1495. mainCont = new El("Main Cont", "div", "rgb(38, 38, 38)", "500px", "400px");
  1496. mainCont.setBorder("normal", "2px", "lime", "10px");
  1497. mainCont.el.style.display = "flex";
  1498. mainCont.el.style.minHeight = "min-content";
  1499. mainCont.el.style.flexDirection = "column";
  1500. mainCont.add(document.body);
  1501.  
  1502. header = new El("Headline Dp", "div", "transparent", "100%", "40px");
  1503. header.setBorder("bottom", "2px", "rgb(106, 173, 84)");
  1504. header.setText(
  1505. "Diep.io+ by r!PsAw (Hide GUI with J)",
  1506. "white",
  1507. "Calibri",
  1508. "bold",
  1509. "20px",
  1510. "2px",
  1511. "center",
  1512. "center"
  1513. );
  1514. header.add(mainCont.el);
  1515.  
  1516. const contentWrapper = document.createElement("div");
  1517. contentWrapper.style.display = "flex";
  1518. contentWrapper.style.gap = "10px";
  1519. contentWrapper.style.padding = "10px";
  1520. contentWrapper.style.flex = "1";
  1521. mainCont.el.appendChild(contentWrapper);
  1522.  
  1523. subContGray = new El(
  1524. "Sub Container Gray",
  1525. "div",
  1526. "transparent",
  1527. "100px",
  1528. "100%"
  1529. );
  1530. subContGray.el.style.display = "flex";
  1531. subContGray.el.style.flexDirection = "column";
  1532. subContGray.el.style.overflowY = "auto";
  1533. subContGray.add(contentWrapper);
  1534.  
  1535. subContBlack = new El("Sub Container Black", "div", "black", "360px", "100%");
  1536. subContBlack.el.style.display = "flex";
  1537. subContBlack.el.style.gap = "10px";
  1538. subContBlack.add(contentWrapper);
  1539.  
  1540. modCont = new El("Module Container", "div", "transparent", "50%", "100%");
  1541. modCont.el.style.display = "flex";
  1542. modCont.el.style.flexDirection = "column";
  1543. modCont.el.style.overflowY = "auto";
  1544. modCont.setBorder("right", "2px", "white");
  1545. modCont.add(subContBlack.el);
  1546.  
  1547. settCont = new El("Settings Container", "div", "transparent", "50%", "100%");
  1548. settCont.el.style.display = "flex";
  1549. settCont.el.style.flexDirection = "column";
  1550. settCont.el.style.overflowY = "auto";
  1551. settCont.add(subContBlack.el);
  1552.  
  1553. loadCategories();
  1554. load_selected();
  1555.  
  1556. subContGray.el.appendChild(trash.element);
  1557. }
  1558.  
  1559. loadGUI();
  1560. document.addEventListener("keydown", toggleGUI);
  1561.  
  1562. function toggleGUI(e) {
  1563. if (e.key === "j" || e.key === "J") {
  1564. if (mainCont.el) {
  1565. mainCont.remove(document.body);
  1566. mainCont.el = null;
  1567. } else {
  1568. loadGUI();
  1569. }
  1570. }
  1571. }
  1572.  
  1573. //actual logic
  1574.  
  1575. //allow user to interact with the gui while in game
  1576. Event.prototype.preventDefault = new Proxy(Event.prototype.preventDefault, {
  1577. apply: function(target, thisArgs, args){
  1578. //console.log(thisArgs.type);
  1579. if(thisArgs.type === "mousedown" || thisArgs.type === "mouseup") return; //console.log('successfully canceled');
  1580. return Reflect.apply(target, thisArgs, args);
  1581. }
  1582. });
  1583.  
  1584. //Move to Mouse
  1585. function reset_moving_game(keys_to_reset){
  1586. for(let key of keys_to_reset){
  1587. if(inputs.moving_game[key]){
  1588. extern.onKeyUp(diep_keys[key], fingerprint);
  1589. }
  1590. }
  1591. }
  1592.  
  1593. let approximation_factor = modules.Mouse.Move_2_mouse.settings.Approximation.selected; // Higher = faster movement, but less smooth Lower = slower movement, but more smooth
  1594. let distance_time_factor = modules.Mouse.Move_2_mouse.settings.Time_factor.selected; // transform the distance into Time
  1595. let moving_active = false;
  1596. let current_direction = 'none';
  1597. let reset_move_to_mouse_complete = false;
  1598.  
  1599. function calculate_distance(x1, y1, x2, y2) {
  1600. return Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
  1601. }
  1602.  
  1603. function get_move_steps(x, y) {
  1604. let center = { x: dim_c.canvas_2_window(canvas.width / 2), y: dim_c.canvas_2_window(canvas.height / 2) };
  1605. let target = { x: x, y: y };
  1606. let full_distance = calculate_distance(center.x, center.y, target.x, target.y);
  1607. let partial_distance = full_distance/approximation_factor;
  1608. let step = { x: (target.x - center.x) / partial_distance, y: (target.y - center.y) / partial_distance };
  1609. return step;
  1610. }
  1611.  
  1612. function move_in_direction(direction, time) {
  1613. moving_active = true;
  1614. current_direction = direction;
  1615. let directions = {
  1616. 'Up': 'KeyW',
  1617. 'Left': 'KeyA',
  1618. 'Down': 'KeyS',
  1619. 'Right': 'KeyD',
  1620. }
  1621. for (let _dir in directions) {
  1622. if (directions[_dir] === undefined) return console.warn("Invalid direction");
  1623. if (_dir === direction) {
  1624. extern.onKeyDown(diep_keys[directions[_dir]], fingerprint);
  1625. } else {
  1626. extern.onKeyUp(diep_keys[directions[_dir]], fingerprint);
  1627. }
  1628. }
  1629. setTimeout(() => {
  1630. moving_active = false;
  1631. }, time);
  1632. }
  1633.  
  1634. function move_to_mouse() {
  1635. window.requestAnimationFrame(move_to_mouse);
  1636. if (modules.Mouse.Move_2_mouse.settings.Move_2_mouse.active) {
  1637. if (moving_active || !player.inGame || !document.hasFocus()) return;
  1638. reset_move_to_mouse_complete = false;
  1639. //update factors
  1640. approximation_factor = modules.Mouse.Move_2_mouse.settings.Approximation.selected;
  1641. distance_time_factor = modules.Mouse.Move_2_mouse.settings.Time_factor.selected;
  1642. //logic
  1643. let step = get_move_steps(inputs.mouse.real.x, inputs.mouse.real.y);
  1644. let horizontal = step.x > 0 ? 'Right' : 'Left';
  1645. let vertical = step.y > 0 ? 'Down' : 'Up';
  1646.  
  1647. switch (current_direction) {
  1648. case "none":
  1649. move_in_direction(horizontal, Math.abs(step.x) * distance_time_factor);
  1650. break;
  1651. case 'Right':
  1652. move_in_direction(vertical, Math.abs(step.y) * distance_time_factor);
  1653. break;
  1654. case 'Left':
  1655. move_in_direction(vertical, Math.abs(step.y) * distance_time_factor);
  1656. break;
  1657. case 'Up':
  1658. move_in_direction(horizontal, Math.abs(step.x) * distance_time_factor);
  1659. break
  1660. case 'Down':
  1661. move_in_direction(horizontal, Math.abs(step.x) * distance_time_factor);
  1662. break
  1663. }
  1664. } else {
  1665. if (!reset_move_to_mouse_complete) {
  1666. reset_moving_game(['KeyW', 'KeyA', 'KeyS', 'KeyD']);
  1667. reset_move_to_mouse_complete = true;
  1668. }
  1669. }
  1670. }
  1671. window.requestAnimationFrame(move_to_mouse);
  1672.  
  1673.  
  1674. // ]-[ HTML RELATED STUFF
  1675. let homescreen = document.getElementById("home-screen");
  1676. let ingamescreen = document.getElementById("in-game-screen");
  1677. let gameOverScreen = document.getElementById('game-over-screen');
  1678. let gameOverScreenContainer = document.querySelector("#game-over-screen > div > div.game-details > div:nth-child(1)");
  1679. function update_scale_option(selector, label, min, max) {
  1680. let element = document.querySelector(selector);
  1681. let label_element = element.closest("div").querySelector("span");
  1682. label_element.innerHTML = `[DIEP.IO+] ${label}`;
  1683. label_element.style.background = "black";
  1684. label_element.style.color = "purple";
  1685. element.min = min;
  1686. element.max = max;
  1687. }
  1688.  
  1689. function new_ranges_for_scales() {
  1690. update_scale_option("#subsetting-option-ui_scale", "UI Scale", '0.01', '1000');
  1691. update_scale_option("#subsetting-option-border_radius", "UI Border Radius", '0.01', '1000');
  1692. update_scale_option("#subsetting-option-border_intensity", "UI Border Intensity", '0.01', '1000');
  1693. }
  1694.  
  1695. new_ranges_for_scales();
  1696.  
  1697. //VISUAL TEAM SWITCH
  1698. //create container
  1699. let team_select_container = document.createElement("div");
  1700. team_select_container.classList.add("labelled");
  1701. team_select_container.id = "team-selector";
  1702. document.querySelector("#server-selector").appendChild(team_select_container);
  1703.  
  1704. //create Text "Team"
  1705. let team_select_label = document.createElement("label");
  1706. team_select_label.innerText = "[Diep.io+] Team Selector";
  1707. team_select_label.style.color = "purple";
  1708. team_select_label.style.backgroundColor = "black";
  1709. team_select_container.appendChild(team_select_label);
  1710.  
  1711. //create Selector
  1712. let team_select_selector = document.createElement("div");
  1713. team_select_selector.classList.add("selector");
  1714. team_select_container.appendChild(team_select_selector);
  1715.  
  1716. //create placeholder "Choose Team"
  1717. let teams_visibility = true;
  1718. let ph_div = document.createElement("div");
  1719. let ph_text_div = document.createElement("div");
  1720. let sel_state;
  1721. ph_text_div.classList.add("dropdown-label");
  1722. ph_text_div.innerHTML = "Choose Team";
  1723. ph_div.style.backgroundColor = "gray";
  1724. ph_div.classList.add("selected");
  1725. ph_div.addEventListener("click", () => {
  1726. //toggle Team List
  1727. toggle_team_list(teams_visibility);
  1728. teams_visibility = !teams_visibility;
  1729. });
  1730.  
  1731. team_select_selector.appendChild(ph_div);
  1732. ph_div.appendChild(document.createElement("div"));
  1733. ph_div.appendChild(ph_text_div);
  1734.  
  1735. // Create refresh button
  1736. /*
  1737. let refresh_btn = document.createElement("button");
  1738. refresh_btn.style.width = "30%";
  1739. refresh_btn.style.height = "10%";
  1740. refresh_btn.style.backgroundColor = "black";
  1741. refresh_btn.textContent = "Refresh";
  1742.  
  1743. refresh_btn.onclick = () => {
  1744. remove_previous_teams();
  1745. links_to_teams_GUI_convert();
  1746. };
  1747.  
  1748. team_select_container.appendChild(refresh_btn);
  1749. */
  1750.  
  1751. //create actual teams
  1752. let team_values = [];
  1753.  
  1754. function create_team_div(text, color, link) {
  1755. team_values.push(text);
  1756. let team_div = document.createElement("div");
  1757. let text_div = document.createElement("div");
  1758. let sel_state;
  1759. text_div.classList.add("dropdown-label");
  1760. text_div.innerHTML = text;
  1761. team_div.style.backgroundColor = color;
  1762. team_div.classList.add("unselected");
  1763. team_div.value = text;
  1764. team_div.addEventListener("click", () => {
  1765. const answer = confirm("You're about to open the link in a new tab, do you want to continue?");
  1766. if (answer) {
  1767. window.open(link, "_blank");
  1768. }
  1769. });
  1770.  
  1771. team_select_selector.appendChild(team_div);
  1772. team_div.appendChild(document.createElement("div"));
  1773. team_div.appendChild(text_div);
  1774. }
  1775.  
  1776. function toggle_team_list(boolean) {
  1777. if (boolean) {
  1778. //true
  1779. team_select_selector.classList.remove("selector");
  1780. team_select_selector.classList.add("selector-active");
  1781. } else {
  1782. //false
  1783. team_select_selector.classList.remove("selector-active");
  1784. team_select_selector.classList.add("selector");
  1785. }
  1786. }
  1787.  
  1788. //example
  1789. //create_team_div("RedTeam", "Red", "https://diep.io/");
  1790. //create_team_div("OrangeTeam", "Orange", "https://diep.io/");
  1791. //create_team_div("YellowTeam", "Yellow", "https://diep.io/");
  1792. function links_to_teams_GUI_convert() {
  1793. let gamemode = get_gamemode();
  1794. let lobby = get_your_lobby();
  1795. let links = get_links(gamemode, lobby);
  1796. let team_names = ["Team-Blue", "Team-Red", "Team-Purple", "Team-Green", "Teamless-Gamemode"];
  1797. let team_colors = ["blue", "red", "purple", "green", "orange"];
  1798. for (let i = 0; i < links.length; i++) {
  1799. !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]);
  1800. }
  1801. }
  1802.  
  1803. function remove_previous_teams() {
  1804. for (let i = team_select_selector.childNodes.length - 1; i >= 0; i--) {
  1805. console.log(team_select_selector);
  1806. let child = team_select_selector.childNodes[i];
  1807. if (child.nodeType === Node.ELEMENT_NODE && child.innerText !== "Choose Team") {
  1808. child.remove();
  1809. }
  1810. }
  1811. }
  1812.  
  1813. let party_link_info = {
  1814. old_link: null,
  1815. current_link: null
  1816. }
  1817. function detect_refresh(){
  1818. if(!party_link_info.old_link || !party_link_info.current_link) return;
  1819. party_link_info.current_link = window.lobby_ip + _c.party_link;
  1820. if(party_link_info.current_link != party_link_info.old_link){
  1821. console.log('Link change detected!');
  1822. remove_previous_teams();
  1823. links_to_teams_GUI_convert();
  1824. party_link_info.old_link = party_link_info.current_link;
  1825. }
  1826. }
  1827.  
  1828. function wait_For_Link() {
  1829. if (_c.party_link === '') {
  1830. setTimeout(() => {
  1831. console.log("[Diep.io+] LOADING...");
  1832. wait_For_Link();
  1833. }, 100);
  1834. } else {
  1835. console.log("[Diep.io+] link loaded!");
  1836. remove_previous_teams();
  1837. links_to_teams_GUI_convert();
  1838. party_link_info.current_link = window.lobby_ip + _c.party_link;
  1839. party_link_info.old_link = party_link_info.current_link;
  1840. }
  1841. }
  1842.  
  1843. wait_For_Link();
  1844.  
  1845. //detect gamemode
  1846. let gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  1847. let last_gamemode = localStorage.getItem(`[Diep.io+] last_gm`);
  1848. localStorage.setItem(`[Diep.io+] last_gm`, gamemode);
  1849.  
  1850. function check_gamemode() {
  1851. gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  1852. save_gm();
  1853. }
  1854.  
  1855.  
  1856. function save_gm() {
  1857. let saved_gm = localStorage.getItem(`[Diep.io+] last_gm`);
  1858. if (saved_gm != null && saved_gm != gamemode) {
  1859. last_gamemode = saved_gm;
  1860. }
  1861. saved_gm === null ? localStorage.setItem(`[Diep.io+] last_gm}`, gamemode) : null;
  1862. }
  1863.  
  1864. //personal best
  1865. let your_final_score = 0;
  1866. const personal_best = document.createElement('div');
  1867. const gameDetail = document.createElement('div');
  1868. const label = document.createElement('div');
  1869. //applying class
  1870. gameDetail.classList.add("game-detail");
  1871. label.classList.add("label");
  1872. personal_best.classList.add("value");
  1873. //text context
  1874. label.textContent = "Best:";
  1875. //adding to html
  1876. gameOverScreenContainer.appendChild(gameDetail);
  1877. gameDetail.appendChild(label);
  1878. gameDetail.appendChild(personal_best);
  1879.  
  1880. function load_ls() {
  1881. return localStorage.getItem(gamemode);
  1882. }
  1883.  
  1884. function save_ls() {
  1885. localStorage.setItem(gamemode, your_final_score);
  1886. }
  1887.  
  1888. function check_final_score() {
  1889. if (_c.screen_state === "game-over") {
  1890. your_final_score = _c.death_score;
  1891. let saved_score = parseFloat(load_ls());
  1892. personal_best.textContent = saved_score;
  1893. if (saved_score < your_final_score) {
  1894. personal_best.textContent = your_final_score;
  1895. save_ls();
  1896. }
  1897. }
  1898. }
  1899.  
  1900. //remove annoying html elements
  1901. function instant_remove() {
  1902. // Define selectors for elements to remove
  1903. const selectors = [
  1904. "#cmpPersistentLink",
  1905. "#apes-io-promo",
  1906. "#apes-io-promo > img",
  1907. "#last-updated",
  1908. "#diep-io_300x250"
  1909. ];
  1910.  
  1911. // Remove each selected element
  1912. selectors.forEach(selector => {
  1913. const element = document.querySelector(selector);
  1914. if (element) {
  1915. element.remove();
  1916. }
  1917. });
  1918.  
  1919. // If all elements have been removed, clear the interval
  1920. if (selectors.every(selector => !document.querySelector(selector))) {
  1921. deep_debug("Removed all ads, quitting...");
  1922. clearInterval(interval);
  1923. }
  1924. }
  1925.  
  1926. // Set an interval to check for ads
  1927. const interval = setInterval(instant_remove, 100);
  1928.  
  1929. // ]-[
  1930.  
  1931. //Predator Stack
  1932. let predator_reloads = [
  1933. //0
  1934. {
  1935. scd2: 600,
  1936. scd3: 1000,
  1937. wcd1: 1500,
  1938. wcd2: 2900,
  1939. },
  1940. //1
  1941. {
  1942. scd2: 500,
  1943. scd3: 900,
  1944. wcd1: 1400,
  1945. wcd2: 2800,
  1946. },
  1947. //2
  1948. {
  1949. scd2: 500,
  1950. scd3: 900,
  1951. wcd1: 1200,
  1952. wcd2: 2400,
  1953. },
  1954. //3
  1955. {
  1956. scd2: 400,
  1957. scd3: 900,
  1958. wcd1: 1200,
  1959. wcd2: 2300,
  1960. },
  1961. //4
  1962. {
  1963. scd2: 400,
  1964. scd3: 900,
  1965. wcd1: 1000,
  1966. wcd2: 2000,
  1967. },
  1968. //5
  1969. {
  1970. scd2: 400,
  1971. scd3: 800,
  1972. wcd1: 900,
  1973. wcd2: 1800,
  1974. },
  1975. //6
  1976. {
  1977. scd2: 300,
  1978. scd3: 800,
  1979. wcd1: 900,
  1980. wcd2: 1750,
  1981. },
  1982. //7
  1983. {
  1984. scd2: 300,
  1985. scd3: 800,
  1986. wcd1: 750,
  1987. wcd2: 1500,
  1988. },
  1989. ];
  1990.  
  1991.  
  1992. function shoot(cooldown = 100) {
  1993. deep_debug("Shoot started!", cooldown);
  1994. extern.onKeyDown(36);
  1995. setTimeout(() => {
  1996. deep_debug("Ending Shoot!", cooldown);
  1997. extern.onKeyUp(36);
  1998. }, cooldown);
  1999. }
  2000.  
  2001. function get_reload(){
  2002. let arr = [...extern.get_convar("game_stats_build")];
  2003. let counter = 0;
  2004. let l = arr.length;
  2005. for(let i = 0; i < l; i++){
  2006. if(arr[i] === '7'){
  2007. counter++;
  2008. }
  2009. }
  2010. return counter;
  2011. }
  2012.  
  2013. function predator_stack(reload) {
  2014. deep_debug("func called");
  2015. let current = predator_reloads[reload];
  2016. deep_debug(current);
  2017. shoot();
  2018. setTimeout(() => {
  2019. shoot(current.scd2);
  2020. }, current.wcd1);
  2021. setTimeout(() => {
  2022. shoot(current.scd3);
  2023. }, current.wcd2);
  2024. }
  2025.  
  2026. //Bot tab
  2027.  
  2028. //iframe creation
  2029. function createInvisibleIframe(url) {
  2030. let existingIframe = document.getElementById('hiddenIframe');
  2031. if (existingIframe) {
  2032. return;
  2033. }
  2034.  
  2035. let iframe = document.createElement('iframe');
  2036. iframe.src = url;
  2037. iframe.id = 'hiddenIframe';
  2038. document.body.appendChild(iframe);
  2039. }
  2040.  
  2041. function removeIframe() {
  2042. let iframe = document.getElementById('hiddenIframe');
  2043. if (iframe) {
  2044. iframe.remove();
  2045. }
  2046. }
  2047.  
  2048. function bot_tab_active_check(){
  2049. if(modules.Functional.Bot_tab.active){
  2050. createInvisibleIframe(link(get_baseUrl(), get_your_lobby(), get_gamemode(), get_team()));
  2051. }else{
  2052. removeIframe();
  2053. }
  2054. }
  2055.  
  2056. //DiepConsole
  2057. function active_diepconsole_render_default(){
  2058. let defaults = ['ren_scoreboard', 'ren_upgrades', 'ren_stats', 'ren_names', 'ren_scoreboard_names'];
  2059. for(let _def of defaults){
  2060. let _setting = modules.DiepConsole.Render.settings[_def]
  2061. _setting.active = true;
  2062. _setting.update_toggle(_setting.checkbox);
  2063. }
  2064. }
  2065. active_diepconsole_render_default();
  2066.  
  2067. function handle_con_toggle(state){
  2068. if(!extern.isConActive() && state && player.inGame){
  2069. one_time_notification('canceled, due to a bug. Make sure to not enable it while in game', notification_rgbs.warning, 5000);
  2070. return;
  2071. }
  2072. if(extern.isConActive() != state){
  2073. extern.execute('con_toggle');
  2074. }
  2075. }
  2076.  
  2077. function update_diep_console(){
  2078. //Modules
  2079. for(let param in modules.DiepConsole){
  2080. let state = modules.DiepConsole[param].active;
  2081. if(param === "con_toggle"){
  2082. handle_con_toggle(state)
  2083. }else if(modules.DiepConsole[param].name != "Render things"){
  2084. extern.set_convar(param, state);
  2085. }
  2086. }
  2087. //Render Settings
  2088. for(let ren_param in modules.DiepConsole.Render.settings){
  2089. let state = modules.DiepConsole.Render.settings[ren_param].active;
  2090. if(modules.DiepConsole.Render.settings[ren_param].name != "Rendering"){
  2091. extern.set_convar(ren_param, state);
  2092. }
  2093. }
  2094. }
  2095.  
  2096.  
  2097. //////
  2098. //mouse functions
  2099.  
  2100. window.addEventListener('mousemove', function(event) {
  2101. inputs.mouse.real.x = event.clientX;
  2102. inputs.mouse.real.y = event.clientY;
  2103. });
  2104.  
  2105. window.addEventListener('mousedown', function(event) {
  2106. if (modules.Mouse.Anti_aim.settings.Anti_aim.active) {
  2107. if (inputs.mouse.shooting) {
  2108. return;
  2109. }
  2110. inputs.mouse.shooting = true;
  2111. pauseMouseMove();
  2112. //freezeMouseMove();
  2113. setTimeout(function() {
  2114. inputs.mouse.shooting = false;
  2115. mouse_move('extern', inputs.mouse.real.x, inputs.mouse.real.y);
  2116. click_at('extern', inputs.mouse.real.x, inputs.mouse.real.y);
  2117. }, modules.Mouse.Anti_aim.settings.Timing.selected);
  2118. };
  2119. });
  2120.  
  2121. function handle_mouse_functions() {
  2122. window.requestAnimationFrame(handle_mouse_functions);
  2123. if (!player.connected) {
  2124. return;
  2125. }
  2126. modules.Mouse.Freeze_mouse.active ? freezeMouseMove() : unfreezeMouseMove();
  2127. modules.Mouse.Anti_aim.settings.Anti_aim.active ? anti_aim("On") : anti_aim("Off");
  2128. }
  2129. window.requestAnimationFrame(handle_mouse_functions);
  2130.  
  2131. //anti aim
  2132. function detect_corner() {
  2133. deep_debug('corner detect called');
  2134. let w = window.innerWidth;
  2135. let h = window.innerHeight;
  2136. let center = {
  2137. x: w / 2,
  2138. y: h / 2
  2139. };
  2140. let lr, ud;
  2141. inputs.mouse.real.x > center.x ? lr = "r" : lr = "l";
  2142. inputs.mouse.real.y > center.y ? ud = "d" : ud = "u";
  2143. deep_debug('output: ', lr + ud);
  2144. return lr + ud;
  2145. }
  2146.  
  2147. function look_at_corner(corner) {
  2148. deep_debug('look at corner called with corner', corner);
  2149. if (!inputs.mouse.shooting) {
  2150. let w = window.innerWidth;
  2151. let h = window.innerHeight;
  2152. deep_debug('w and h', w, h);
  2153. deep_debug('inputs: ', inputs);
  2154. switch (corner) {
  2155. case "lu":
  2156. anti_aim_at('extern', w, h);
  2157. break
  2158. case "ld":
  2159. anti_aim_at('extern', w, 0);
  2160. break
  2161. case "ru":
  2162. anti_aim_at('extern', 0, h);
  2163. break
  2164. case "rd":
  2165. anti_aim_at('extern', 0, 0);
  2166. break
  2167. }
  2168. }
  2169. }
  2170.  
  2171. function anti_aim(toggle) {
  2172. deep_debug('anti aim called with:', toggle);
  2173. if(!player.inGame) return;
  2174. switch (toggle) {
  2175. case "On":
  2176. if (modules.Mouse.Anti_aim.settings.Anti_aim.active && !inputs.mouse.isFrozen) {
  2177. deep_debug('condition !modules.Mouse.Anti_aim.settings.active met');
  2178. look_at_corner(detect_corner());
  2179. }
  2180. break
  2181. case "Off":
  2182. //(inputs.mouse.isFrozen && !modules.Mouse.Freeze_mouse.active) ? unfreezeMouseMove() : null;
  2183. (inputs.mouse.isPaused && !modules.Mouse.Freeze_mouse.active) ? unpauseMouseMove() : null;
  2184. break
  2185. }
  2186. }
  2187.  
  2188. // Example: Freeze and unfreeze
  2189. function pauseMouseMove() {
  2190. if(!inputs.mouse.isPaused){
  2191. inputs.mouse.isForced = true;
  2192. inputs.mouse.force.x = inputs.mouse.real.x
  2193. inputs.mouse.force.y = inputs.mouse.real.y;
  2194. inputs.mouse.isPaused = true; //tell the script that freezing finished
  2195. }
  2196. }
  2197.  
  2198. function freezeMouseMove() {
  2199. if(!inputs.mouse.isFrozen){
  2200. inputs.mouse.isForced = true;
  2201. inputs.mouse.force.x = inputs.mouse.real.x
  2202. inputs.mouse.force.y = inputs.mouse.real.y;
  2203. inputs.mouse.isFrozen = true; //tell the script that freezing finished
  2204. }
  2205. /*
  2206. if (!inputs.mouse.isFrozen) {
  2207. inputs.mouse.isFrozen = true;
  2208. clear_onTouch();
  2209. deep_debug("Mousemove events are frozen.");
  2210. }
  2211. */
  2212. }
  2213.  
  2214. function unpauseMouseMove(){
  2215. if (inputs.mouse.isPaused && !inputs.mouse.isShooting) {
  2216. inputs.mouse.isForced = false;
  2217. inputs.mouse.isPaused = false; //tell the script that unfreezing finished
  2218. }
  2219. }
  2220.  
  2221. function unfreezeMouseMove() {
  2222. if (inputs.mouse.isFrozen) {
  2223. inputs.mouse.isForced = false;
  2224. inputs.mouse.isFrozen = false; //tell the script that unfreezing finished
  2225. }
  2226. /*
  2227. if (inputs.mouse.isFrozen && !inputs.mouse.isShooting) {
  2228. inputs.mouse.isFrozen = false;
  2229. redefine_onTouch();
  2230. deep_debug("Mousemove events are active.");
  2231. }
  2232. */
  2233. }
  2234.  
  2235. function click_at(input_or_extern, x, y, delay1 = 150, delay2 = 500) {
  2236. i_e(input_or_extern, 'onTouchStart', -1, x, y);
  2237. setTimeout(() => {
  2238. i_e(input_or_extern, 'onTouchEnd', -1, x, y);
  2239. }, delay1);
  2240. setTimeout(() => {
  2241. inputs.mouse.shooting = false;
  2242. }, delay2);
  2243. }
  2244.  
  2245. /* it was a bug and is now patched
  2246. function ghost_click_at(input_or_extern, x, y, delay1 = 150, delay2 = 500) {
  2247. i_e(input_or_extern, 'onTouchStart', -2, x, y);
  2248. setTimeout(() => {
  2249. i_e(input_or_extern, 'onTouchEnd', -2, x, y);
  2250. }, delay1);
  2251. setTimeout(() => {
  2252. inputs.mouse.shooting = false;
  2253. }, delay2);
  2254. }
  2255. */
  2256.  
  2257. function mouse_move(input_or_extern, x, y) {
  2258. deep_debug('mouse move called with', x, y);
  2259. apply_force(x, y);
  2260. i_e(input_or_extern, 'onTouchMove', -1, x, y);
  2261. disable_force();
  2262. }
  2263.  
  2264. function anti_aim_at(input_or_extern, x, y) {
  2265. deep_debug('frozen, shooting', inputs.mouse.isFrozen, inputs.mouse.isShooting);
  2266. deep_debug('anti aim at called with:', x, y);
  2267. if (inputs.mouse.shooting) {
  2268. deep_debug('quit because inputs.mouse.shooting');
  2269. return;
  2270. }
  2271. mouse_move(input_or_extern, x, y);
  2272. }
  2273. //////
  2274.  
  2275. //Custom Auto Spin
  2276. function getMouseAngle(x, y) {
  2277. const centerX = window.innerWidth / 2;
  2278. const centerY = window.innerHeight / 2;
  2279.  
  2280. const dx = x - centerX;
  2281. const dy = y - centerY;
  2282.  
  2283. let angle = Math.atan2(dy, dx) * (180 / Math.PI);
  2284.  
  2285. return angle < 0 ? angle + 360 : angle;
  2286. }
  2287.  
  2288. function offset_Angle(angle){
  2289. let _angle;
  2290. if(angle <= 360){
  2291. _angle = angle;
  2292. }else{
  2293. _angle = angle-360;
  2294. while(_angle > 360){
  2295. _angle -= 360;
  2296. }
  2297. }
  2298. return _angle;
  2299. }
  2300.  
  2301. function getPointOnCircle(degrees) {
  2302. const centerX = window.innerWidth / 2;
  2303. const centerY = window.innerHeight / 2;
  2304. const radius = Math.min(window.innerWidth, window.innerHeight) / 2;
  2305.  
  2306. const radians = degrees * (Math.PI / 180);
  2307. const x = centerX + radius * Math.cos(radians);
  2308. const y = centerY + radius * Math.sin(radians);
  2309.  
  2310. return { x:x, y:y };
  2311. }
  2312.  
  2313. let cas_force = false;
  2314. let cas_active = false;
  2315. let starting_angle = 0;
  2316. let temp_interval = setInterval(start_custom_spin, modules.Mouse.Custom_auto_spin.settings.Interval.selected);
  2317. function start_keyDown_Proxy(){
  2318. extern.onKeyDown = new Proxy(extern.onKeyDown, {
  2319. apply: function (target, thisArgs, args){
  2320. if(args.length > 1 && args[1] === fingerprint){
  2321. //inputs coming from script
  2322.  
  2323. //inputs_game
  2324. let keys = Object.keys(inputs.moving_game);
  2325. let key_nums = [];
  2326. let l = keys.length;
  2327. for(let i = 0; i < l; i++){
  2328. key_nums[i] = diep_keys[keys[i]];
  2329. }
  2330. if(key_nums.includes(args[0])){
  2331. let i = key_nums.indexOf(args[0]);
  2332. inputs.moving_game[keys[i]] = true;
  2333. }
  2334. }else if(modules.Mouse.Custom_auto_spin.settings.Replace_auto_spin.active && args[0] === diep_keys.KeyC){
  2335. //Auto Spin replacer
  2336. cas_active = !cas_active;
  2337. new_notification(`Custom Auto Spin: ${cas_active?'On':'Off'}`, notification_rgbs.normal, 4000);
  2338. return;
  2339. }else{
  2340. //inputs coming from user
  2341.  
  2342. //inputs_real
  2343. let keys = Object.keys(inputs.moving_real);
  2344. let key_nums = [];
  2345. let l = keys.length;
  2346. for(let i = 0; i < l; i++){
  2347. key_nums[i] = diep_keys[keys[i]];
  2348. }
  2349. if(key_nums.includes(args[0])){
  2350. let i = key_nums.indexOf(args[0]);
  2351. inputs.moving_real[keys[i]] = true;
  2352. }
  2353. }
  2354. return Reflect.apply(target, thisArgs, args);
  2355. }
  2356. });
  2357. }
  2358.  
  2359. function start_keyUp_Proxy(){
  2360. extern.onKeyUp = new Proxy(extern.onKeyUp, {
  2361. apply: function (target, thisArgs, args){
  2362. if(args.length > 1 && args[1] === fingerprint){
  2363. //inputs coming from script
  2364.  
  2365. //moving_game
  2366. let keys = Object.keys(inputs.moving_game);
  2367. let key_nums = [];
  2368. let l = keys.length;
  2369. for(let i = 0; i < l; i++){
  2370. key_nums[i] = diep_keys[keys[i]];
  2371. }
  2372. if(key_nums.includes(args[0])){
  2373. let i = key_nums.indexOf(args[0]);
  2374. inputs.moving_game[keys[i]] = false;
  2375. }
  2376. }else{
  2377. //inputs coming from user
  2378.  
  2379. //moving_real
  2380. let keys = Object.keys(inputs.moving_real);
  2381. let key_nums = [];
  2382. let l = keys.length;
  2383. for(let i = 0; i < l; i++){
  2384. key_nums[i] = diep_keys[keys[i]];
  2385. }
  2386. if(key_nums.includes(args[0])){
  2387. let i = key_nums.indexOf(args[0]);
  2388. inputs.moving_real[keys[i]] = false;
  2389. //make sure script knows if you unpressed a key that it was pressing
  2390. if(inputs.moving_game[keys[i]]) inputs.moving_game[keys[i]] = false;
  2391. }
  2392. }
  2393. return Reflect.apply(target, thisArgs, args);
  2394. }
  2395. });
  2396. }
  2397.  
  2398. function start_custom_spin(){
  2399. clearInterval(temp_interval);
  2400. temp_interval = setInterval(start_custom_spin, modules.Mouse.Custom_auto_spin.settings.Interval.selected);
  2401. if(!player.inGame) return;
  2402. if(!modules.Mouse.Custom_auto_spin.settings.Replace_auto_spin.active) cas_active = modules.Mouse.Custom_auto_spin.settings.Custom_auto_spin.active;
  2403. if(!cas_active){
  2404. starting_angle = getMouseAngle(inputs.mouse.real.x, inputs.mouse.real.y);
  2405. if(inputs.mouse.isForced && cas_force){
  2406. disable_force();
  2407. cas_force = false;
  2408. }
  2409. }else{
  2410. cas_force = true;
  2411. let l = Math.pow(2, modules.Mouse.Custom_auto_spin.settings.Smoothness.selected);
  2412. console.log(l);
  2413. let angle_peace = 360/l;
  2414. console.log(angle_peace);
  2415. let time_peace = modules.Mouse.Custom_auto_spin.settings.Interval.selected/l;
  2416. for(let i = 0; i < l; i++){
  2417. setTimeout(() => {
  2418. let temp_angle = offset_Angle(starting_angle + angle_peace * i);
  2419. let temp_coords = getPointOnCircle(temp_angle);
  2420. apply_force(temp_coords.x, temp_coords.y);
  2421. i_e('extern', 'onTouchMove', -1, temp_coords.x, temp_coords.y);
  2422. }, time_peace*i);
  2423. }
  2424. }
  2425. }
  2426.  
  2427. //Sandbox Auto Lvl up
  2428. function sandbox_lvl_up() {
  2429. if (modules.Functional.Sandbox_lvl_up.active && player.connected && player.inGame && player.gamemode === "sandbox") {
  2430. document.querySelector("#sandbox-max-level").click();
  2431. }
  2432. }
  2433.  
  2434. //START, autorespawn Module
  2435.  
  2436. //name saving logic
  2437. var killer_names = localStorage.getItem("[Diep.io+] saved names") ? JSON.parse(localStorage.getItem("[Diep.io+] saved names")) : ['r!PsAw', 'TestTank'];
  2438. function import_killer_names(){
  2439. let imported_string = prompt('Paste killer names here: ', '["name1", "name2", "name3"]');
  2440. killer_names = killer_names.concat(JSON.parse(imported_string));
  2441. killer_names = [...new Set(killer_names)];
  2442. localStorage.setItem("[Diep.io+] saved names", JSON.stringify(killer_names));
  2443. }
  2444. let banned_names = ["Pentagon", "Triangle", "Square", "Crasher", "Mothership", "Guardian of Pentagons", "Fallen Booster", "Fallen Overlord", "Necromancer", "Defender", "Unnamed Tank"];
  2445. function check_and_save_name(){
  2446. deep_debug(_c.killer_name, !killer_names.includes(_c.killer_name));
  2447. if(_c.screen_state === 'game-over' && !banned_names.includes(_c.killer_name) && !killer_names.includes(_c.killer_name)){
  2448. deep_debug("Condition met!");
  2449. killer_names.push(_c.killer_name);
  2450. deep_debug("Added");
  2451. killer_names = [...new Set(killer_names)];
  2452. if(modules.Functional.Auto_respawn.settings.Remember.active){
  2453. localStorage.setItem("[Diep.io+] saved names", JSON.stringify(killer_names));
  2454. deep_debug("saved list");
  2455. }
  2456. }
  2457. }
  2458.  
  2459. function get_random_killer_name(){
  2460. let l = killer_names.length;
  2461. let index = Math.floor(Math.random() * l);
  2462. return killer_names[index];
  2463. }
  2464.  
  2465. //Random Symbols/Numbers/Letters
  2466. function generate_random_name_string(type){
  2467. let final_result = '';
  2468. let chars = '';
  2469. switch(type){
  2470. case "Symbols":
  2471. chars = '!@#$%^&*()_+=-.,][';
  2472. break
  2473. case "Numbers":
  2474. chars = '1234567890';
  2475. break
  2476. case "Letters":
  2477. chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  2478. break
  2479. }
  2480. for (let i = 0; i < 16; i++) {
  2481. final_result += chars[Math.floor(Math.random() * chars.length)];
  2482. }
  2483. return final_result;
  2484. }
  2485. //ascii inject
  2486. function get_ascii_inject(type){
  2487. let asciiArray = [];
  2488. switch(type){
  2489. case "Glitched":
  2490. asciiArray = [0x110000];
  2491. break
  2492. case "N A M E":
  2493. asciiArray = player.name.split("").flatMap(char => [char.charCodeAt(0), 10]).slice(0, -1);
  2494. break
  2495. }
  2496. let interesting = {
  2497. length: asciiArray.length,
  2498. charCodeAt(i) {
  2499. return asciiArray[i];
  2500. },
  2501. };
  2502. const argument = {
  2503. toString() {
  2504. return interesting;
  2505. },
  2506. };
  2507. return argument;
  2508. }
  2509.  
  2510. //main Loop
  2511. function get_respawn_name_by_type(type){
  2512. let temp_name = '';
  2513. switch(type){
  2514. case "Normal":
  2515. temp_name = player.name;
  2516. break
  2517. case "Glitched":
  2518. temp_name = get_ascii_inject(type);
  2519. break
  2520. case "N A M E":
  2521. temp_name = get_ascii_inject(type);
  2522. break
  2523. case "Random Killer":
  2524. temp_name = get_random_killer_name();
  2525. break
  2526. case "Random Symbols":
  2527. temp_name = generate_random_name_string('Symbols');
  2528. break
  2529. case "Random Numbers":
  2530. temp_name = generate_random_name_string('Numbers');
  2531. break
  2532. case "Random Letters":
  2533. temp_name = generate_random_name_string('Letters');
  2534. break
  2535. }
  2536. return temp_name;
  2537. }
  2538. function respawn() {
  2539. check_and_save_name();
  2540. if (modules.Functional.Auto_respawn.settings.Auto_respawn.active && player.connected && !player.inGame) {
  2541. //prevent respawn after 300k flag
  2542. if(modules.Functional.Auto_respawn.settings.Prevent.active && _c.death_score >= 300000){
  2543. return;
  2544. }
  2545. let type = modules.Functional.Auto_respawn.settings.Name.selected;
  2546. let temp_name = get_respawn_name_by_type(type);
  2547. extern.try_spawn(temp_name);
  2548. }
  2549. }
  2550.  
  2551. //END
  2552.  
  2553. //AntiAfk Timeout
  2554. function AntiAfkTimeout() {
  2555. if (modules.Mouse.Anti_timeout.active && player.connected) {
  2556. extern.onTouchMove(inputs.mouse.real.x, inputs.mouse.real.y);
  2557. }
  2558. }
  2559.  
  2560. //Zoom
  2561. function start_zoom_proxy(){
  2562. input.setScreensizeZoom = new Proxy(input.setScreensizeZoom, {
  2563. apply: function(target, thisArgs, args){
  2564. player.base_value = args[1];
  2565. let factor = modules.Functional.Zoom.value / 100;
  2566. player.dpr = player.base_value * factor;
  2567. let newargs = [args[0], player.dpr];
  2568. return Reflect.apply(target, thisArgs, newargs);
  2569. }
  2570. });
  2571. }
  2572. function HandleZoom() {
  2573. if(player.connected){
  2574. //let base_value = 1;
  2575. //let factor = modules.Functional.Zoom.value / 100;
  2576. //player.dpr = base_value * factor;
  2577. let diepScale = player.base_value * Math.floor(player.ui_scale * windowScaling() * 25) / 25;
  2578. extern.setScreensizeZoom(diepScale, player.base_value);
  2579. extern.updateDPR(player.dpr);
  2580. }
  2581. }
  2582.  
  2583. //ctx helper functions
  2584. function ctx_arc(x, y, r, sAngle, eAngle, counterclockwise, c, stroke_or_fill = 'fill', _globalAlpha=1, _lineWidth = '2px') {
  2585. let original_ga = ctx.globalAlpha;
  2586. let original_lw = ctx.lineWidth;
  2587. ctx.beginPath();
  2588. ctx.arc(x, y, r, sAngle, eAngle, counterclockwise);
  2589. ctx.globalAlpha = _globalAlpha;
  2590. switch(stroke_or_fill){
  2591. case "fill":
  2592. ctx.fillStyle = c;
  2593. ctx.fill();
  2594. break
  2595. case "stroke":
  2596. ctx.lineWidth = _lineWidth;
  2597. ctx.strokeStyle = c;
  2598. ctx.stroke();
  2599. ctx.lineWidth = original_lw;
  2600. break
  2601. }
  2602. ctx.globalAlpha = original_ga;
  2603. }
  2604.  
  2605. function ctx_text(fcolor, scolor, lineWidth, font, text, textX, textY) {
  2606. deep_debug('called crx_text with: ', fcolor, scolor, lineWidth, font, text, textX, textY);
  2607. ctx.fillStyle = fcolor;
  2608. ctx.lineWidth = lineWidth;
  2609. ctx.font = font;
  2610. ctx.strokeStyle = scolor;
  2611. ctx.strokeText(`${text}`, textX, textY)
  2612. ctx.fillText(`${text}`, textX, textY)
  2613. }
  2614.  
  2615. function ctx_rect(x, y, a, b, c) {
  2616. deep_debug('called ctx_rect with: ', x, y, a, b, c);
  2617. ctx.beginPath();
  2618. ctx.strokeStyle = c;
  2619. ctx.strokeRect(x, y, a, b);
  2620. }
  2621.  
  2622. function transparent_rect_fill(x, y, a, b, scolor, fcolor, opacity){
  2623. deep_debug('called transparent_rect_fill with: ', x, y, a, b, scolor, fcolor, opacity);
  2624. ctx.beginPath();
  2625. ctx.rect(x, y, a, b);
  2626.  
  2627. // Set stroke opacity
  2628. ctx.globalAlpha = 1;// Reset to 1 for stroke, or set as needed
  2629. ctx.strokeStyle = scolor;
  2630. ctx.stroke();
  2631.  
  2632. // Set fill opacity
  2633. ctx.globalAlpha = opacity;// Set the opacity for the fill color
  2634. ctx.fillStyle = fcolor;
  2635. ctx.fill();
  2636.  
  2637. // Reset globalAlpha back to 1 for future operations
  2638. ctx.globalAlpha = 1;
  2639. }
  2640.  
  2641. //key visualiser
  2642. let ctx_wasd = {
  2643. square_sizes: { //in windowScaling
  2644. a: 50,
  2645. b: 50
  2646. },
  2647. text_props: {
  2648. lineWidth: 3,
  2649. font: 1 + "em Ubuntu",
  2650. },
  2651. square_colors: {
  2652. stroke: "black",
  2653. unpressed: "yellow",
  2654. pressed: "orange"
  2655. },
  2656. text_colors: {
  2657. stroke: "black",
  2658. unpressed: "orange",
  2659. pressed: "red"
  2660. },
  2661. w: {
  2662. x: 300,
  2663. y: 200,
  2664. pressed: false,
  2665. text: 'W'
  2666. },
  2667. a: {
  2668. x: 350,
  2669. y: 150,
  2670. pressed: false,
  2671. text: 'A'
  2672. },
  2673. s: {
  2674. x: 300,
  2675. y: 150,
  2676. pressed: false,
  2677. text: 'S'
  2678. },
  2679. d: {
  2680. x: 250,
  2681. y: 150,
  2682. pressed: false,
  2683. text: 'D'
  2684. },
  2685. l_m: {
  2686. x: 350,
  2687. y: 75,
  2688. pressed: false,
  2689. text: 'LMC'
  2690. },
  2691. r_m: {
  2692. x: 250,
  2693. y: 75,
  2694. pressed: false,
  2695. text: 'RMC'
  2696. },
  2697. }
  2698.  
  2699. function visualise_keys(){
  2700. let keys = ['w', 'a', 's', 'd', 'l_m', 'r_m'];
  2701. let l = keys.length;
  2702. for(let i = 0; i < l; i++){
  2703. let args = {
  2704. x: canvas.width - dim_c.windowScaling_2_canvas(ctx_wasd[keys[i]].x),
  2705. y: canvas.height - dim_c.windowScaling_2_canvas(ctx_wasd[keys[i]].y),
  2706. a: dim_c.windowScaling_2_canvas(ctx_wasd.square_sizes.a),
  2707. b: dim_c.windowScaling_2_canvas(ctx_wasd.square_sizes.b),
  2708. s_c: ctx_wasd.square_colors.stroke,
  2709. f_c: ctx_wasd[keys[i]].pressed? ctx_wasd.square_colors.pressed : ctx_wasd.square_colors.unpressed,
  2710. t_s: ctx_wasd.text_colors.stroke,
  2711. t_f: ctx_wasd[keys[i]].pressed? ctx_wasd.text_colors.pressed : ctx_wasd.text_colors.unpressed,
  2712. t_lineWidth: ctx_wasd.text_props.lineWidth,
  2713. t_font: ctx_wasd.text_props.font,
  2714. text: ctx_wasd[keys[i]].text,
  2715. opacity: 0.25
  2716. }
  2717. deep_debug(args);
  2718. transparent_rect_fill(
  2719. args.x,
  2720. args.y,
  2721. args.a,
  2722. args.b,
  2723. args.s_c,
  2724. args.f_c,
  2725. args.opacity
  2726. );
  2727. ctx_text(
  2728. args.t_f,
  2729. args.t_s,
  2730. args.t_lineWidth,
  2731. args.t_font,
  2732. args.text,
  2733. args.x+(args.a/2),
  2734. args.y+(args.b/2)
  2735. );
  2736. }
  2737. }
  2738.  
  2739. //Key Binds for Tank Upgrading
  2740. let selected_box = null;
  2741. let _bp = { //box parameters
  2742. startX: 47,
  2743. startY: 67,
  2744. distX: 13,
  2745. distY: 9,
  2746. width: 86,
  2747. height: 86,
  2748. outer_xy: 2
  2749. }
  2750.  
  2751. let _bo = { //box offsets
  2752. offsetX: _bp.width + (_bp.outer_xy * 2) + _bp.distX,
  2753. offsetY: _bp.height + (_bp.outer_xy * 2) + _bp.distY
  2754. }
  2755.  
  2756. function step_offset(steps, offset){
  2757. let final_offset = 0;
  2758. switch(offset){
  2759. case "x":
  2760. final_offset = _bp.startX + (steps * _bo.offsetX);
  2761. break
  2762. case "y":
  2763. final_offset = _bp.startY + (steps * _bo.offsetY);
  2764. break
  2765. }
  2766. return final_offset;
  2767. }
  2768.  
  2769. const boxes = [
  2770. {
  2771. color: "lightblue",
  2772. LUcornerX: _bp.startX,
  2773. LUcornerY: _bp.startY,
  2774. KeyBind: "R"
  2775. },
  2776. {
  2777. color: "green",
  2778. LUcornerX: _bp.startX + _bo.offsetX,
  2779. LUcornerY: _bp.startY,
  2780. KeyBind: "T"
  2781. },
  2782. {
  2783. color: "red",
  2784. LUcornerX: _bp.startX,
  2785. LUcornerY: _bp.startY + _bo.offsetY,
  2786. KeyBind: "F"
  2787. },
  2788. {
  2789. color: "yellow",
  2790. LUcornerX: _bp.startX + _bo.offsetX,
  2791. LUcornerY: _bp.startY + _bo.offsetY,
  2792. KeyBind: "G"
  2793. },
  2794. {
  2795. color: "blue",
  2796. LUcornerX: _bp.startX,
  2797. LUcornerY: step_offset(2, "y"),
  2798. KeyBind: "V"
  2799. },
  2800. {
  2801. color: "purple",
  2802. LUcornerX: _bp.startX + _bo.offsetX,
  2803. LUcornerY: step_offset(2, "y"),
  2804. KeyBind: "B"
  2805. }
  2806. ]
  2807.  
  2808. //upgrading Tank logic
  2809. function upgrade_get_coords(color){
  2810. let l = boxes.length;
  2811. let upgrade_coords = {x: "not defined", y: "not defined"};
  2812. for(let i = 0; i < l; i++){
  2813. if(boxes[i].color === color){
  2814. upgrade_coords.x = dim_c.windowScaling_2_window(boxes[i].LUcornerX + (_bp.width/2));
  2815. upgrade_coords.y = dim_c.windowScaling_2_window(boxes[i].LUcornerY + (_bp.height/2));
  2816. }
  2817. }
  2818. deep_debug(upgrade_coords);
  2819. return upgrade_coords;
  2820. }
  2821.  
  2822. function upgrade(color, delay = 100, cdelay1, cdelay2){
  2823. let u_coords = upgrade_get_coords(color);
  2824. //ghost_click_at('extern', u_coords.x, u_coords.y, cdelay1, cdelay2);
  2825. click_at('extern', u_coords.x, u_coords.y, cdelay1, cdelay2); //using this since ghost_click was patched
  2826. }
  2827. window.upgrade = upgrade;
  2828.  
  2829. function visualise_tank_upgrades(){
  2830. let l = boxes.length;
  2831. for (let i = 0; i < l; i++) {
  2832. let coords = upgrade_get_coords(boxes[i].color);
  2833. ctx_text(boxes[i].color, "black", 6, 1.5 + "em Ubuntu", `[${boxes[i].KeyBind}]`, coords.x, coords.y);
  2834. }
  2835. }
  2836.  
  2837. function check_tu_KeyBind(_KeyBind){
  2838. let l = boxes.length;
  2839. for (let i = 0; i < l; i++) {
  2840. if(_KeyBind === `Key${boxes[i].KeyBind}`){
  2841. deep_debug(_KeyBind, `Key${boxes[i].KeyBind}`, _KeyBind === `Key${boxes[i].KeyBind}`);
  2842. upgrade(boxes[i].color);
  2843. }
  2844. }
  2845. }
  2846.  
  2847. document.body.addEventListener("keydown", function(e) {
  2848. switch(e.code){
  2849. case "KeyW":
  2850. ctx_wasd.w.pressed = true;
  2851. break
  2852. case "KeyA":
  2853. ctx_wasd.a.pressed = true;
  2854. break
  2855. case "KeyS":
  2856. ctx_wasd.s.pressed = true;
  2857. break
  2858. case "KeyD":
  2859. ctx_wasd.d.pressed = true;
  2860. break
  2861. }
  2862. if(modules.Functional.Tank_upgrades.settings.Tank_upgrades.active){
  2863. check_tu_KeyBind(e.code);
  2864. }
  2865. });
  2866.  
  2867. document.body.addEventListener("keyup", function(e) {
  2868. deep_debug(`unpressed ${e.code}`);
  2869. switch(e.code){
  2870. case "KeyW":
  2871. ctx_wasd.w.pressed = false;
  2872. break
  2873. case "KeyA":
  2874. ctx_wasd.a.pressed = false;
  2875. break
  2876. case "KeyS":
  2877. ctx_wasd.s.pressed = false;
  2878. break
  2879. case "KeyD":
  2880. ctx_wasd.d.pressed = false;
  2881. break
  2882. }
  2883. deep_debug('====DID UNPRESS??', ctx_wasd.w.pressed, ctx_wasd.a.pressed, ctx_wasd.s.pressed, ctx_wasd.d.pressed);
  2884. });
  2885.  
  2886. document.body.addEventListener("mousedown", function(e) {
  2887. switch(e.button){
  2888. case 0:
  2889. ctx_wasd.l_m.pressed = true;
  2890. break
  2891. case 2:
  2892. ctx_wasd.r_m.pressed = true;
  2893. break
  2894. }
  2895. });
  2896.  
  2897. document.body.addEventListener("mouseup", function(e) {
  2898. switch(e.button){
  2899. case 0:
  2900. ctx_wasd.l_m.pressed = false;
  2901. break
  2902. case 2:
  2903. ctx_wasd.r_m.pressed = false;
  2904. break
  2905. }
  2906. });
  2907. //destroyer cooldown visualiser
  2908. let times_watcher = {
  2909. waiting: false,
  2910. cooldowns: [2540, 2311, 2201, 1911, 1760, 1681, 1560, 1381],
  2911. }
  2912.  
  2913. function draw_destroyer_cooldown(){
  2914. let c = times_watcher.waiting? 'red' : 'lime' ;
  2915. ctx_arc(inputs.mouse.real.x, inputs.mouse.real.y, 50*player.dpr, 0, 2 * Math.PI, false, c, 'fill', 0.3);
  2916. }
  2917.  
  2918. function handle_cooldown(_cd){
  2919. times_watcher.waiting = true;
  2920. setTimeout(() => {
  2921. times_watcher.waiting = false;
  2922. }, _cd);
  2923. }
  2924. document.body.addEventListener("mousedown", function(e) {
  2925. if(e.button === 0 && !times_watcher.waiting && player.inGame){
  2926. let _cd = times_watcher.cooldowns[modules.Visual.destroyer_cooldown.settings.reload.selected];
  2927. handle_cooldown(_cd);
  2928. }
  2929. });
  2930.  
  2931. document.body.addEventListener("keydown", function(e){
  2932. if(e.keyCode === 32 && !times_watcher.waiting && player.inGame){
  2933. let _cd = times_watcher.cooldowns[modules.Visual.destroyer_cooldown.settings.reload.selected];
  2934. handle_cooldown(_cd);
  2935. }
  2936. });
  2937.  
  2938. //debug function
  2939. function draw_canvas_debug(){
  2940. let temp_textX = canvas.width/2, temp_textY = canvas.height/2;
  2941. let temp_texts = [
  2942. `Your Real mouse position! x: ${inputs.mouse.real.x} y: ${inputs.mouse.real.y}`,
  2943. `Scaled down for the game! x: ${(inputs.mouse.game.x).toFixed(2)} y: ${(inputs.mouse.game.y).toFixed(2)}`,
  2944. `player values! DPR: ${player.dpr} base value: ${player.base_value} ui scale: ${player.ui_scale}`,
  2945. `window Scaling: ${windowScaling()}`,
  2946. `Canvas! width: ${canvas.width} height: ${canvas.height}`,
  2947. `Window! width: ${window.innerWidth} height: ${window.innerHeight}`,
  2948. `Ratio between Window and Canvas: ${dim_c.window_2_canvas(1)}`,
  2949. `Inputs Moving_game: ${inputs.moving_game.KeyW} ${inputs.moving_game.KeyA} ${inputs.moving_game.KeyS} ${inputs.moving_game.KeyD} ${inputs.moving_game.ArrowUp} ${inputs.moving_game.ArrowRight} ${inputs.moving_game.ArrowDown} ${inputs.moving_game.ArrowLeft}`
  2950. ];
  2951. let l = temp_texts.length;
  2952. let _d = (canvas.height/3)/l;
  2953. for(let i = 0; i < l; i++){
  2954. ctx_text('yellow', 'black', 5, 1.5 + "em Ubuntu", temp_texts[i], temp_textX, temp_textY + (i * _d));
  2955. }
  2956. //drawing line from your real mouse position, to your ingame mouse position
  2957. ctx.beginPath();
  2958. ctx.strokeStyle = "Red";
  2959. ctx.moveTo(inputs.mouse.real.x, inputs.mouse.real.y);
  2960. ctx.lineTo(inputs.mouse.game.x*player.dpr, inputs.mouse.game.y*player.dpr);
  2961. ctx.stroke();
  2962. }
  2963.  
  2964. //CANVAS API REQUIRED FOR EVERYTHING HERE
  2965.  
  2966. //maths helper functions
  2967. function get_average(points) {
  2968. let result = [0, 0];
  2969. for (let point of points) {
  2970. result[0] += point[0];
  2971. result[1] += point[1];
  2972. }
  2973. result[0] /= points.length;
  2974. result[1] /= points.length;
  2975. return result;
  2976. }
  2977.  
  2978. //api detecting logic
  2979. let current_tries = 0;
  2980. let notify_after_tries = 100;
  2981. let notified_about_missing = false;
  2982. let api_loaded = false;
  2983. let api_missing = false;
  2984.  
  2985. function notify_about_missing(){
  2986. if(notified_about_missing) return;
  2987. alert('Missing Canvas Api to run addon script, join our discord server to get it: https://discord.gg/S3ZzgDNAuG');
  2988. notified_about_missing = true;
  2989. }
  2990.  
  2991. function await_api(){
  2992. if(current_tries > notify_after_tries) {
  2993. api_missing = true;
  2994. return;
  2995. }
  2996. current_tries++;
  2997. api_loaded = !!window.ripsaw_api;
  2998. console.log('did api load?', api_loaded);
  2999. window.ripsaw_api ? clearInterval(interval_api) : setTimeout(await_api, 100);
  3000. }
  3001. var interval_api = setInterval(await_api, 100);
  3002.  
  3003. //aim lines
  3004. function draw_aim_lines(len_factor=1){
  3005. let temp_tanks = window.ripsaw_api.get_tanks();
  3006. if(temp_tanks.length <= 0) return;
  3007. for(let temp_tank of temp_tanks){
  3008. for(let temp_turret of temp_tank.turrets){
  3009. switch(temp_turret.source_array){
  3010. case "rectangular":{
  3011. let diff = {
  3012. x: temp_turret.coords.endX - temp_turret.coords.startX,
  3013. y: temp_turret.coords.endY - temp_turret.coords.startY,
  3014. };
  3015. ctx.moveTo(temp_turret.coords.startX, temp_turret.coords.startY);
  3016. ctx.lineTo(temp_turret.coords.startX + (diff.x * len_factor), temp_turret.coords.startY + (diff.y * len_factor));
  3017. ctx_text('yellow', 'black', 5, 1.5 + "em Ubuntu", temp_tank.name, temp_turret.coords.startX + (diff.x * len_factor), temp_turret.coords.startY + (diff.y * len_factor));
  3018. ctx.stroke();
  3019. }
  3020. break
  3021. case "other":{
  3022. if(temp_turret.points.length < 4) return console.warn('less than 4 points');
  3023. let start = get_average([temp_turret.points[0], temp_turret.points[3]]);
  3024. let end = get_average([temp_turret.points[1], temp_turret.points[2]]);
  3025. let diff = [
  3026. end[0]-start[0],
  3027. end[1]-start[1]
  3028. ];
  3029. ctx.moveTo(...start);
  3030. ctx.lineTo(start[0]+(diff[0] * len_factor), start[1]+(diff[1] * len_factor));
  3031. ctx_text('yellow', 'black', 5, 1.5 + "em Ubuntu", temp_tank.name, start[0]+(diff[0] * len_factor), start[1]+(diff[1] * len_factor));
  3032. ctx.stroke();
  3033. }
  3034. break
  3035. }
  3036. }
  3037. }
  3038. }
  3039.  
  3040. //Farm Bot
  3041. let get_closest_update_notified = false;
  3042. let last_shape = [0, 0];
  3043. let resetting_farmbot_movement_complete = false;
  3044.  
  3045. let exposed_sm = {
  3046. points: null,
  3047. closest: null,
  3048. }
  3049.  
  3050. function handle_farmbot_aim(){
  3051. window.requestAnimationFrame(handle_farmbot_aim);
  3052. if(player.connected && player.inGame){
  3053. if(last_shape.length > 0 && modules.Addons.farm_bot.settings.toggle_farm_bot.active){
  3054. let temp = [dim_c.canvas_2_window(last_shape[0]), dim_c.canvas_2_window(last_shape[1])];
  3055. apply_force(...temp);
  3056. i_e('extern', 'onTouchMove', -1, ...temp);
  3057. }else{
  3058. disable_force();
  3059. }
  3060. }
  3061. }
  3062. window.requestAnimationFrame(handle_farmbot_aim);
  3063.  
  3064. function simple_move(x, y){
  3065. let center = {x: canvas.width/2, y: canvas.height/2};
  3066. let len = Math.min(canvas.width, canvas.height)/3;
  3067. let a = {
  3068. posx: center.x + len,
  3069. posy: center.y + len,
  3070. negx: center.x - len,
  3071. negy: center.y - len,
  3072. }
  3073. //diagonals
  3074. let dia = {
  3075. posx: center.x + (len/3)*2,
  3076. posy: center.y + (len/3)*2,
  3077. negx: center.x - (len/3)*2,
  3078. negy: center.y - (len/3)*2,
  3079. }
  3080. let points = {
  3081. LeftTop: {x: dia.negx, y: dia.negy},
  3082. CenterTop: {x: center.x, y: a.negy},
  3083. RightTop: {x: dia.posx, y: dia.negy},
  3084. RightCenter: {x: a.posx, y: center.y},
  3085. RightBottom: {x: dia.posx, y: dia.posy},
  3086. CenterBottom: {x: center.x, y: a.posy},
  3087. LeftBottom: {x: dia.negx, y: dia.posy},
  3088. LeftCenter: {x: a.negx, y: center.y},
  3089. }
  3090. let closest = {
  3091. key: null,
  3092. distance: canvas.width+canvas.height, //ensure to make it large at the start
  3093. }
  3094. let activate_keys = (keys) => {
  3095. let temp = ['KeyW', 'KeyA', 'KeyS', 'KeyD'];
  3096. for(let key of temp){
  3097. if(!document.hasFocus()){
  3098. inputs.moving_game[key] = false;
  3099. one_time_notification('your tab is running in the background!', notification_rgbs.warning, 5000);
  3100. }else{
  3101. notifications.length = 0;
  3102. }
  3103. //press keys from arguments
  3104. if(keys.includes(key) && !inputs.moving_game[key]){
  3105. extern.onKeyDown(diep_keys[key], fingerprint);
  3106. //unpress the rest (of temp) if it's being pressed
  3107. }else if(!keys.includes(key) && inputs.moving_game[key]){
  3108. extern.onKeyUp(diep_keys[key], fingerprint);
  3109. }
  3110. }
  3111. }
  3112. for(let point in points){
  3113. let d = calculate_distance(points[point].x, points[point].y, x, y);
  3114. if(closest.distance > d){
  3115. closest.key = point;
  3116. closest.distance = d;
  3117. }
  3118. }
  3119. exposed_sm.closest = closest;
  3120. exposed_sm.points = points;
  3121. let selected_keys = [];
  3122. switch(closest.key){
  3123. case 'LeftTop':
  3124. selected_keys[0] = 'KeyW';
  3125. selected_keys[1] = 'KeyA';
  3126. break
  3127. case 'CenterTop':
  3128. selected_keys[0] = 'KeyW';
  3129. break
  3130. case 'RightTop':
  3131. selected_keys[0] = 'KeyW';
  3132. selected_keys[1] = 'KeyD';
  3133. break
  3134. case 'RightCenter':
  3135. selected_keys[0] = 'KeyD';
  3136. break
  3137. case 'RightBottom':
  3138. selected_keys[0] = 'KeyS';
  3139. selected_keys[1] = 'KeyD';
  3140. break
  3141. case 'CenterBottom':
  3142. selected_keys[0] = 'KeyS';
  3143. break
  3144. case 'LeftBottom':
  3145. selected_keys[0] = 'KeyS';
  3146. selected_keys[1] = 'KeyA';
  3147. break
  3148. case 'LeftCenter':
  3149. selected_keys[0] = 'KeyA';
  3150. break
  3151. }
  3152. activate_keys(selected_keys);
  3153. }
  3154.  
  3155. function handle_farmbot_movement(){
  3156. window.requestAnimationFrame(handle_farmbot_movement);
  3157. if(modules.Addons.farm_bot.settings.toggle_farm_bot.active){
  3158. if(player.inGame && player.connected){
  3159. resetting_farmbot_movement_complete = false;
  3160. //moving to shape
  3161. if(modules.Addons.farm_bot.settings.move_to_shape.active){
  3162. if(modules.Mouse.Move_2_mouse.settings.Move_2_mouse.active){
  3163. one_time_notification('canceled, disable move to mouse for this to work', notification_rgbs.warning, 5000);
  3164. modules.Addons.farm_bot.settings.move_to_shape.active = false;
  3165. modules.Addons.farm_bot.settings.move_to_shape.update_toggle(modules.Addons.farm_bot.settings.move_to_shape.checkbox);
  3166. return
  3167. }
  3168. if(last_shape.length === 0){
  3169. reset_moving_game(['KeyW', 'KeyA', 'KeyS', 'KeyD']);
  3170. }else{
  3171. simple_move(...last_shape);
  3172. }
  3173. }else{
  3174. reset_moving_game(['KeyW', 'KeyA', 'KeyS', 'KeyD']);
  3175. }
  3176. }
  3177. }else{
  3178. if(!resetting_farmbot_movement_complete){
  3179. reset_moving_game(['KeyW', 'KeyA', 'KeyS', 'KeyD']);
  3180. resetting_farmbot_movement_complete = true;
  3181. }
  3182. }
  3183. }
  3184. window.requestAnimationFrame(handle_farmbot_movement);
  3185.  
  3186. function start_farming(shape_types){
  3187. //I commented this function previously, so I had to update it with the uncommented version
  3188. if(!get_closest_update_notified && window.ripsaw_api && !window.ripsaw_api.get_closest){
  3189. get_closest_update_notified = true;
  3190. return alert('please update the canvas API');
  3191. }
  3192. if(player.inGame && player.connected){
  3193. //argument checking to avoid errors
  3194. let allowed_types = ['crashers', 'pentagons', 'squares', 'triangles'];
  3195. if(!(shape_types instanceof Array)) return console.warn('expected Array at start_farming, quitting...');
  3196. let api_response = window.ripsaw_api.get_shapes();
  3197. let temp_arr = [];
  3198. for(let temp_arg of shape_types){
  3199. if(!allowed_types.includes(temp_arg)) return console.warn(temp_arg, ' was not found in allowed types at start_farming, quitting...');
  3200. if(api_response[temp_arg].length > 0){ //push only if array not empty
  3201. temp_arr.push(...api_response[temp_arg]);
  3202. }
  3203. }
  3204. if(temp_arr.length <= 0) {
  3205. //let the script know that there are no shapes
  3206. last_shape.length = 0;
  3207. return;
  3208. }
  3209. let lol = window.ripsaw_api.get_closest(temp_arr);
  3210. last_shape[0] = lol[0];
  3211. last_shape[1] = lol[1];
  3212. //drawing
  3213. let you = window.ripsaw_api.get_your_body().front_arc;
  3214. if(modules.Addons.farm_bot.settings.toggle_lines.active && you && you.x && you.y){
  3215. ctx.beginPath();
  3216. ctx.strokeStyle = "purple";
  3217. ctx.moveTo(you.x, you.y);
  3218. ctx.lineTo(...last_shape);
  3219. ctx.stroke();
  3220. }
  3221. }
  3222. }
  3223.  
  3224. //canvas gui (try to keep this in the end
  3225. const world_map = {
  3226. min: {x: 0, y:0},
  3227. max: {x:26000, y:26000},
  3228. }
  3229. setTimeout(() => {
  3230. let gui = () => {
  3231. if (player.inGame) {
  3232. //DEBUG start
  3233. if(deep_debug_properties.canvas){
  3234. draw_canvas_debug();
  3235. }
  3236. //DEBUG end
  3237. if(modules.Functional.Tank_upgrades.settings.visualise.active){
  3238. visualise_tank_upgrades();
  3239. }
  3240. if (modules.Visual.Key_inputs_visualiser.active) {
  3241. visualise_keys();
  3242. }
  3243. if (modules.Visual.destroyer_cooldown.settings.destroyer_cooldown.active){
  3244. draw_destroyer_cooldown();
  3245. }
  3246. if(modules.Mouse.Move_2_mouse.settings.Move_2_mouse.active && modules.Mouse.Move_2_mouse.settings.toggle_debug.active ){
  3247. //move_to_mouse
  3248. let center = { x: canvas.width / 2, y: canvas.height / 2 };
  3249. let target = { x: inputs.mouse.real.x, y: inputs.mouse.real.y };
  3250. let full_distance = calculate_distance(center.x, center.y, target.x, target.y);
  3251. let partial_distance = full_distance/approximation_factor;
  3252. let step = { x: (target.x - center.x) / partial_distance, y: (target.y - center.y) / partial_distance };
  3253. //main line
  3254. ctx.beginPath();
  3255. ctx.strokeStyle = "black";
  3256. ctx.moveTo(center.x, center.y);
  3257. ctx.lineTo(target.x, target.y);
  3258. ctx.stroke();
  3259. //other lines
  3260. ctx.beginPath();
  3261. ctx.strokeStyle = "yellow";
  3262. ctx.moveTo(center.x, center.y);
  3263. let temp = {
  3264. x: center.x,
  3265. y: center.y,
  3266. }
  3267. let l = Math.floor(partial_distance);
  3268. for(let i = 0; i < l; i++){
  3269. temp.x += step.x * (distance_time_factor/10);
  3270. ctx.lineTo(temp.x, temp.y);
  3271. temp.y += step.y * (distance_time_factor/10);
  3272. ctx.lineTo(temp.x, temp.y);
  3273. }
  3274. ctx.stroke();
  3275. }
  3276. if(modules.Addons.aim_lines.settings.toggle_aim_lines.active){
  3277. if(api_missing) {
  3278. notify_about_missing();
  3279. return;
  3280. }
  3281. draw_aim_lines(modules.Addons.aim_lines.settings.adjust_length.selected);
  3282. }
  3283. if(modules.Addons.farm_bot.settings.toggle_farm_bot.active){
  3284. if(api_missing) {
  3285. notify_about_missing();
  3286. return;
  3287. }
  3288. if(modules.Addons.farm_bot.settings.toggle_debug.active){
  3289. //visualise the script logic
  3290. for(let point in exposed_sm.points){
  3291. //white line from closest direction to shape
  3292. if(point === exposed_sm.closest.key){
  3293. ctx.beginPath();
  3294. ctx.strokeStyle = "white";
  3295. ctx.moveTo(last_shape[0], last_shape[1]);
  3296. ctx.lineTo(exposed_sm.points[point].x, exposed_sm.points[point].y);
  3297. ctx.stroke();
  3298. }
  3299. //all directions black, closest red
  3300. ctx.beginPath();
  3301. ctx.strokeStyle = (point === exposed_sm.closest.key && last_shape.length > 0) ? "red" : "black";
  3302. ctx.moveTo(canvas.width/2, canvas.height/2);
  3303. ctx.lineTo(exposed_sm.points[point].x, exposed_sm.points[point].y);
  3304. ctx.stroke();
  3305. }
  3306. }
  3307. let temp_shape_array = [];
  3308. if(!modules.Addons.farm_bot.settings.toggle_squares.active) temp_shape_array.push('squares');
  3309. if(!modules.Addons.farm_bot.settings.toggle_crashers.active) temp_shape_array.push('crashers');
  3310. if(!modules.Addons.farm_bot.settings.toggle_pentagons.active) temp_shape_array.push('pentagons');
  3311. if(!modules.Addons.farm_bot.settings.toggle_triangles.active) temp_shape_array.push('triangles');
  3312. if(temp_shape_array.length === 0) one_time_notification("You're currently ignoring all shapes, disable at least one of them or the bot won't shoot", notification_rgbs.warning, 5000);
  3313. start_farming(temp_shape_array);
  3314. }
  3315. if(modules.Addons.world_coords.settings.toggle_world_coords.active){
  3316. if(api_missing) {
  3317. notify_about_missing();
  3318. return;
  3319. }
  3320. //calculate
  3321. let minimap = window.ripsaw_api.get_minimap().corners;
  3322. let you = window.ripsaw_api.get_arrows().minimap.center;
  3323. let unscaled = {
  3324. x: you[0]-minimap.top_left[0],
  3325. y: you[1]-minimap.top_left[1],
  3326. max: {x: minimap.top_right[0]-minimap.top_left[0], y: minimap.bottom_left[1]-minimap.top_left[1]},
  3327. }
  3328. let precision = modules.Addons.world_coords.settings.precision.selected;
  3329. let world = {
  3330. x: ((unscaled.x/unscaled.max.x)*world_map.max.x).toFixed(precision),
  3331. y: ((unscaled.y/unscaled.max.y)*world_map.max.y).toFixed(precision),
  3332. }
  3333. ctx.beginPath();
  3334. ctx_text('gray', 'black', 3, 1 + "em Ubuntu", `x: ${world.x} y: ${world.y}`, minimap.top_left[0], minimap.top_left[1]-((canvas.height-minimap.top_left[1])*0.3));
  3335. }
  3336. }
  3337. window.requestAnimationFrame(gui); // Start animation loop
  3338. };
  3339. gui();
  3340. }, 500); // Delay before starting the rendering
  3341.  
  3342. // START ZOOM SCROLL FUNCTIONS V3
  3343.  
  3344. const zoomScrollStep = 5;
  3345. const minZoomValue = 10;
  3346. const maxZoomValue = 500;
  3347.  
  3348. let zoomIndicatorElement = null;
  3349. let zoomIndicatorTimeout = null;
  3350.  
  3351. function ensureZoomIndicatorExists() {
  3352. if (!zoomIndicatorElement) {
  3353. zoomIndicatorElement = document.createElement('div');
  3354. zoomIndicatorElement.id = 'zoom-scroll-indicator-v3';
  3355. Object.assign(zoomIndicatorElement.style, {
  3356. position: 'fixed',
  3357. top: '15px',
  3358. left: '50%',
  3359. transform: 'translateX(-50%)',
  3360. backgroundColor: 'rgba(38, 38, 38, 0.9)',
  3361. color: 'white',
  3362. padding: '6px 15px',
  3363. borderRadius: '0px',
  3364. borderBottom: '3px solid lime',
  3365. fontFamily: '"Ubuntu", Calibri, Arial, sans-serif',
  3366. fontSize: '18px',
  3367. fontWeight: 'bold',
  3368. zIndex: '1001',
  3369. opacity: '0',
  3370. pointerEvents: 'none',
  3371. transition: 'opacity 2s ease-out, top 0.2s ease-out',
  3372. textAlign: 'center',
  3373. minWidth: '80px'
  3374. });
  3375. document.body.appendChild(zoomIndicatorElement);
  3376. }
  3377. }
  3378.  
  3379. function showZoomIndicator(zoomValue) {
  3380. ensureZoomIndicatorExists();
  3381.  
  3382. zoomIndicatorElement.style.top = '10px';
  3383. zoomIndicatorElement.textContent = `🔍 ${zoomValue}%`;
  3384. zoomIndicatorElement.style.opacity = '1';
  3385.  
  3386. if (zoomIndicatorTimeout) {
  3387. clearTimeout(zoomIndicatorTimeout);
  3388. }
  3389.  
  3390. setTimeout(() => {
  3391. zoomIndicatorElement.style.top = '15px';
  3392. }, 50);
  3393.  
  3394.  
  3395. zoomIndicatorTimeout = setTimeout(() => {
  3396. zoomIndicatorElement.style.opacity = '0';
  3397. zoomIndicatorElement.style.top = '10px';
  3398. zoomIndicatorTimeout = null;
  3399. }, 100);
  3400. }
  3401.  
  3402.  
  3403. function handleZoomScroll(e) {
  3404. if (player.inGame && modules.Functional && modules.Functional.Zoom) {
  3405. e.preventDefault();
  3406. let currentZoom = parseFloat(modules.Functional.Zoom.value);
  3407. let newZoom = currentZoom;
  3408. if (e.deltaY < 0) {
  3409. newZoom += zoomScrollStep;
  3410. } else if (e.deltaY > 0) {
  3411. newZoom -= zoomScrollStep;
  3412. }
  3413. newZoom = Math.max(minZoomValue, Math.min(maxZoomValue, newZoom));
  3414. newZoom = Math.round(newZoom);
  3415. if (newZoom !== currentZoom) {
  3416. modules.Functional.Zoom.value = newZoom;
  3417. showZoomIndicator(newZoom);
  3418. try {
  3419. const sliderElement = modules.Functional.Zoom.elements[1];
  3420. if (sliderElement && sliderElement.tagName === 'INPUT' && sliderElement.type === 'range') {
  3421. sliderElement.value = newZoom;
  3422. }
  3423. const titleElement = modules.Functional.Zoom.title.el;
  3424. if (titleElement) {
  3425. titleElement.innerHTML = `${modules.Functional.Zoom.name}: ${newZoom} %`;
  3426. }
  3427. } catch (error) {
  3428. console.warn("[Diep.io+ Zoom Scroll] Could not update GUI slider/title visually:", error);
  3429. }
  3430. }
  3431. }
  3432. }
  3433. document.body.addEventListener('wheel', handleZoomScroll, { passive: false });
  3434.  
  3435. // END ZOOM SCROLL FUNCTIONS V3
  3436.  
  3437. //INTERVALS HANDLE
  3438. let active_static_intervals = new WeakSet();
  3439. let static_intervals = {
  3440. detect_refresh: {
  3441. callbackFunc: detect_refresh,
  3442. wait: 100,
  3443. id: null,
  3444. },
  3445. check_gamemode: {
  3446. callbackFunc: check_gamemode,
  3447. wait: 250,
  3448. id: null,
  3449. },
  3450. check_final_score: {
  3451. callbackFunc: check_final_score,
  3452. wait: 100,
  3453. id: null,
  3454. },
  3455. bot_tab_active_check: {
  3456. callbackFunc: bot_tab_active_check,
  3457. wait: 1000,
  3458. id: null,
  3459. },
  3460. update_diep_console: {
  3461. callbackFunc: update_diep_console,
  3462. wait: 100,
  3463. id: null,
  3464. },
  3465. sandbox_lvl_up: {
  3466. callbackFunc: sandbox_lvl_up,
  3467. wait: 500,
  3468. id: null,
  3469. },
  3470. respawn: {
  3471. callbackFunc: respawn,
  3472. wait: 1000,
  3473. id: null,
  3474. },
  3475. AntiAfkTimeout: {
  3476. callbackFunc: AntiAfkTimeout,
  3477. wait: 1000,
  3478. id: null,
  3479. },
  3480. HandleZoom: {
  3481. callbackFunc: HandleZoom,
  3482. wait: 100,
  3483. id: null,
  3484. },
  3485. };
  3486.  
  3487. function start_static_intervals(){
  3488. for(let i in static_intervals){
  3489. let temp = static_intervals[i];
  3490. if(!active_static_intervals.has(temp) && !temp.id){
  3491. temp.id = setInterval(temp.callbackFunc, temp.wait);
  3492. active_static_intervals.add(temp);
  3493. }
  3494. }
  3495. }
  3496.  
  3497. function start_static_interval(key){
  3498. let temp = static_intervals[key];
  3499. if(!temp) return console.warn('undefined interval');
  3500. if(!active_static_intervals.has(temp) && !temp.id){
  3501. temp.id = setInterval(temp.callbackFunc, temp.wait);
  3502. active_static_intervals.add(temp);
  3503. }
  3504. }
  3505.  
  3506. function clear_static_interval(key){
  3507. let temp = static_intervals[key];
  3508. if(!temp) return console.warn('undefined interval');
  3509. if(active_static_intervals.has(temp) && temp.id){
  3510. clearInterval(temp.id);
  3511. temp.id = null;
  3512. active_static_intervals.delete(temp);
  3513. }else{
  3514. return console.warn('interval was not active');
  3515. }
  3516. }
  3517.  
  3518.  
  3519. //init
  3520.  
  3521. function update_information() {
  3522. window.requestAnimationFrame(update_information);
  3523. let teams = ["blue", "red", "purple", "green"];
  3524. player.connected = !!window.lobby_ip;
  3525. player.connected? player.inGame = !!extern.doesHaveTank() : null;
  3526. player.name = document.getElementById("spawn-nickname").value;
  3527. player.team = teams[parseInt(_c.party_link.split('x')[1])];
  3528. player.gamemode = _c.active_gamemode;
  3529. player.ui_scale = parseFloat(localStorage.getItem("d:ui_scale"));
  3530. }
  3531. window.requestAnimationFrame(update_information);
  3532.  
  3533. function waitForConnection() {
  3534. if (player.connected) {
  3535. define_onTouch();
  3536. start_input_proxies();
  3537. start_zoom_proxy();
  3538. start_keyDown_Proxy();
  3539. start_keyUp_Proxy();
  3540. start_static_intervals();
  3541. } else {
  3542. setTimeout(waitForConnection, 100);
  3543. }
  3544. }
  3545. waitForConnection();