Diep.io+ (added Advanced Auto Respawn, Sandbox Arena size Increase, GUI Module settings)

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

当前为 2025-02-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Diep.io+ (added Advanced Auto Respawn, Sandbox Arena size Increase, GUI Module settings)
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.2.1.2
  5. // @description Quick Tank Upgrades, Highscore saver, Advanced Auto Respawn, Anti Aim, Zoom hack, Anti AFK Timeout, Sandbox Auto K, Sandbox Arena Increase
  6. // @author r!PsAw
  7. // @match https://diep.io/*
  8. // @icon https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQFMDAvSZe2hsFwAIeAPcDSNx8X2lUMp-rLPA&s
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. //This is just the beginning! :)
  14.  
  15. //inner script settings
  16. let deep_debug_properties = {
  17. active: false,
  18. }
  19.  
  20. function deep_debug(...args) {
  21. if (deep_debug_properties.active) {
  22. console.log(...args);
  23. }
  24. }
  25.  
  26. //Information for script
  27. let _c = window.__common__;
  28. let player = {
  29. connected: false,
  30. inGame: false,
  31. name: '',
  32. team: null,
  33. gamemode: null,
  34. ui_scale: 1,
  35. dpr: 1,
  36. };
  37.  
  38. function windowScaling() {
  39. const a = canvas.height / 1080;
  40. const b = canvas.width / 1920;
  41. return b < a ? a : b;
  42. }
  43.  
  44. //basic function to construct links
  45. function link(baseUrl, lobby, gamemode, team) {
  46. let str = "";
  47. str += baseUrl + "?s=" + lobby + "&g=" + gamemode + "&l=" + team;
  48. return str;
  49. }
  50.  
  51. function get_baseUrl() {
  52. return location.origin + location.pathname;
  53. }
  54.  
  55. function get_your_lobby() {
  56. return window.lobby_ip;
  57. }
  58.  
  59. function get_gamemode() {
  60. //return window.__common__.active_gamemode;
  61. return window.lobby_gamemode;
  62. }
  63.  
  64. function get_team() {
  65. return window.__common__.party_link;
  66. }
  67.  
  68. //dimensions
  69.  
  70. class dimensions_converter {
  71. constructor() {
  72. this.scalingFactor = null; //undetectable without bypass
  73. this.fieldFactor = null; //undetectable without bypass
  74. }
  75. canvas_2_window(a) {
  76. let b = a / (canvas.width / window.innerWidth);
  77. return b;
  78. }
  79.  
  80. window_2_canvas(a) {
  81. let b = a * (canvas.width / window.innerWidth);
  82. return b;
  83. }
  84.  
  85. windowScaling_2_window(a) {
  86. let b = (this.windowScaling_2_canvas(a)) / (canvas.width / window.innerWidth);
  87. return b;
  88. }
  89.  
  90. windowScaling_2_canvas(a) {
  91. let b = a * windowScaling();
  92. deep_debug('windowScaling_2_canvas called! a, b', a, b);
  93. return b;
  94. }
  95. /* DISABLED FOR NOW
  96. diepUnits_2_canvas(a) {
  97. let b = a / scalingFactor;
  98. return b;
  99. }
  100.  
  101. diepUnits_2_window(a) {
  102. let b = (this.diepUnits_2_canvas(a)) / (canvas.width / window.innerWidth);
  103. return b;
  104. }
  105.  
  106. window_2_diepUnits(a) {
  107. let b = (this.canvas_2_diepUnits(a)) * (canvas.width / window.innerWidth);
  108. return b;
  109. }
  110.  
  111. canvas_2_diepUnits(a) {
  112. let b = a * this.scalingFactor;
  113. return b;
  114. }
  115. */
  116.  
  117. window_2_windowScaling(a) {
  118. let b = (this.canvas_2_windowScaling(a)) * (canvas.width / window.innerWidth) * player.ui_scale;
  119. return b;
  120. }
  121.  
  122. canvas_2_windowScaling(a) {
  123. let b = a * windowScaling();
  124. return b;
  125. }
  126. /* DISABLED FOR NOW
  127. diepUnits_2_windowScaling(a) {
  128. let b = (this.diepUnits_2_canvas(a)) * this.fieldFactor;
  129. return b;
  130. }
  131.  
  132. windowScaling_2_diepUntis(a) {
  133. let b = (a / this.fieldFactor) * this.scalingFactor;
  134. return b;
  135. }
  136. */
  137. }
  138.  
  139. let dim_c = new dimensions_converter();
  140.  
  141. function i_e(type, key, ...args) {
  142. switch (type) {
  143. case "input":
  144. input[key](...args);
  145. break
  146. case "extern":
  147. extern[key](...args);
  148. break
  149. }
  150. }
  151.  
  152. let inputs = {
  153. mouse: {
  154. real: {
  155. x: 0,
  156. y: 0,
  157. },
  158. game: {
  159. x: 0,
  160. y: 0,
  161. },
  162. force: {
  163. x: 0,
  164. y: 0,
  165. },
  166. isForced: false,
  167. isFrozen: false,
  168. isShooting: false,
  169. original: {
  170. onTouchMove: null,
  171. onTouchStart: null,
  172. onTouchEnd: null,
  173. }
  174. },
  175. keys_pressed: [],
  176. }
  177.  
  178. function apply_force(x, y) {
  179. inputs.mouse.force = {
  180. x: x,
  181. y: y,
  182. }
  183. inputs.mouse.isForced = true;
  184. }
  185.  
  186. function disable_force() {
  187. inputs.mouse.isForced = false;
  188. }
  189.  
  190. const touchMethods = ['onTouchMove', 'onTouchStart', 'onTouchEnd'];
  191. let canvas = document.getElementById("canvas");
  192. let ctx = canvas.getContext('2d');
  193.  
  194. function define_onTouch() {
  195. touchMethods.forEach(function(method) {
  196. inputs.mouse.original[method] = input[method];
  197. deep_debug('defined input.', method);
  198. });
  199. }
  200.  
  201. function clear_onTouch() {
  202. touchMethods.forEach(function(method) {
  203. input[method] = () => {};
  204. });
  205. }
  206.  
  207. function redefine_onTouch() {
  208. touchMethods.forEach(function(method) {
  209. input[method] = inputs.mouse.original[method];
  210. });
  211. }
  212.  
  213. function start_input_proxies(_filter = false, _single = false, _method = null) {
  214. ((_filter || _single) && !_method) ? console.warn("missing _method at start_input_proxies"): null;
  215. let temp_methods = touchMethods;
  216. if (_filter) {
  217. temp_methods.filter((item) => item != _method);
  218. } else if (_single) {
  219. temp_methods = [_method];
  220. }
  221. temp_methods.forEach(function(method) {
  222. input[method] = new Proxy(input[method], {
  223. apply: function(definition, input_obj, args) {
  224. let x, y, type, new_args;
  225. if (inputs.mouse.isForced) {
  226. x = inputs.mouse.forced.x;
  227. y = inputs.mouse.forced.y;
  228. } else {
  229. x = args[1];
  230. y = args[2];
  231. }
  232. type = args[0];
  233. new_args = [type, x / player.dpr, y / player.dpr];
  234. inputs.mouse.game = {
  235. x: new_args[1],
  236. y: new_args[2],
  237. }
  238. return Reflect.apply(definition, input_obj, new_args);
  239. }
  240. });
  241. });
  242. }
  243.  
  244. function update_information() {
  245. window.requestAnimationFrame(update_information);
  246. let teams = ["blue", "red", "purple", "green"];
  247. player.connected = !!window.lobby_ip;
  248. player.connected? player.inGame = !!extern.doesHaveTank() : null;
  249. player.name = document.querySelector("#spawn-nickname").value;
  250. player.team = teams[parseInt(_c.party_link.split('x')[1])];
  251. player.gamemode = _c.active_gamemode;
  252. player.ui_scale = parseFloat(localStorage.getItem("d:ui_scale"))
  253. }
  254. window.requestAnimationFrame(update_information);
  255.  
  256. function waitForConnection() {
  257. if (player.connected) {
  258. define_onTouch();
  259. start_input_proxies();
  260. } else {
  261. setTimeout(waitForConnection, 100);
  262. }
  263. }
  264. waitForConnection();
  265.  
  266. //GUI
  267. function n2id(string) {
  268. return string.toLowerCase().replace(/ /g, "-");
  269. }
  270.  
  271. class El {
  272. constructor(
  273. name,
  274. type,
  275. el_color,
  276. width,
  277. height,
  278. opacity = "1",
  279. zindex = "100"
  280. ) {
  281. this.el = document.createElement(type);
  282. this.el.style.backgroundColor = el_color;
  283. this.el.style.width = width;
  284. this.el.style.height = height;
  285. this.el.style.opacity = opacity;
  286. this.el.style.zIndex = zindex;
  287. this.el.id = n2id(name);
  288. this.display = "block"; // store default display
  289. }
  290.  
  291. setBorder(type, width, color, radius = 0) {
  292. const borderStyle = `${width} solid ${color}`;
  293. switch (type) {
  294. case "normal":
  295. this.el.style.border = borderStyle;
  296. break;
  297. case "top":
  298. this.el.style.borderTop = borderStyle;
  299. break;
  300. case "left":
  301. this.el.style.borderLeft = borderStyle;
  302. break;
  303. case "right":
  304. this.el.style.borderRight = borderStyle;
  305. break;
  306. case "bottom":
  307. this.el.style.borderBottom = borderStyle;
  308. break;
  309. }
  310. this.el.style.borderRadius = radius;
  311. }
  312.  
  313. setPosition(
  314. position,
  315. display,
  316. top,
  317. left,
  318. flexDirection,
  319. justifyContent,
  320. translate
  321. ) {
  322. this.el.style.position = position;
  323. this.el.style.display = display;
  324. if (top) this.el.style.top = top;
  325. if (left) this.el.style.left = left;
  326. // Flex properties
  327. if (flexDirection) this.el.style.flexDirection = flexDirection;
  328. if (justifyContent) this.el.style.justifyContent = justifyContent;
  329. if (translate) this.el.style.transform = `translate(${translate})`;
  330. this.display = display;
  331. }
  332.  
  333. margin(top, left, right, bottom) {
  334. this.el.style.margin = `${top} ${right} ${bottom} ${left}`;
  335. }
  336.  
  337. setText(
  338. text,
  339. txtColor,
  340. font,
  341. weight,
  342. fontSize,
  343. stroke,
  344. alignContent,
  345. textAlign
  346. ) {
  347. this.el.innerHTML = text;
  348. this.el.style.color = txtColor;
  349. this.el.style.fontFamily = font;
  350. this.el.style.fontWeight = weight;
  351. this.el.style.fontSize = fontSize;
  352. this.el.style.textShadow = stroke;
  353. this.el.style.alignContent = alignContent;
  354. this.el.style.textAlign = textAlign;
  355. }
  356.  
  357. add(parent) {
  358. parent.appendChild(this.el);
  359. }
  360.  
  361. remove(parent) {
  362. parent.removeChild(this.el);
  363. }
  364.  
  365. toggle(showOrHide) {
  366. this.el.style.display = showOrHide === "hide" ? "none" : this.display;
  367. }
  368. }
  369.  
  370. let mainCont, header, subContGray, subContBlack, modCont, settCont;
  371.  
  372. class Setting {
  373. constructor(name, type, options) {
  374. this.name = name;
  375. this.options = options;
  376. this.elements = [];
  377. this.desc = new El(
  378. name + " Setting",
  379. "div",
  380. "transparent",
  381. "170px",
  382. "50px"
  383. );
  384. this.desc.setPosition("relative", "block");
  385. this.desc.setText(
  386. name,
  387. "white",
  388. "Calibri",
  389. "bold",
  390. "15px",
  391. "2px",
  392. "center",
  393. "center"
  394. );
  395. this.elements.push(this.desc.el);
  396.  
  397. switch (type) {
  398. case "title":
  399. this.desc.el.style.backgroundColor = "rgb(50, 50, 50)";
  400. this.desc.setText(
  401. name,
  402. "lightgray",
  403. "Calibri",
  404. "bold",
  405. "20px",
  406. "2px",
  407. "center",
  408. "center"
  409. );
  410. this.desc.setBorder("normal", "2px", "gray", "5px");
  411. break;
  412. case "select":{
  413. if (!this.options) return console.warn("Missing Options!");
  414. let index = 0;
  415. this.selected = options[index];
  416. //temp cont
  417. let temp_container = new El(
  418. name + " temp Container",
  419. "div",
  420. "transparent"
  421. );
  422. temp_container.el.style.display = "flex";
  423. temp_container.el.style.alignItems = "center";
  424. temp_container.el.style.justifyContent = "center";
  425. temp_container.el.style.gap = "10px";
  426.  
  427. //displ
  428. let displ = new El(
  429. name + " Setting Display",
  430. "div",
  431. "lightgray",
  432. "125px",
  433. "25px"
  434. );
  435. displ.setText(
  436. this.selected,
  437. "black",
  438. "Calibri",
  439. "bold",
  440. "15px",
  441. "2px",
  442. "center",
  443. "center"
  444. );
  445.  
  446. //left Arrow
  447. let l_arrow = new El(
  448. name + " left Arrow",
  449. "div",
  450. "transparent",
  451. "0px",
  452. "0px"
  453. );
  454. l_arrow.setBorder("bottom", "8px", "transparent");
  455. l_arrow.setBorder("left", "0px", "transparent");
  456. l_arrow.setBorder("right", "16px", "blue");
  457. l_arrow.setBorder("top", "8px", "transparent");
  458.  
  459. l_arrow.el.addEventListener("mouseover", () => {
  460. l_arrow.el.style.cursor = "pointer";
  461. l_arrow.setBorder("right", "16px", "darkblue");
  462. });
  463.  
  464. l_arrow.el.addEventListener("mouseout", () => {
  465. l_arrow.el.style.cursor = "normal";
  466. l_arrow.setBorder("right", "16px", "blue");
  467. });
  468.  
  469. l_arrow.el.addEventListener("mousedown", (e) => {
  470. if (e.button != 0) return;
  471. let limit = options.length - 1;
  472. if (index - 1 < 0) {
  473. index = limit;
  474. } else {
  475. index--;
  476. }
  477. this.selected = options[index];
  478. displ.el.innerHTML = this.selected;
  479. });
  480.  
  481. //right Arrow
  482. let r_arrow = new El(
  483. name + " right Arrow",
  484. "div",
  485. "transparent",
  486. "0px",
  487. "0px"
  488. );
  489. r_arrow.setBorder("bottom", "8px", "transparent");
  490. r_arrow.setBorder("left", "16px", "blue");
  491. r_arrow.setBorder("right", "0px", "transparent");
  492. r_arrow.setBorder("top", "8px", "transparent");
  493.  
  494. r_arrow.el.addEventListener("mouseover", () => {
  495. r_arrow.el.style.cursor = "pointer";
  496. r_arrow.setBorder("left", "16px", "darkblue");
  497. });
  498.  
  499. r_arrow.el.addEventListener("mouseout", () => {
  500. r_arrow.el.style.cursor = "normal";
  501. r_arrow.setBorder("left", "16px", "blue");
  502. });
  503.  
  504. r_arrow.el.addEventListener("mousedown", (e) => {
  505. if (e.button != 0) return;
  506. let limit = options.length - 1;
  507. if (index + 1 > limit) {
  508. index = 0;
  509. } else {
  510. index++;
  511. }
  512. this.selected = options[index];
  513. displ.el.innerHTML = this.selected;
  514. });
  515.  
  516. //connect together
  517. temp_container.el.appendChild(l_arrow.el);
  518. temp_container.el.appendChild(displ.el);
  519. temp_container.el.appendChild(r_arrow.el);
  520.  
  521. //remember them
  522. this.elements.push(temp_container.el);
  523. break;
  524. }
  525. case "toggle":{
  526. this.active = false;
  527. this.desc.el.style.display = "flex";
  528. this.desc.el.style.alignItems = "center";
  529. this.desc.el.style.justifyContent = "space-between";
  530. let empty_checkbox = new El(
  531. this.name + " Setting checkbox",
  532. "div",
  533. "lightgray",
  534. "20px",
  535. "20px"
  536. );
  537. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  538. //event listeners
  539. empty_checkbox.el.addEventListener("mousedown", (e) => {
  540. if (e.button != 0) return;
  541. this.active = !this.active;
  542. if (this.active) {
  543. empty_checkbox.el.innerHTML = "✔";
  544. empty_checkbox.el.style.backgroundColor = "green";
  545. empty_checkbox.setBorder("normal", "2px", "lime", "4px");
  546. } else {
  547. empty_checkbox.el.innerHTML = "";
  548. empty_checkbox.el.style.backgroundColor = "lightgray";
  549. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  550. }
  551. });
  552. empty_checkbox.el.addEventListener("mouseover", () => {
  553. empty_checkbox.el.style.backgroundColor = this.active
  554. ? "darkgreen"
  555. : "darkgray";
  556. empty_checkbox.el.style.cursor = "pointer";
  557. });
  558. empty_checkbox.el.addEventListener("mouseout", () => {
  559. empty_checkbox.el.style.backgroundColor = this.active
  560. ? "green"
  561. : "lightgray";
  562. });
  563. this.desc.el.appendChild(empty_checkbox.el);
  564. break;
  565. }
  566. }
  567. }
  568. load() {
  569. this.elements.forEach((element) => settCont.el.appendChild(element));
  570. }
  571.  
  572. unload() {
  573. this.elements.forEach((element) => {
  574. if (settCont.el.contains(element)) {
  575. settCont.el.removeChild(element);
  576. }
  577. });
  578. }
  579. }
  580.  
  581. class Module {
  582. constructor(name, type, settings, callback) {
  583. this.name = name;
  584. this.type = type;
  585. this.callbackFunc = callback;
  586. this.settings = settings;
  587. this.title = new El(name, "div", "transparent", "170px", "50px");
  588. this.title.setPosition("relative", "block");
  589. this.title.setText(
  590. name,
  591. "white",
  592. "Calibri",
  593. "bold",
  594. "15px",
  595. "2px",
  596. "center",
  597. "center"
  598. );
  599. this.elements = [];
  600. this.elements.push(this.title.el);
  601. switch (type) {
  602. case "toggle": {
  603. this.active = false;
  604. this.title.el.style.display = "flex";
  605. this.title.el.style.alignItems = "center";
  606. this.title.el.style.justifyContent = "space-between";
  607. let empty_checkbox = new El(
  608. this.name + " checkbox",
  609. "div",
  610. "lightgray",
  611. "20px",
  612. "20px"
  613. );
  614. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  615. //event listeners
  616. empty_checkbox.el.addEventListener("mousedown", (e) => {
  617. if (e.button != 0) return;
  618. this.active = !this.active;
  619. if (this.active) {
  620. empty_checkbox.el.innerHTML = "✔";
  621. empty_checkbox.el.style.backgroundColor = "green";
  622. empty_checkbox.setBorder("normal", "2px", "lime", "4px");
  623. } else {
  624. empty_checkbox.el.innerHTML = "";
  625. empty_checkbox.el.style.backgroundColor = "lightgray";
  626. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  627. }
  628. });
  629. empty_checkbox.el.addEventListener("mouseover", () => {
  630. empty_checkbox.el.style.backgroundColor = this.active
  631. ? "darkgreen"
  632. : "darkgray";
  633. empty_checkbox.el.style.cursor = "pointer";
  634. });
  635. empty_checkbox.el.addEventListener("mouseout", () => {
  636. empty_checkbox.el.style.backgroundColor = this.active
  637. ? "green"
  638. : "lightgray";
  639. });
  640. this.title.el.appendChild(empty_checkbox.el);
  641. break;
  642. }
  643. case "slider": {
  644. this.value = 100;
  645. this.title.el.innerHTML = `${this.name}: ${this.value} %`;
  646. const slider = document.createElement("input");
  647. slider.type = "range";
  648. slider.value = this.value;
  649. slider.min = 0;
  650. slider.max = 100;
  651.  
  652. slider.addEventListener("input", () => {
  653. this.value = slider.value;
  654. this.title.el.innerHTML = `${this.name}: ${this.value} %`;
  655. });
  656.  
  657. this.elements.push(slider);
  658. break;
  659. }
  660. case "button":
  661. this.title.setBorder("normal", "2px", "white", "10px");
  662. this.title.el.style.cursor = "pointer";
  663. this.title.el.addEventListener("mousedown", () => {
  664. if (this.callbackFunc) {
  665. this.callbackFunc();
  666. }
  667. });
  668. break;
  669. case "open":{
  670. this.active = false;
  671. this.title.el.style.display = "flex";
  672. this.title.el.style.alignItems = "center";
  673. this.title.el.style.justifyContent = "space-between";
  674. let opener_box = new El(
  675. this.name + " opener box",
  676. "div",
  677. "rgb(75, 75, 75)",
  678. "20px",
  679. "20px"
  680. );
  681. opener_box.setBorder("normal", "2px", "gray", "4px");
  682. opener_box.el.style.display = "flex";
  683. opener_box.el.style.alignItems = "center";
  684. opener_box.el.style.justifyContent = "center";
  685. //
  686. let triangle = new El(
  687. name + " triangle",
  688. "div",
  689. "transparent",
  690. "0px",
  691. "0px"
  692. );
  693. triangle.setBorder("bottom", "16px", "lime");
  694. triangle.setBorder("left", "8px", "transparent");
  695. triangle.setBorder("right", "8px", "transparent");
  696. triangle.setBorder("top", "0px", "transparent");
  697. //
  698. //event listeners
  699. opener_box.el.addEventListener("mousedown", (e) => {
  700. if (e.button != 0) return;
  701. this.active = !this.active;
  702. if (this.active) {
  703. triangle.setBorder("bottom", "0px", "transparent");
  704. triangle.setBorder("left", "8px", "transparent");
  705. triangle.setBorder("right", "8px", "transparent");
  706. triangle.setBorder("top", "16px", "red");
  707. this.loadSettings();
  708. } else {
  709. triangle.setBorder("bottom", "16px", "lime");
  710. triangle.setBorder("left", "8px", "transparent");
  711. triangle.setBorder("right", "8px", "transparent");
  712. triangle.setBorder("top", "0px", "transparent");
  713. this.unloadSettings();
  714. }
  715. });
  716. opener_box.el.addEventListener("mouseover", () => {
  717. opener_box.el.style.backgroundColor = "rgb(50, 50, 50)";
  718. opener_box.el.style.cursor = "pointer";
  719. });
  720. opener_box.el.addEventListener("mouseout", () => {
  721. opener_box.el.style.backgroundColor = "rgb(75, 75, 75)";
  722. });
  723. opener_box.el.appendChild(triangle.el);
  724. this.title.el.appendChild(opener_box.el);
  725. break;
  726. }
  727. }
  728. }
  729. load() {
  730. this.elements.forEach((element) => modCont.el.appendChild(element));
  731. }
  732.  
  733. unload() {
  734. this.elements.forEach((element) => {
  735. if (modCont.el.contains(element)) {
  736. modCont.el.removeChild(element);
  737. }
  738. });
  739. }
  740.  
  741. loadSettings() {
  742. if (!this.settings) return;
  743. for (let _sett in this.settings) {
  744. this.settings[_sett].load();
  745. }
  746. }
  747.  
  748. unloadSettings() {
  749. if (!this.settings) return;
  750. for (let _sett in this.settings) {
  751. this.settings[_sett].unload();
  752. }
  753. }
  754. }
  755.  
  756. class Category {
  757. constructor(name, modules) {
  758. this.name = name;
  759. this.element = new El(name, "div", "rgb(38, 38, 38)", "90px", "50px");
  760. this.element.setPosition("relative", "block");
  761. this.element.setText(
  762. name,
  763. "white",
  764. "Calibri",
  765. "bold",
  766. "20px",
  767. "2px",
  768. "center",
  769. "center"
  770. );
  771. this.element.setBorder("normal", "2px", "transparent", "10px");
  772. this.selected = false;
  773. this.modules = modules;
  774.  
  775. this.element.el.addEventListener("mousedown", (e) => {
  776. if (e.button !== 0) return;
  777. this.selected = !this.selected;
  778. this.element.el.style.backgroundColor = this.selected
  779. ? "lightgray"
  780. : "rgb(38, 38, 38)";
  781. handle_categories_selection(this.name);
  782. if (!this.selected) unload_modules(this.name);
  783. });
  784.  
  785. this.element.el.addEventListener("mouseover", () => {
  786. if (!this.selected) {
  787. this.element.el.style.backgroundColor = "rgb(58, 58, 58)";
  788. this.element.el.style.cursor = "pointer";
  789. }
  790. });
  791.  
  792. this.element.el.addEventListener("mouseout", () => {
  793. if (!this.selected)
  794. this.element.el.style.backgroundColor = "rgb(38, 38, 38)";
  795. });
  796. }
  797. unselect() {
  798. this.selected = false;
  799. this.element.el.style.backgroundColor = "rgb(38, 38, 38)";
  800. }
  801. }
  802.  
  803. //1travel
  804. let modules = {
  805. Info: {
  806. q_a1: new Module(
  807. "Where is the rest of the scripts?",
  808. "button",
  809. null,
  810. () => {
  811. alert(
  812. "They're patched, I can't make the bypass public for now, because it will be patched too"
  813. );
  814. }
  815. ),
  816. q_a2: new Module("Why no updates so long?", "button", null, () => {
  817. alert(
  818. "I had some things to do in the university + I was working on a big canvas API, that no longer works due to the patch"
  819. );
  820. }),
  821. q_a3: new Module(
  822. "I have a problem/question where can I contact you?",
  823. "button",
  824. null,
  825. () => {
  826. alert("Dm me on discord. My tag is: h3llside");
  827. }
  828. ),
  829. q_a4: new Module(
  830. "What will happen to Diep.io+ after Diep Police Department?",
  831. "button",
  832. null,
  833. () => {
  834. alert(`
  835. There are two possbile outcomes:
  836. 1. I will make it a Ghost client, meaning it will contain helpful functions that make your life easier, but don't give you any advantages public and move everything else to Addons (make it private) OR
  837. 2. I will make bannable cheats less detectable
  838. `);
  839. }
  840. ),
  841. q_a5: new Module(
  842. "I really want to have access for Addons, can I have it?",
  843. "button",
  844. null,
  845. () => {
  846. alert(`
  847. No, unless you give me something in return. For example some useful information for bypassing or someone's private script
  848. `);
  849. }
  850. ),
  851. q_a6: new Module(
  852. "I want you to make a script for me, can you do it?",
  853. "button",
  854. null,
  855. () => {
  856. alert(`
  857. If it's simple - yes. If not, well I want a reward then in any form, because my time and energy are limited, to waste hours on someone who wants some personalised script
  858. `);
  859. }
  860. ),
  861. },
  862.  
  863. Visual: {
  864. Key_inputs_visualiser: new Module("Key Inputs Visualiser", "toggle"),
  865. display_hotkeys: new Module("Show Tank Upgrade Hotkeys", "toggle"),
  866. },
  867.  
  868. Functional: {
  869. CopyLink: new Module("Copy Party Link", "button", null, null, () => {
  870. document.getElementById("copy-party-link").click();
  871. }),
  872. Sandbox_lvl_up: new Module("Sandbox Auto Level Up", "toggle"),
  873. Auto_respawn: new Module("Auto Respawn", "open", {
  874. Title: new Setting("Auto Respawn", "title"),
  875. Remember: new Setting("Remember and store Killer Names", "toggle"),
  876. Prevent: new Setting("Prevent respawning after 300k score", "toggle"),
  877. Name: new Setting("Spawn Name Type: ", "select", [
  878. "Normal",
  879. "Glitched",
  880. "N A M E",
  881. "Random Killer",
  882. "Random Symbols",
  883. "Random Numbers",
  884. "Random Letters",
  885. ]),
  886. Auto_respawn: new Setting("Auto Respawn", "toggle"),
  887. }),
  888. Bot_tab: new Module("Sandbox Arena size increase", "toggle"),
  889. Zoom: new Module("Zoom Out", "slider"),
  890. },
  891.  
  892. Mouse: {
  893. Anti_aim: new Module("Anti Aim", "toggle"),
  894. Freeze_mouse: new Module("Freeze Mouse", "toggle"),
  895. Anti_timeout: new Module("Anti AFK Timeout", "toggle"),
  896. },
  897.  
  898. DiepConsole: {
  899. con_toggle: new Module("Show/hide Diep Console", "toggle"),
  900. net_predict_movement: new Module("predict movement", "toggle"),
  901. Render: new Module("Render things", "open", {
  902. Title: new Setting("Rendering", "title"),
  903. ren_scoreboard: new Setting("Leaderboard", "toggle"),
  904. ren_scoreboard_names: new Setting("Scoreboard Names", "toggle"),
  905. ren_fps: new Setting("FPS", "toggle"),
  906. ren_upgrades: new Setting("Tank Upgrades", "toggle"),
  907. ren_stats: new Setting("Stat Upgrades", "toggle"),
  908. ren_names: new Setting("Names", "toggle"),
  909. }),
  910. //game builds
  911. },
  912.  
  913. Addons: {},
  914. };
  915.  
  916. console.log(modules);
  917.  
  918. let categories = [];
  919.  
  920. function create_categories() {
  921. for (let key in modules) {
  922. categories.push(new Category(key, modules[key]));
  923. }
  924. }
  925. create_categories();
  926.  
  927. //loading / unloading modules
  928. function load_modules(category_name) {
  929. const current_category = categories.find(
  930. (category) => category.name === category_name
  931. );
  932. for (let moduleName in current_category.modules) {
  933. let module = current_category.modules[moduleName];
  934. module.load();
  935. if (module.type === "open" && module.active) module.loadSettings();
  936. }
  937. }
  938.  
  939. function unload_modules(category_name) {
  940. const current_category = categories.find(
  941. (category) => category.name === category_name
  942. );
  943. for (let moduleName in current_category.modules) {
  944. let module = current_category.modules[moduleName];
  945. module.unload();
  946. module.unloadSettings();
  947. }
  948. }
  949.  
  950. function find_module_path(_name) {
  951. for (let category in modules) {
  952. for (let module in modules[category]) {
  953. // Iterate over actual modules
  954. if (modules[category][module].name === _name) {
  955. return [category, module]; // Return actual category and module
  956. }
  957. }
  958. }
  959. return -1; // Return -1 if not found
  960. }
  961.  
  962. function handle_categories_selection(current_name) {
  963. categories.forEach((category) => {
  964. if (category.name !== current_name && category.selected) {
  965. category.unselect();
  966. unload_modules(category.name);
  967. }
  968. });
  969.  
  970. load_modules(current_name);
  971. }
  972.  
  973. function loadCategories() {
  974. const categoryCont = document.querySelector("#sub-container-gray");
  975. categories.forEach((category) =>
  976. categoryCont.appendChild(category.element.el)
  977. );
  978. }
  979.  
  980. function load_selected() {
  981. categories.forEach((category) => {
  982. if (category.selected) {
  983. load_modules(category.name);
  984. }
  985. });
  986. }
  987.  
  988. function loadGUI() {
  989. document.body.style.margin = "0";
  990. document.body.style.display = "flex";
  991. document.body.style.justifyContent = "left";
  992.  
  993. mainCont = new El("Main Cont", "div", "rgb(38, 38, 38)", "500px", "400px");
  994. mainCont.setBorder("normal", "2px", "lime", "10px");
  995. mainCont.el.style.display = "flex";
  996. mainCont.el.style.flexDirection = "column";
  997. mainCont.add(document.body);
  998.  
  999. header = new El("Headline Dp", "div", "transparent", "100%", "40px");
  1000. header.setBorder("bottom", "2px", "rgb(106, 173, 84)");
  1001. header.setText(
  1002. "Diep.io+ by r!PsAw (Hide GUI with J)",
  1003. "white",
  1004. "Calibri",
  1005. "bold",
  1006. "20px",
  1007. "2px",
  1008. "center",
  1009. "center"
  1010. );
  1011. header.add(mainCont.el);
  1012.  
  1013. const contentWrapper = document.createElement("div");
  1014. contentWrapper.style.display = "flex";
  1015. contentWrapper.style.gap = "10px";
  1016. contentWrapper.style.padding = "10px";
  1017. contentWrapper.style.flex = "1";
  1018. mainCont.el.appendChild(contentWrapper);
  1019.  
  1020. subContGray = new El(
  1021. "Sub Container Gray",
  1022. "div",
  1023. "transparent",
  1024. "100px",
  1025. "100%"
  1026. );
  1027. subContGray.el.style.display = "flex";
  1028. subContGray.el.style.flexDirection = "column";
  1029. subContGray.el.style.overflowY = "auto";
  1030. subContGray.add(contentWrapper);
  1031.  
  1032. subContBlack = new El("Sub Container Black", "div", "black", "360px", "100%");
  1033. subContBlack.el.style.display = "flex";
  1034. subContBlack.el.style.gap = "10px";
  1035. subContBlack.add(contentWrapper);
  1036.  
  1037. modCont = new El("Module Container", "div", "transparent", "50%", "100%");
  1038. modCont.el.style.display = "flex";
  1039. modCont.el.style.flexDirection = "column";
  1040. modCont.el.style.overflowY = "auto";
  1041. modCont.setBorder("right", "2px", "white");
  1042. modCont.add(subContBlack.el);
  1043.  
  1044. settCont = new El("Settings Container", "div", "transparent", "50%", "100%");
  1045. settCont.el.style.display = "flex";
  1046. settCont.el.style.flexDirection = "column";
  1047. settCont.el.style.overflowY = "auto";
  1048. settCont.add(subContBlack.el);
  1049.  
  1050. loadCategories();
  1051. load_selected();
  1052. }
  1053.  
  1054. loadGUI();
  1055. document.addEventListener("keydown", toggleGUI);
  1056.  
  1057. function toggleGUI(e) {
  1058. if (e.key === "j" || e.key === "J") {
  1059. if (mainCont.el) {
  1060. mainCont.remove(document.body);
  1061. mainCont.el = null;
  1062. } else {
  1063. loadGUI();
  1064. }
  1065. }
  1066. }
  1067.  
  1068. //actual logic
  1069.  
  1070. // ]-[ HTML RELATED STUFF
  1071. let homescreen = document.getElementById("home-screen");
  1072. let ingamescreen = document.getElementById("in-game-screen");
  1073. let gameOverScreen = document.getElementById('game-over-screen');
  1074. let gameOverScreenContainer = document.querySelector("#game-over-screen > div > div.game-details > div:nth-child(1)");
  1075. function update_scale_option(selector, label, min, max) {
  1076. let element = document.querySelector(selector);
  1077. let label_element = element.closest("div").querySelector("span");
  1078. label_element.innerHTML = `[DIEP.IO+] ${label}`;
  1079. label_element.style.background = "black";
  1080. label_element.style.color = "purple";
  1081. element.min = min;
  1082. element.max = max;
  1083. }
  1084.  
  1085. function new_ranges_for_scales() {
  1086. update_scale_option("#subsetting-option-ui_scale", "UI Scale", '0.01', '1000');
  1087. update_scale_option("#subsetting-option-border_radius", "UI Border Radius", '0.01', '1000');
  1088. update_scale_option("#subsetting-option-border_intensity", "UI Border Intensity", '0.01', '1000');
  1089. }
  1090.  
  1091. new_ranges_for_scales();
  1092.  
  1093. //detect gamemode
  1094. let gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  1095. let last_gamemode = localStorage.getItem(`[Diep.io+] last_gm`);
  1096. localStorage.setItem(`[Diep.io+] last_gm}`, gamemode);
  1097.  
  1098. function check_gamemode() {
  1099. gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  1100. save_gm();
  1101. }
  1102.  
  1103. setInterval(check_gamemode, 250);
  1104.  
  1105. function save_gm() {
  1106. let saved_gm = localStorage.getItem(`[Diep.io+] last_gm`);
  1107. if (saved_gm != null && saved_gm != gamemode) {
  1108. last_gamemode = saved_gm;
  1109. }
  1110. saved_gm === null ? localStorage.setItem(`[Diep.io+] last_gm}`, gamemode) : null;
  1111. }
  1112.  
  1113. //personal best
  1114. let your_final_score = 0;
  1115. const personal_best = document.createElement('div');
  1116. const gameDetail = document.createElement('div');
  1117. const label = document.createElement('div');
  1118. //applying class
  1119. gameDetail.classList.add("game-detail");
  1120. label.classList.add("label");
  1121. personal_best.classList.add("value");
  1122. //text context
  1123. label.textContent = "Best:";
  1124. //adding to html
  1125. gameOverScreenContainer.appendChild(gameDetail);
  1126. gameDetail.appendChild(label);
  1127. gameDetail.appendChild(personal_best);
  1128.  
  1129. function load_ls() {
  1130. return localStorage.getItem(gamemode);
  1131. }
  1132.  
  1133. function save_ls() {
  1134. localStorage.setItem(gamemode, your_final_score);
  1135. }
  1136.  
  1137. function check_final_score() {
  1138. if (_c.screen_state === "game-over") {
  1139. your_final_score = _c.death_score;
  1140. let saved_score = parseFloat(load_ls());
  1141. personal_best.textContent = saved_score;
  1142. if (saved_score < your_final_score) {
  1143. personal_best.textContent = your_final_score;
  1144. save_ls();
  1145. }
  1146. }
  1147. }
  1148.  
  1149. setInterval(check_final_score, 100);
  1150.  
  1151. //remove annoying html elements
  1152. function instant_remove() {
  1153. // Define selectors for elements to remove
  1154. const selectors = [
  1155. "#cmpPersistentLink",
  1156. "#apes-io-promo",
  1157. "#apes-io-promo > img",
  1158. "#last-updated",
  1159. "#diep-io_300x250"
  1160. ];
  1161.  
  1162. // Remove each selected element
  1163. selectors.forEach(selector => {
  1164. const element = document.querySelector(selector);
  1165. if (element) {
  1166. element.remove();
  1167. }
  1168. });
  1169.  
  1170. // If all elements have been removed, clear the interval
  1171. if (selectors.every(selector => !document.querySelector(selector))) {
  1172. deep_debug("Removed all ads, quitting...");
  1173. clearInterval(interval);
  1174. }
  1175. }
  1176.  
  1177. // Set an interval to check for ads
  1178. const interval = setInterval(instant_remove, 100);
  1179.  
  1180. // ]-[
  1181.  
  1182. //Bot tab
  1183.  
  1184.  
  1185. //iframe creation
  1186. function createInvisibleIframe(url) {
  1187. let existingIframe = document.getElementById('hiddenIframe');
  1188. if (existingIframe) {
  1189. return;
  1190. }
  1191.  
  1192. let iframe = document.createElement('iframe');
  1193. iframe.src = url;
  1194. iframe.id = 'hiddenIframe';
  1195. document.body.appendChild(iframe);
  1196. }
  1197.  
  1198. function removeIframe() {
  1199. let iframe = document.getElementById('hiddenIframe');
  1200. if (iframe) {
  1201. iframe.remove();
  1202. }
  1203. }
  1204.  
  1205. function bot_tab_active_check(){
  1206. if(modules.Functional.Bot_tab.active){
  1207. createInvisibleIframe(link(get_baseUrl(), get_your_lobby(), get_gamemode(), get_team()));
  1208. }else{
  1209. removeIframe();
  1210. }
  1211. }
  1212. setInterval(bot_tab_active_check, 1000);
  1213.  
  1214. //DiepConsole
  1215. function active_diepconsole_render_default(){
  1216. let defaults = ['ren_scoreboard', 'ren_upgrades', 'ren_stats', 'ren_names', 'ren_scoreboard_names'];
  1217. for(let _def of defaults){
  1218. let _setting = modules.DiepConsole.Render.settings[_def]
  1219. _setting.active = true;
  1220. }
  1221. }
  1222. active_diepconsole_render_default();
  1223.  
  1224. function handle_con_toggle(state){
  1225. if(extern.isConActive() != state){
  1226. extern.execute('con_toggle');
  1227. }
  1228. }
  1229.  
  1230. function update_diep_console(){
  1231. //Modules
  1232. for(let param in modules.DiepConsole){
  1233. let state = modules.DiepConsole[param].active;
  1234. if(param === "con_toggle"){
  1235. handle_con_toggle(state)
  1236. }else if(modules.DiepConsole[param].name != "Render things"){
  1237. extern.set_convar(param, state);
  1238. }
  1239. }
  1240. //Render Settings
  1241. for(let ren_param in modules.DiepConsole.Render.settings){
  1242. let state = modules.DiepConsole.Render.settings[ren_param].active;
  1243. if(modules.DiepConsole.Render.settings[ren_param].name != "Rendering"){
  1244. extern.set_convar(ren_param, state);
  1245. }
  1246. }
  1247. }
  1248. setInterval(update_diep_console, 100);
  1249.  
  1250.  
  1251. //////
  1252. //mouse functions
  1253.  
  1254. window.addEventListener('mousemove', function(event) {
  1255. inputs.mouse.real.x = event.clientX;
  1256. inputs.mouse.real.y = event.clientY;
  1257. });
  1258.  
  1259. window.addEventListener('mousedown', function(event) {
  1260. if (modules.Mouse.Anti_aim.active) {
  1261. if (inputs.mouse.shooting) {
  1262. return;
  1263. }
  1264. inputs.mouse.shooting = true;
  1265. freezeMouseMove();
  1266. setTimeout(function() {
  1267. inputs.mouse.shooting = false;
  1268. mouse_move('extern', inputs.mouse.real.x, inputs.mouse.real.y);
  1269. click_at('extern', inputs.mouse.real.x, inputs.mouse.real.y);
  1270. }, 50);
  1271. };
  1272. });
  1273.  
  1274. function handle_mouse_functions() {
  1275. window.requestAnimationFrame(handle_mouse_functions);
  1276. if (!player.connected) {
  1277. return;
  1278. }
  1279. modules.Mouse.Freeze_mouse.active ? freezeMouseMove() : unfreezeMouseMove();
  1280. modules.Mouse.Anti_aim.active ? anti_aim("On") : anti_aim("Off");
  1281. }
  1282. window.requestAnimationFrame(handle_mouse_functions);
  1283.  
  1284. //anti aim
  1285. function detect_corner() {
  1286. deep_debug('corner detect called');
  1287. let w = window.innerWidth;
  1288. let h = window.innerHeight;
  1289. let center = {
  1290. x: w / 2,
  1291. y: h / 2
  1292. };
  1293. let lr, ud;
  1294. inputs.mouse.real.x > center.x ? lr = "r" : lr = "l";
  1295. inputs.mouse.real.y > center.y ? ud = "d" : ud = "u";
  1296. deep_debug('output: ', lr + ud);
  1297. return lr + ud;
  1298. }
  1299.  
  1300. function look_at_corner(corner) {
  1301. deep_debug('look at corner called with corner', corner);
  1302. if (!inputs.mouse.shooting) {
  1303. let w = window.innerWidth;
  1304. let h = window.innerHeight;
  1305. deep_debug('w and h', w, h);
  1306. deep_debug('inputs: ', inputs);
  1307. switch (corner) {
  1308. case "lu":
  1309. anti_aim_at('extern', w, h);
  1310. break
  1311. case "ld":
  1312. anti_aim_at('extern', w, 0);
  1313. break
  1314. case "ru":
  1315. anti_aim_at('extern', 0, h);
  1316. break
  1317. case "rd":
  1318. anti_aim_at('extern', 0, 0);
  1319. break
  1320. }
  1321. }
  1322. }
  1323.  
  1324. function anti_aim(toggle) {
  1325. deep_debug('anti aim called with:', toggle);
  1326. switch (toggle) {
  1327. case "On":
  1328. if (modules.Mouse.Anti_aim.active) {
  1329. deep_debug('condition !modules.Mouse.Anti_aim.active met');
  1330. look_at_corner(detect_corner());
  1331. }
  1332. break
  1333. case "Off":
  1334. deep_debug('inputs.mouse.isFrozen ', inputs.mouse.isFrozen);
  1335. (inputs.mouse.isFrozen && !modules.Mouse.Freeze_mouse.active) ? unfreezeMouseMove(): null;
  1336. break
  1337. }
  1338. }
  1339. // Example: Freeze and unfreeze
  1340. function freezeMouseMove() {
  1341. if (!inputs.mouse.isFrozen) {
  1342. inputs.mouse.isFrozen = true;
  1343. clear_onTouch();
  1344. deep_debug("Mousemove events are frozen.");
  1345. }
  1346. }
  1347.  
  1348. function unfreezeMouseMove() {
  1349. if (inputs.mouse.isFrozen && !inputs.mouse.isShooting) {
  1350. inputs.mouse.isFrozen = false;
  1351. redefine_onTouch();
  1352. deep_debug("Mousemove events are active.");
  1353. }
  1354. }
  1355.  
  1356. function click_at(input_or_extern, x, y, delay1 = 150, delay2 = 500) {
  1357. i_e(input_or_extern, 'onTouchStart', -1, x, y);
  1358. setTimeout(() => {
  1359. i_e(input_or_extern, 'onTouchEnd', -1, x, y);
  1360. }, delay1);
  1361. setTimeout(() => {
  1362. inputs.mouse.shooting = false;
  1363. }, delay2);
  1364. }
  1365.  
  1366. /* it was a bug and is now patched
  1367. function ghost_click_at(input_or_extern, x, y, delay1 = 150, delay2 = 500) {
  1368. i_e(input_or_extern, 'onTouchStart', -2, x, y);
  1369. setTimeout(() => {
  1370. i_e(input_or_extern, 'onTouchEnd', -2, x, y);
  1371. }, delay1);
  1372. setTimeout(() => {
  1373. inputs.mouse.shooting = false;
  1374. }, delay2);
  1375. }
  1376. */
  1377.  
  1378. function mouse_move(input_or_extern, x, y) {
  1379. deep_debug('mouse move called with', x, y);
  1380. apply_force(x, y);
  1381. i_e(input_or_extern, 'onTouchMove', -1, x, y);
  1382. disable_force();
  1383. }
  1384.  
  1385. function anti_aim_at(input_or_extern, x, y) {
  1386. deep_debug('frozen, shooting', inputs.mouse.isFrozen, inputs.mouse.isShooting);
  1387. deep_debug('anti aim at called with:', x, y);
  1388. if (inputs.mouse.shooting) {
  1389. deep_debug('quit because inputs.mouse.shooting');
  1390. return;
  1391. }
  1392. mouse_move(input_or_extern, x, y);
  1393. }
  1394. //////
  1395.  
  1396. //Sandbox Auto Lvl up
  1397. function sandbox_lvl_up() {
  1398. if (modules.Functional.Sandbox_lvl_up.active && player.connected && player.inGame && player.gamemode === "sandbox") {
  1399. document.querySelector("#sandbox-max-level").click();
  1400. }
  1401. }
  1402. setInterval(sandbox_lvl_up, 500);
  1403.  
  1404. //START, autorespawn Module
  1405.  
  1406. //name saving logic
  1407. let killer_names = localStorage.getItem("[Diep.io+] saved names") ? JSON.parse(localStorage.getItem("[Diep.io+] saved names")) : ['r!PsAw', 'TestTank'];
  1408. let banned_names = ["Pentagon", "Triangle", "Square", "Crasher", "Mothership", "Guardian of Pentagons", "Fallen Booster", "Fallen Overlord", "Necromancer", "Defender", "Unnamed Tank"];
  1409. function check_and_save_name(){
  1410. if(_c.screen_state === 'game-over' && !banned_names.includes(_c.killer_name)){
  1411. killer_names.push(_c.killer_name);
  1412. if(modules.Functional.Auto_respawn.settings.Remember.active){
  1413. localStorage.setItem("[Diep.io+] saved names", JSON.stringify(killer_names));
  1414. }
  1415. }
  1416. }
  1417.  
  1418. function get_random_killer_name(){
  1419. let l = killer_names.length;
  1420. let index = Math.floor(Math.random() * l);
  1421. return killer_names[index];
  1422. }
  1423.  
  1424. //Random Symbols/Numbers/Letters
  1425. function generate_random_name_string(type){
  1426. let final_result = '';
  1427. let chars = '';
  1428. switch(type){
  1429. case "Symbols":
  1430. chars = '!@#$%^&*()_+=-.,][';
  1431. break
  1432. case "Numbers":
  1433. chars = '1234567890';
  1434. break
  1435. case "Letters":
  1436. chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  1437. break
  1438. }
  1439. for (let i = 0; i < 16; i++) {
  1440. final_result += chars[Math.floor(Math.random() * chars.length)];
  1441. }
  1442. return final_result;
  1443. }
  1444. //ascii inject
  1445. function get_ascii_inject(type){
  1446. let asciiArray = [];
  1447. switch(type){
  1448. case "Glitched":
  1449. asciiArray = [0x110000];
  1450. break
  1451. case "N A M E":
  1452. asciiArray = player.name.split("").flatMap(char => [char.charCodeAt(0), 10]).slice(0, -1);
  1453. break
  1454. }
  1455. let interesting = {
  1456. length: asciiArray.length,
  1457. charCodeAt(i) {
  1458. return asciiArray[i];
  1459. },
  1460. };
  1461. const argument = {
  1462. toString() {
  1463. return interesting;
  1464. },
  1465. };
  1466. return argument;
  1467. }
  1468.  
  1469. //main Loop
  1470. function get_respawn_name_by_type(type){
  1471. let temp_name = '';
  1472. switch(type){
  1473. case "Normal":
  1474. temp_name = player.name;
  1475. break
  1476. case "Glitched":
  1477. temp_name = get_ascii_inject(type);
  1478. break
  1479. case "N A M E":
  1480. temp_name = get_ascii_inject(type);
  1481. break
  1482. case "Random Killer":
  1483. temp_name = get_random_killer_name();
  1484. break
  1485. case "Random Symbols":
  1486. temp_name = generate_random_name_string('Symbols');
  1487. break
  1488. case "Random Numbers":
  1489. temp_name = generate_random_name_string('Numbers');
  1490. break
  1491. case "Random Letters":
  1492. temp_name = generate_random_name_string('Letters');
  1493. break
  1494. }
  1495. return temp_name;
  1496. }
  1497. function respawn() {
  1498. check_and_save_name();
  1499. if (modules.Functional.Auto_respawn.settings.Auto_respawn.active && player.connected && !player.inGame) {
  1500. //prevent respawn after 300k flag
  1501. if(modules.Functional.Auto_respawn.settings.Prevent.active && _c.death_score >= 300000){
  1502. return;
  1503. }
  1504. let type = modules.Functional.Auto_respawn.settings.Name.selected;
  1505. let temp_name = get_respawn_name_by_type(type);
  1506. extern.try_spawn(temp_name);
  1507. }
  1508. }
  1509.  
  1510. setInterval(respawn, 1000);
  1511.  
  1512. //END
  1513.  
  1514. //AntiAfk Timeout
  1515. function AntiAfkTimeout() {
  1516. if (modules.Mouse.Anti_timeout.active && player.connected) {
  1517. extern.onTouchMove(inputs.mouse.real.x, inputs.mouse.real.y);
  1518. }
  1519. }
  1520. setInterval(AntiAfkTimeout, 1000);
  1521.  
  1522. //Zoom
  1523. function HandleZoom() {
  1524. window.requestAnimationFrame(HandleZoom);
  1525. if(player.connected){
  1526. let base_value = 1;
  1527. let factor = modules.Functional.Zoom.value / 100;
  1528. player.dpr = base_value * factor;
  1529. let diepScale = base_value * Math.floor(player.ui_scale * windowScaling() * 25) / 25;
  1530. extern.setScreensizeZoom(diepScale, player.dpr);
  1531. extern.updateDPR(player.dpr);
  1532. }
  1533. }
  1534. window.requestAnimationFrame(HandleZoom);
  1535.  
  1536. //ctx helper functions
  1537. function ctx_text(fcolor, scolor, lineWidth, font, text, textX, textY) {
  1538. deep_debug('called crx_text with: ', fcolor, scolor, lineWidth, font, text, textX, textY);
  1539. ctx.fillStyle = fcolor;
  1540. ctx.lineWidth = lineWidth;
  1541. ctx.font = font;
  1542. ctx.strokeStyle = scolor;
  1543. ctx.strokeText(`${text}`, textX, textY)
  1544. ctx.fillText(`${text}`, textX, textY)
  1545. }
  1546.  
  1547. function ctx_rect(x, y, a, b, c) {
  1548. deep_debug('called ctx_rect with: ', x, y, a, b, c);
  1549. ctx.beginPath();
  1550. ctx.strokeStyle = c;
  1551. ctx.strokeRect(x, y, a, b);
  1552. }
  1553.  
  1554. function transparent_rect_fill(x, y, a, b, scolor, fcolor, opacity){
  1555. deep_debug('called transparent_rect_fill with: ', x, y, a, b, scolor, fcolor, opacity);
  1556. ctx.beginPath();
  1557. ctx.rect(x, y, a, b);
  1558.  
  1559. // Set stroke opacity
  1560. ctx.globalAlpha = 1;// Reset to 1 for stroke, or set as needed
  1561. ctx.strokeStyle = scolor;
  1562. ctx.stroke();
  1563.  
  1564. // Set fill opacity
  1565. ctx.globalAlpha = opacity;// Set the opacity for the fill color
  1566. ctx.fillStyle = fcolor;
  1567. ctx.fill();
  1568.  
  1569. // Reset globalAlpha back to 1 for future operations
  1570. ctx.globalAlpha = 1;
  1571. }
  1572.  
  1573. //key visualiser
  1574. let ctx_wasd = {
  1575. square_sizes: { //in windowScaling
  1576. a: 50,
  1577. b: 50
  1578. },
  1579. text_props: {
  1580. lineWidth: 3,
  1581. font: 1 + "em Ubuntu",
  1582. },
  1583. square_colors: {
  1584. stroke: "black",
  1585. unpressed: "yellow",
  1586. pressed: "orange"
  1587. },
  1588. text_colors: {
  1589. stroke: "black",
  1590. unpressed: "orange",
  1591. pressed: "red"
  1592. },
  1593. w: {
  1594. x: 300,
  1595. y: 200,
  1596. pressed: false,
  1597. text: 'W'
  1598. },
  1599. a: {
  1600. x: 350,
  1601. y: 150,
  1602. pressed: false,
  1603. text: 'A'
  1604. },
  1605. s: {
  1606. x: 300,
  1607. y: 150,
  1608. pressed: false,
  1609. text: 'S'
  1610. },
  1611. d: {
  1612. x: 250,
  1613. y: 150,
  1614. pressed: false,
  1615. text: 'D'
  1616. },
  1617. l_m: {
  1618. x: 350,
  1619. y: 75,
  1620. pressed: false,
  1621. text: 'LMC'
  1622. },
  1623. r_m: {
  1624. x: 250,
  1625. y: 75,
  1626. pressed: false,
  1627. text: 'RMC'
  1628. },
  1629. }
  1630.  
  1631. function visualise_keys(){
  1632. let keys = ['w', 'a', 's', 'd', 'l_m', 'r_m'];
  1633. let l = keys.length;
  1634. for(let i = 0; i < l; i++){
  1635. let args = {
  1636. x: canvas.width - dim_c.windowScaling_2_canvas(ctx_wasd[keys[i]].x),
  1637. y: canvas.height - dim_c.windowScaling_2_canvas(ctx_wasd[keys[i]].y),
  1638. a: dim_c.windowScaling_2_canvas(ctx_wasd.square_sizes.a),
  1639. b: dim_c.windowScaling_2_canvas(ctx_wasd.square_sizes.b),
  1640. s_c: ctx_wasd.square_colors.stroke,
  1641. f_c: ctx_wasd[keys[i]].pressed? ctx_wasd.square_colors.pressed : ctx_wasd.square_colors.unpressed,
  1642. t_s: ctx_wasd.text_colors.stroke,
  1643. t_f: ctx_wasd[keys[i]].pressed? ctx_wasd.text_colors.pressed : ctx_wasd.text_colors.unpressed,
  1644. t_lineWidth: ctx_wasd.text_props.lineWidth,
  1645. t_font: ctx_wasd.text_props.font,
  1646. text: ctx_wasd[keys[i]].text,
  1647. opacity: 0.25
  1648. }
  1649. deep_debug(args);
  1650. transparent_rect_fill(
  1651. args.x,
  1652. args.y,
  1653. args.a,
  1654. args.b,
  1655. args.s_c,
  1656. args.f_c,
  1657. args.opacity
  1658. );
  1659. ctx_text(
  1660. args.t_f,
  1661. args.t_s,
  1662. args.t_lineWidth,
  1663. args.t_font,
  1664. args.text,
  1665. args.x+(args.a/2),
  1666. args.y+(args.b/2)
  1667. );
  1668. }
  1669. }
  1670.  
  1671. //Key Binds for Tank Upgrading
  1672. let selected_box = null;
  1673. let _bp = { //box parameters
  1674. startX: 47,
  1675. startY: 67,
  1676. distX: 13,
  1677. distY: 9,
  1678. width: 86,
  1679. height: 86,
  1680. outer_xy: 2
  1681. }
  1682.  
  1683. let _bo = { //box offsets
  1684. offsetX: _bp.width + (_bp.outer_xy * 2) + _bp.distX,
  1685. offsetY: _bp.height + (_bp.outer_xy * 2) + _bp.distY
  1686. }
  1687.  
  1688. function step_offset(steps, offset){
  1689. let final_offset = 0;
  1690. switch(offset){
  1691. case "x":
  1692. final_offset = _bp.startX + (steps * _bo.offsetX);
  1693. break
  1694. case "y":
  1695. final_offset = _bp.startY + (steps * _bo.offsetY);
  1696. break
  1697. }
  1698. return final_offset;
  1699. }
  1700.  
  1701. const boxes = [
  1702. {
  1703. color: "lightblue",
  1704. LUcornerX: _bp.startX,
  1705. LUcornerY: _bp.startY,
  1706. KeyBind: "R"
  1707. },
  1708. {
  1709. color: "green",
  1710. LUcornerX: _bp.startX + _bo.offsetX,
  1711. LUcornerY: _bp.startY,
  1712. KeyBind: "T"
  1713. },
  1714. {
  1715. color: "red",
  1716. LUcornerX: _bp.startX,
  1717. LUcornerY: _bp.startY + _bo.offsetY,
  1718. KeyBind: "F"
  1719. },
  1720. {
  1721. color: "yellow",
  1722. LUcornerX: _bp.startX + _bo.offsetX,
  1723. LUcornerY: _bp.startY + _bo.offsetY,
  1724. KeyBind: "G"
  1725. },
  1726. {
  1727. color: "blue",
  1728. LUcornerX: _bp.startX,
  1729. LUcornerY: step_offset(2, "y"),
  1730. KeyBind: "V"
  1731. },
  1732. {
  1733. color: "purple",
  1734. LUcornerX: _bp.startX + _bo.offsetX,
  1735. LUcornerY: step_offset(2, "y"),
  1736. KeyBind: "B"
  1737. }
  1738. ]
  1739.  
  1740. //upgrading Tank logic
  1741. function upgrade_get_coords(color){
  1742. let l = boxes.length;
  1743. let upgrade_coords = {x: "not defined", y: "not defined"};
  1744. for(let i = 0; i < l; i++){
  1745. if(boxes[i].color === color){
  1746. upgrade_coords.x = dim_c.windowScaling_2_window(boxes[i].LUcornerX + (_bp.width/2));
  1747. upgrade_coords.y = dim_c.windowScaling_2_window(boxes[i].LUcornerY + (_bp.height/2));
  1748. }
  1749. }
  1750. deep_debug(upgrade_coords);
  1751. return upgrade_coords;
  1752. }
  1753.  
  1754. function upgrade(color, delay = 100, cdelay1, cdelay2){
  1755. let u_coords = upgrade_get_coords(color);
  1756. //ghost_click_at('extern', u_coords.x, u_coords.y, cdelay1, cdelay2);
  1757. click_at('extern', u_coords.x, u_coords.y, cdelay1, cdelay2); //using this since ghost_click was patched
  1758. }
  1759.  
  1760. function visualise_tank_upgrades(){
  1761. let l = boxes.length;
  1762. for (let i = 0; i < l; i++) {
  1763. let coords = upgrade_get_coords(boxes[i].color);
  1764. ctx_text(boxes[i].color, "black", 6, 1.5 + "em Ubuntu", `[${boxes[i].KeyBind}]`, coords.x, coords.y);
  1765. }
  1766. }
  1767.  
  1768. function check_tu_KeyBind(_KeyBind){
  1769. let l = boxes.length;
  1770. for (let i = 0; i < l; i++) {
  1771. if(_KeyBind === `Key${boxes[i].KeyBind}`){
  1772. deep_debug(_KeyBind, `Key${boxes[i].KeyBind}`, _KeyBind === `Key${boxes[i].KeyBind}`);
  1773. upgrade(boxes[i].color);
  1774. }
  1775. }
  1776. }
  1777.  
  1778. document.body.addEventListener("keydown", function(e) {
  1779. switch(e.code){
  1780. case "KeyW":
  1781. ctx_wasd.w.pressed = true;
  1782. break
  1783. case "KeyA":
  1784. ctx_wasd.a.pressed = true;
  1785. break
  1786. case "KeyS":
  1787. ctx_wasd.s.pressed = true;
  1788. break
  1789. case "KeyD":
  1790. ctx_wasd.d.pressed = true;
  1791. break
  1792. }
  1793. check_tu_KeyBind(e.code);
  1794. });
  1795.  
  1796. document.body.addEventListener("keyup", function(e) {
  1797. deep_debug(`unpressed ${e.code}`);
  1798. switch(e.code){
  1799. case "KeyW":
  1800. ctx_wasd.w.pressed = false;
  1801. break
  1802. case "KeyA":
  1803. ctx_wasd.a.pressed = false;
  1804. break
  1805. case "KeyS":
  1806. ctx_wasd.s.pressed = false;
  1807. break
  1808. case "KeyD":
  1809. ctx_wasd.d.pressed = false;
  1810. break
  1811. }
  1812. deep_debug('====DID UNPRESS??', ctx_wasd.w.pressed, ctx_wasd.a.pressed, ctx_wasd.s.pressed, ctx_wasd.d.pressed);
  1813. });
  1814.  
  1815. document.body.addEventListener("mousedown", function(e) {
  1816. switch(e.button){
  1817. case 0:
  1818. ctx_wasd.l_m.pressed = true;
  1819. break
  1820. case 2:
  1821. ctx_wasd.r_m.pressed = true;
  1822. break
  1823. }
  1824. });
  1825.  
  1826. document.body.addEventListener("mouseup", function(e) {
  1827. switch(e.button){
  1828. case 0:
  1829. ctx_wasd.l_m.pressed = false;
  1830. break
  1831. case 2:
  1832. ctx_wasd.r_m.pressed = false;
  1833. break
  1834. }
  1835. });
  1836.  
  1837.  
  1838. //canvas gui (try to keep this in the end
  1839. setTimeout(() => {
  1840. let gui = () => {
  1841. if (player.inGame) {
  1842. if(modules.Visual.display_hotkeys.active){
  1843. visualise_tank_upgrades();
  1844. }
  1845. if (modules.Visual.Key_inputs_visualiser.active) {
  1846. visualise_keys();
  1847. }
  1848. }
  1849. window.requestAnimationFrame(gui); // Start animation loop
  1850. };
  1851. gui();
  1852. }, 500); // Delay before starting the rendering