Diep.io+ (added quick Tank Upgrade Hotkeys)

Quick Tank Upgrades, Highscore saver, Anti Aim, Zoom hack, Anti AFK Timeout, Sandbox Auto K

Versione datata 24/02/2025. Vedi la nuova versione l'ultima versione.

  1. // ==UserScript==
  2. // @name Diep.io+ (added quick Tank Upgrade Hotkeys)
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.2.1
  5. // @description Quick Tank Upgrades, Highscore saver, Anti Aim, Zoom hack, Anti AFK Timeout, Sandbox Auto K
  6. // @author r!PsAw
  7. // @match https://diep.io/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=diep.io
  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 player = {
  28. connected: false,
  29. inGame: false,
  30. name: '',
  31. team: null,
  32. gamemode: null,
  33. ui_scale: 1,
  34. dpr: 1,
  35. };
  36.  
  37. function windowScaling() {
  38. const a = canvas.height / 1080;
  39. const b = canvas.width / 1920;
  40. return b < a ? a : b;
  41. }
  42.  
  43. class dimensions_converter {
  44. constructor() {
  45. this.scalingFactor = null; //undetectable without bypass
  46. this.fieldFactor = null; //undetectable without bypass
  47. }
  48. canvas_2_window(a) {
  49. let b = a / (canvas.width / window.innerWidth);
  50. return b;
  51. }
  52.  
  53. window_2_canvas(a) {
  54. let b = a * (canvas.width / window.innerWidth);
  55. return b;
  56. }
  57.  
  58. windowScaling_2_window(a) {
  59. let b = (this.windowScaling_2_canvas(a)) / (canvas.width / window.innerWidth);
  60. return b;
  61. }
  62.  
  63. windowScaling_2_canvas(a) {
  64. let b = a * windowScaling();
  65. deep_debug('windowScaling_2_canvas called! a, b', a, b);
  66. return b;
  67. }
  68. /* DISABLED FOR NOW
  69. diepUnits_2_canvas(a) {
  70. let b = a / scalingFactor;
  71. return b;
  72. }
  73.  
  74. diepUnits_2_window(a) {
  75. let b = (this.diepUnits_2_canvas(a)) / (canvas.width / window.innerWidth);
  76. return b;
  77. }
  78.  
  79. window_2_diepUnits(a) {
  80. let b = (this.canvas_2_diepUnits(a)) * (canvas.width / window.innerWidth);
  81. return b;
  82. }
  83.  
  84. canvas_2_diepUnits(a) {
  85. let b = a * this.scalingFactor;
  86. return b;
  87. }
  88. */
  89.  
  90. window_2_windowScaling(a) {
  91. let b = (this.canvas_2_windowScaling(a)) * (canvas.width / window.innerWidth);
  92. return b;
  93. }
  94.  
  95. canvas_2_windowScaling(a) {
  96. let b = a * windowScaling();
  97. return b;
  98. }
  99. /* DISABLED FOR NOW
  100. diepUnits_2_windowScaling(a) {
  101. let b = (this.diepUnits_2_canvas(a)) * this.fieldFactor;
  102. return b;
  103. }
  104.  
  105. windowScaling_2_diepUntis(a) {
  106. let b = (a / this.fieldFactor) * this.scalingFactor;
  107. return b;
  108. }
  109. */
  110. }
  111.  
  112. let dim_c = new dimensions_converter();
  113.  
  114. function i_e(type, key, ...args) {
  115. switch (type) {
  116. case "input":
  117. input[key](...args);
  118. break
  119. case "extern":
  120. extern[key](...args);
  121. break
  122. }
  123. }
  124.  
  125. let inputs = {
  126. mouse: {
  127. real: {
  128. x: 0,
  129. y: 0,
  130. },
  131. game: {
  132. x: 0,
  133. y: 0,
  134. },
  135. force: {
  136. x: 0,
  137. y: 0,
  138. },
  139. isForced: false,
  140. isFrozen: false,
  141. isShooting: false,
  142. original: {
  143. onTouchMove: null,
  144. onTouchStart: null,
  145. onTouchEnd: null,
  146. }
  147. },
  148. keys_pressed: [],
  149. }
  150.  
  151. function apply_force(x, y) {
  152. inputs.mouse.force = {
  153. x: x,
  154. y: y,
  155. }
  156. inputs.mouse.isForced = true;
  157. }
  158.  
  159. function disable_force() {
  160. inputs.mouse.isForced = false;
  161. }
  162.  
  163. const touchMethods = ['onTouchMove', 'onTouchStart', 'onTouchEnd'];
  164. let canvas = document.getElementById("canvas");
  165. let ctx = canvas.getContext('2d');
  166.  
  167. function define_onTouch() {
  168. touchMethods.forEach(function(method) {
  169. inputs.mouse.original[method] = input[method];
  170. deep_debug('defined input.', method);
  171. });
  172. }
  173.  
  174. function clear_onTouch() {
  175. touchMethods.forEach(function(method) {
  176. input[method] = () => {};
  177. });
  178. }
  179.  
  180. function redefine_onTouch() {
  181. touchMethods.forEach(function(method) {
  182. input[method] = inputs.mouse.original[method];
  183. });
  184. }
  185.  
  186. function start_input_proxies(_filter = false, _single = false, _method = null) {
  187. ((_filter || _single) && !_method) ? console.warn("missing _method at start_input_proxies"): null;
  188. let temp_methods = touchMethods;
  189. if (_filter) {
  190. temp_methods.filter((item) => item != _method);
  191. } else if (_single) {
  192. temp_methods = [_method];
  193. }
  194. temp_methods.forEach(function(method) {
  195. input[method] = new Proxy(input[method], {
  196. apply: function(definition, input_obj, args) {
  197. let x, y, type, new_args;
  198. if (inputs.mouse.isForced) {
  199. x = inputs.mouse.forced.x;
  200. y = inputs.mouse.forced.y;
  201. } else {
  202. x = args[1];
  203. y = args[2];
  204. }
  205. type = args[0];
  206. new_args = [type, x / player.dpr, y / player.dpr];
  207. inputs.mouse.game = {
  208. x: new_args[1],
  209. y: new_args[2],
  210. }
  211. return Reflect.apply(definition, input_obj, new_args);
  212. }
  213. });
  214. });
  215. }
  216.  
  217. function update_information() {
  218. window.requestAnimationFrame(update_information);
  219. let teams = ["blue", "red", "purple", "green"];
  220. player.connected = !!window.lobby_ip;
  221. player.connected? player.inGame = !!extern.doesHaveTank() : null;
  222. player.name = document.querySelector("#spawn-nickname").value;
  223. player.team = teams[parseInt(window.__common__.party_link.split('x')[1])];
  224. player.gamemode = window.__common__.active_gamemode;
  225. player.ui_scale = parseFloat(localStorage.getItem("d:ui_scale"))
  226. }
  227. window.requestAnimationFrame(update_information);
  228.  
  229. function waitForConnection() {
  230. if (player.connected) {
  231. define_onTouch();
  232. start_input_proxies();
  233. } else {
  234. setTimeout(waitForConnection, 100);
  235. }
  236. }
  237. waitForConnection();
  238.  
  239. //GUI
  240. function n2id(string) {
  241. return string.toLowerCase().replace(/ /g, "-");
  242. }
  243.  
  244. class El {
  245. constructor(
  246. name,
  247. type,
  248. el_color,
  249. width,
  250. height,
  251. opacity = "1",
  252. zindex = "100"
  253. ) {
  254. this.el = document.createElement(type);
  255. this.el.style.backgroundColor = el_color;
  256. this.el.style.width = width;
  257. this.el.style.height = height;
  258. this.el.style.opacity = opacity;
  259. this.el.style.zIndex = zindex;
  260. this.el.id = n2id(name);
  261. this.display = "block"; // store default display
  262. }
  263.  
  264. setBorder(type, width, color, radius = 0) {
  265. const borderStyle = `${width} solid ${color}`;
  266. switch (type) {
  267. case "normal":
  268. this.el.style.border = borderStyle;
  269. break;
  270. case "top":
  271. this.el.style.borderTop = borderStyle;
  272. break;
  273. case "left":
  274. this.el.style.borderLeft = borderStyle;
  275. break;
  276. case "right":
  277. this.el.style.borderRight = borderStyle;
  278. break;
  279. case "bottom":
  280. this.el.style.borderBottom = borderStyle;
  281. break;
  282. }
  283. this.el.style.borderRadius = radius;
  284. }
  285.  
  286. setPosition(
  287. position,
  288. display,
  289. top,
  290. left,
  291. flexDirection,
  292. justifyContent,
  293. translate
  294. ) {
  295. this.el.style.position = position;
  296. this.el.style.display = display;
  297. if (top) this.el.style.top = top;
  298. if (left) this.el.style.left = left;
  299. // Flex properties
  300. if (flexDirection) this.el.style.flexDirection = flexDirection;
  301. if (justifyContent) this.el.style.justifyContent = justifyContent;
  302. if (translate) this.el.style.transform = `translate(${translate})`;
  303. this.display = display;
  304. }
  305.  
  306. margin(top, left, right, bottom) {
  307. this.el.style.margin = `${top} ${right} ${bottom} ${left}`;
  308. }
  309.  
  310. setText(
  311. text,
  312. txtColor,
  313. font,
  314. weight,
  315. fontSize,
  316. stroke,
  317. alignContent,
  318. textAlign
  319. ) {
  320. this.el.innerHTML = text;
  321. this.el.style.color = txtColor;
  322. this.el.style.fontFamily = font;
  323. this.el.style.fontWeight = weight;
  324. this.el.style.fontSize = fontSize;
  325. this.el.style.textShadow = stroke;
  326. this.el.style.alignContent = alignContent;
  327. this.el.style.textAlign = textAlign;
  328. }
  329.  
  330. add(parent) {
  331. parent.appendChild(this.el);
  332. }
  333.  
  334. remove(parent) {
  335. parent.removeChild(this.el);
  336. }
  337.  
  338. toggle(showOrHide) {
  339. this.el.style.display = showOrHide === "hide" ? "none" : this.display;
  340. }
  341. }
  342.  
  343. let mainCont, header, subContGray, subContBlack, modCont, settCont;
  344.  
  345. class Module {
  346. constructor(name, type, submodules = null, settings, callback) {
  347. this.name = name;
  348. this.submodules = submodules;
  349. this.callbackFunc = callback;
  350. this.settings = settings;
  351. this.title = new El(name, "div", "transparent", "170px", "50px");
  352. this.title.setPosition("relative", "block");
  353. this.title.setText(
  354. name,
  355. "white",
  356. "Calibri",
  357. "bold",
  358. "15px",
  359. "2px",
  360. "center",
  361. "center"
  362. );
  363. this.elements = [];
  364. this.elements.push(this.title.el);
  365. switch (type) {
  366. case "toggle": {
  367. this.active = false;
  368. this.title.el.style.display = "flex";
  369. this.title.el.style.alignItems = "center";
  370. this.title.el.style.justifyContent = "space-between";
  371. let empty_checkbox = new El(
  372. this.name + " checkbox",
  373. "div",
  374. "lightgray",
  375. "20px",
  376. "20px"
  377. );
  378. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  379. //event listeners
  380. empty_checkbox.el.addEventListener("mousedown", (e) => {
  381. if (e.button != 0) return;
  382. this.active = !this.active;
  383. if (this.active) {
  384. empty_checkbox.el.innerHTML = "✔";
  385. empty_checkbox.el.style.backgroundColor = "green";
  386. empty_checkbox.setBorder("normal", "2px", "lime", "4px");
  387. } else {
  388. empty_checkbox.el.innerHTML = "";
  389. empty_checkbox.el.style.backgroundColor = "lightgray";
  390. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  391. }
  392. });
  393. empty_checkbox.el.addEventListener("mouseover", () => {
  394. empty_checkbox.el.style.backgroundColor = this.active ?
  395. "darkgreen" :
  396. "darkgray";
  397. empty_checkbox.el.style.cursor = "pointer";
  398. });
  399. empty_checkbox.el.addEventListener("mouseout", () => {
  400. empty_checkbox.el.style.backgroundColor = this.active ?
  401. "green" :
  402. "lightgray";
  403. });
  404. this.title.el.appendChild(empty_checkbox.el);
  405. break;
  406. }
  407. case "slider": {
  408. this.value = 100;
  409. this.title.el.innerHTML = `${this.name}: ${this.value} %`;
  410. const slider = document.createElement("input");
  411. slider.type = "range";
  412. slider.value = this.value;
  413. slider.min = 0;
  414. slider.max = 100;
  415.  
  416. slider.addEventListener("input", () => {
  417. this.value = slider.value;
  418. this.title.el.innerHTML = `${this.name}: ${this.value} %`;
  419. });
  420.  
  421. this.elements.push(slider);
  422. break;
  423. }
  424. case "button":
  425. this.title.setBorder("normal", '2px', 'white', '10px');
  426. this.title.el.style.cursor = "pointer";
  427. this.title.el.addEventListener("mousedown", () => {
  428. if (this.callbackFunc) {
  429. this.callbackFunc();
  430. }
  431. });
  432. break;
  433. case "color":
  434. break;
  435. }
  436. }
  437. load() {
  438. this.elements.forEach((element) => modCont.el.appendChild(element));
  439. }
  440.  
  441. unload() {
  442. this.elements.forEach((element) => {
  443. if (modCont.el.contains(element)) {
  444. modCont.el.removeChild(element);
  445. }
  446. });
  447. }
  448. }
  449.  
  450. class Category {
  451. constructor(name, modules) {
  452. this.name = name;
  453. this.element = new El(name, "div", "rgb(38, 38, 38)", "90px", "50px");
  454. this.element.setPosition("relative", "block");
  455. this.element.setText(
  456. name,
  457. "white",
  458. "Calibri",
  459. "bold",
  460. "20px",
  461. "2px",
  462. "center",
  463. "center"
  464. );
  465. this.element.setBorder("normal", "2px", "transparent", "10px");
  466. this.selected = false;
  467. this.modules = modules;
  468.  
  469. this.element.el.addEventListener("mousedown", (e) => {
  470. if (e.button !== 0) return;
  471. this.selected = !this.selected;
  472. this.element.el.style.backgroundColor = this.selected ?
  473. "lightgray" :
  474. "rgb(38, 38, 38)";
  475. handle_categories_selection(this.name);
  476. if (!this.selected) unload_modules(this.name);
  477. });
  478.  
  479. this.element.el.addEventListener("mouseover", () => {
  480. if (!this.selected) {
  481. this.element.el.style.backgroundColor = "rgb(58, 58, 58)";
  482. this.element.el.style.cursor = "pointer";
  483. }
  484. });
  485.  
  486. this.element.el.addEventListener("mouseout", () => {
  487. if (!this.selected)
  488. this.element.el.style.backgroundColor = "rgb(38, 38, 38)";
  489. });
  490. }
  491. unselect() {
  492. this.selected = false;
  493. this.element.el.style.backgroundColor = "rgb(38, 38, 38)";
  494. }
  495. }
  496.  
  497. //1travel
  498. let modules = {
  499. 'Info': {
  500. q_a1: new Module("Where is the rest of the scripts?", "button", null, null, () => {
  501. alert("They're patched, I can't make the bypass public for now, because it will be patched too");
  502. }),
  503. q_a2: new Module("Why no updates so long?", "button", null, null, () => {
  504. alert("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");
  505. }),
  506. q_a3: new Module("I have a problem/question where can I contact you?", "button", null, null, () => {
  507. alert("Dm me on discord. My tag is: h3llside");
  508. }),
  509. q_a4: new Module("What will happen to Diep.io+ after Diep Police Department?", "button", null, null, () => {
  510. alert(`
  511. There are two possbile outcomes:
  512. 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
  513. 2. I will make bannable cheats less detectable
  514. `);
  515. }),
  516. q_a5: new Module("I really want to have access for Addons, can I have it?", "button", null, null, () => {
  517. alert(`
  518. No, unless you give me something in return. For example some useful information for bypassing or someone's private script
  519. `);
  520. }),
  521. q_a6: new Module("I want you to make a script for me, can you do it?", "button", null, null, () => {
  522. alert(`
  523. 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
  524. `);
  525. }),
  526. },
  527. Visual: {
  528. Key_inputs_visualiser: new Module("Key Inputs Visualiser", "toggle"),
  529. display_hotkeys: new Module("Show Tank Upgrade Hotkeys", "toggle"),
  530. },
  531. Functional: {
  532. CopyLink: new Module("Copy Party Link", "button", null, null, () => {
  533. document.getElementById("copy-party-link").click();
  534. }),
  535. //glitched Name
  536. Sandbox_lvl_up: new Module("Sandbox Auto Level Up", "toggle"),
  537. Auto_respawn: new Module("Auto Respawn", "toggle"),
  538. Zoom: new Module("Zoom Out", "slider"),
  539. },
  540. Mouse: {
  541. Anti_aim: new Module("Anti Aim", "toggle"),
  542. Freeze_mouse: new Module("Freeze Mouse", "toggle"),
  543. Anti_timeout: new Module("Anti AFK Timeout", "toggle"),
  544. },
  545. DiepConsole: {
  546. con_toggle: new Module("Show/hide Diep Console", "toggle"),
  547. net_predict_movement: new Module("predict movement", "toggle"),
  548. //game builds
  549. //render
  550. },
  551. Addons: {},
  552. };
  553.  
  554. let categories = [];
  555.  
  556. function create_categories() {
  557. for (let key in modules) {
  558. categories.push(new Category(key, modules[key]));
  559. }
  560. }
  561. create_categories();
  562.  
  563. function load_modules(category_name) {
  564. const current_category = categories.find(
  565. (category) => category.name === category_name
  566. );
  567. for (let moduleName in current_category.modules) {
  568. current_category.modules[moduleName].load();
  569. }
  570. }
  571.  
  572. function unload_modules(category_name) {
  573. const current_category = categories.find(
  574. (category) => category.name === category_name
  575. );
  576. for (let moduleName in current_category.modules) {
  577. current_category.modules[moduleName].unload();
  578. }
  579. }
  580.  
  581. function handle_categories_selection(current_name) {
  582. categories.forEach((category) => {
  583. if (category.name !== current_name && category.selected) {
  584. category.unselect();
  585. unload_modules(category.name);
  586. }
  587. });
  588.  
  589. load_modules(current_name);
  590. }
  591.  
  592. function loadCategories() {
  593. const categoryCont = document.querySelector("#sub-container-gray");
  594. categories.forEach((category) =>
  595. categoryCont.appendChild(category.element.el)
  596. );
  597. }
  598.  
  599. function load_selected() {
  600. categories.forEach((category) => {
  601. if (category.selected) {
  602. load_modules(category.name);
  603. }
  604. });
  605. }
  606.  
  607. function loadGUI() {
  608. document.body.style.margin = "0";
  609. document.body.style.display = "flex";
  610. document.body.style.justifyContent = "left";
  611.  
  612. mainCont = new El("Main Cont", "div", "rgb(38, 38, 38)", "500px", "400px");
  613. mainCont.setBorder("normal", "2px", "lime", "10px");
  614. mainCont.el.style.display = "flex";
  615. mainCont.el.style.flexDirection = "column";
  616. mainCont.add(document.body);
  617.  
  618. header = new El("Headline Dp", "div", "transparent", "100%", "40px");
  619. header.setBorder("bottom", "2px", "rgb(106, 173, 84)");
  620. header.setText(
  621. "Diep.io+ by r!PsAw (Hide GUI with J)",
  622. "white",
  623. "Calibri",
  624. "bold",
  625. "20px",
  626. "2px",
  627. "center",
  628. "center"
  629. );
  630. header.add(mainCont.el);
  631.  
  632. const contentWrapper = document.createElement("div");
  633. contentWrapper.style.display = "flex";
  634. contentWrapper.style.gap = "10px";
  635. contentWrapper.style.padding = "10px";
  636. contentWrapper.style.flex = "1";
  637. mainCont.el.appendChild(contentWrapper);
  638.  
  639. subContGray = new El(
  640. "Sub Container Gray",
  641. "div",
  642. "transparent",
  643. "100px",
  644. "100%"
  645. );
  646. subContGray.el.style.display = "flex";
  647. subContGray.el.style.flexDirection = "column";
  648. subContGray.el.style.overflowY = "auto";
  649. subContGray.add(contentWrapper);
  650.  
  651. subContBlack = new El("Sub Container Black", "div", "black", "360px", "100%");
  652. subContBlack.el.style.display = "flex";
  653. subContBlack.el.style.gap = "10px";
  654. subContBlack.add(contentWrapper);
  655.  
  656. modCont = new El("Module Container", "div", "transparent", "50%", "100%");
  657. modCont.el.style.display = "flex";
  658. modCont.el.style.flexDirection = "column";
  659. modCont.el.style.overflowY = "auto";
  660. modCont.setBorder("right", "2px", "white");
  661. modCont.add(subContBlack.el);
  662.  
  663. settCont = new El("Settings Container", "div", "transparent", "50%", "100%");
  664. settCont.el.style.display = "flex";
  665. settCont.el.style.flexDirection = "column";
  666. settCont.el.style.overflowY = "auto";
  667. settCont.add(subContBlack.el);
  668.  
  669. loadCategories();
  670. load_selected();
  671. }
  672.  
  673. loadGUI();
  674. document.addEventListener("keydown", toggleGUI);
  675.  
  676. function toggleGUI(e) {
  677. if (e.key === "j" || e.key === "J") {
  678. if (mainCont.el) {
  679. mainCont.remove(document.body);
  680. mainCont.el = null;
  681. } else {
  682. loadGUI();
  683. }
  684. }
  685. }
  686.  
  687. //actual logic
  688.  
  689. // ]-[ HTML RELATED STUFF
  690. let homescreen = document.getElementById("home-screen");
  691. let ingamescreen = document.getElementById("in-game-screen");
  692. let gameOverScreen = document.getElementById('game-over-screen');
  693. let gameOverScreenContainer = document.querySelector("#game-over-screen > div > div.game-details > div:nth-child(1)");
  694. function update_scale_option(selector, label, min, max) {
  695. let element = document.querySelector(selector);
  696. let label_element = element.closest("div").querySelector("span");
  697. label_element.innerHTML = `[DIEP.IO+] ${label}`;
  698. label_element.style.background = "black";
  699. label_element.style.color = "purple";
  700. element.min = min;
  701. element.max = max;
  702. }
  703.  
  704. function new_ranges_for_scales() {
  705. update_scale_option("#subsetting-option-ui_scale", "UI Scale", '0.01', '1000');
  706. update_scale_option("#subsetting-option-border_radius", "UI Border Radius", '0.01', '1000');
  707. update_scale_option("#subsetting-option-border_intensity", "UI Border Intensity", '0.01', '1000');
  708. }
  709.  
  710. new_ranges_for_scales();
  711.  
  712. //detect gamemode
  713. let gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  714. let last_gamemode = localStorage.getItem(`[Diep.io+] last_gm`);
  715. localStorage.setItem(`[Diep.io+] last_gm}`, gamemode);
  716.  
  717. function check_gamemode() {
  718. gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  719. save_gm();
  720. }
  721.  
  722. setInterval(check_gamemode, 250);
  723.  
  724. function save_gm() {
  725. let saved_gm = localStorage.getItem(`[Diep.io+] last_gm`);
  726. if (saved_gm != null && saved_gm != gamemode) {
  727. last_gamemode = saved_gm;
  728. }
  729. saved_gm === null ? localStorage.setItem(`[Diep.io+] last_gm}`, gamemode) : null;
  730. }
  731.  
  732. //personal best
  733. let your_final_score = 0;
  734. const personal_best = document.createElement('div');
  735. const gameDetail = document.createElement('div');
  736. const label = document.createElement('div');
  737. //applying class
  738. gameDetail.classList.add("game-detail");
  739. label.classList.add("label");
  740. personal_best.classList.add("value");
  741. //text context
  742. label.textContent = "Best:";
  743. //adding to html
  744. gameOverScreenContainer.appendChild(gameDetail);
  745. gameDetail.appendChild(label);
  746. gameDetail.appendChild(personal_best);
  747.  
  748. function load_ls() {
  749. return localStorage.getItem(gamemode);
  750. }
  751.  
  752. function save_ls() {
  753. localStorage.setItem(gamemode, your_final_score);
  754. }
  755.  
  756. function check_final_score() {
  757. if (window.__common__.screen_state === "game-over") {
  758. your_final_score = window.__common__.death_score;
  759. let saved_score = parseFloat(load_ls());
  760. personal_best.textContent = saved_score;
  761. if (saved_score < your_final_score) {
  762. personal_best.textContent = your_final_score;
  763. save_ls();
  764. }
  765. }
  766. }
  767.  
  768. setInterval(check_final_score, 100);
  769.  
  770. //remove annoying html elements
  771. function instant_remove() {
  772. // Define selectors for elements to remove
  773. const selectors = [
  774. "#cmpPersistentLink",
  775. "#apes-io-promo",
  776. "#apes-io-promo > img",
  777. "#last-updated",
  778. "#diep-io_300x250"
  779. ];
  780.  
  781. // Remove each selected element
  782. selectors.forEach(selector => {
  783. const element = document.querySelector(selector);
  784. if (element) {
  785. element.remove();
  786. }
  787. });
  788.  
  789. // If all elements have been removed, clear the interval
  790. if (selectors.every(selector => !document.querySelector(selector))) {
  791. deep_debug("Removed all ads, quitting...");
  792. clearInterval(interval);
  793. }
  794. }
  795.  
  796. // Set an interval to check for ads
  797. const interval = setInterval(instant_remove, 100);
  798.  
  799. // ]-[
  800.  
  801. //DiepConsole
  802. function handle_con_toggle(state){
  803. if(extern.isConActive() != state){
  804. extern.execute('con_toggle');
  805. }
  806. }
  807.  
  808. function update_diep_console(){
  809. for(let param in modules.DiepConsole){
  810. let state = modules.DiepConsole[param].active;
  811. if(param === "con_toggle"){
  812. handle_con_toggle(state)
  813. }else{
  814. extern.set_convar(param, state);
  815. }
  816. }
  817. }
  818. setInterval(update_diep_console, 100);
  819.  
  820. //////
  821. //mouse functions
  822.  
  823. window.addEventListener('mousemove', function(event) {
  824. inputs.mouse.real.x = event.clientX;
  825. inputs.mouse.real.y = event.clientY;
  826. });
  827.  
  828. window.addEventListener('mousedown', function(event) {
  829. if (modules.Mouse.Anti_aim.active) {
  830. if (inputs.mouse.shooting) {
  831. return;
  832. }
  833. inputs.mouse.shooting = true;
  834. freezeMouseMove();
  835. setTimeout(function() {
  836. inputs.mouse.shooting = false;
  837. mouse_move('extern', inputs.mouse.real.x, inputs.mouse.real.y);
  838. click_at('extern', inputs.mouse.real.x, inputs.mouse.real.y);
  839. }, 50);
  840. };
  841. });
  842.  
  843. function handle_mouse_functions() {
  844. window.requestAnimationFrame(handle_mouse_functions);
  845. if (!player.connected) {
  846. return;
  847. }
  848. modules.Mouse.Freeze_mouse.active ? freezeMouseMove() : unfreezeMouseMove();
  849. modules.Mouse.Anti_aim.active ? anti_aim("On") : anti_aim("Off");
  850. }
  851. window.requestAnimationFrame(handle_mouse_functions);
  852.  
  853. //anti aim
  854. function detect_corner() {
  855. deep_debug('corner detect called');
  856. let w = window.innerWidth;
  857. let h = window.innerHeight;
  858. let center = {
  859. x: w / 2,
  860. y: h / 2
  861. };
  862. let lr, ud;
  863. inputs.mouse.real.x > center.x ? lr = "r" : lr = "l";
  864. inputs.mouse.real.y > center.y ? ud = "d" : ud = "u";
  865. deep_debug('output: ', lr + ud);
  866. return lr + ud;
  867. }
  868.  
  869. function look_at_corner(corner) {
  870. deep_debug('look at corner called with corner', corner);
  871. if (!inputs.mouse.shooting) {
  872. let w = window.innerWidth;
  873. let h = window.innerHeight;
  874. deep_debug('w and h', w, h);
  875. deep_debug('inputs: ', inputs);
  876. switch (corner) {
  877. case "lu":
  878. anti_aim_at('extern', w, h);
  879. break
  880. case "ld":
  881. anti_aim_at('extern', w, 0);
  882. break
  883. case "ru":
  884. anti_aim_at('extern', 0, h);
  885. break
  886. case "rd":
  887. anti_aim_at('extern', 0, 0);
  888. break
  889. }
  890. }
  891. }
  892.  
  893. function anti_aim(toggle) {
  894. deep_debug('anti aim called with:', toggle);
  895. switch (toggle) {
  896. case "On":
  897. if (modules.Mouse.Anti_aim.active) {
  898. deep_debug('condition !modules.Mouse.Anti_aim.active met');
  899. look_at_corner(detect_corner());
  900. }
  901. break
  902. case "Off":
  903. deep_debug('inputs.mouse.isFrozen ', inputs.mouse.isFrozen);
  904. (inputs.mouse.isFrozen && !modules.Mouse.Freeze_mouse.active) ? unfreezeMouseMove(): null;
  905. break
  906. }
  907. }
  908. // Example: Freeze and unfreeze
  909. function freezeMouseMove() {
  910. if (!inputs.mouse.isFrozen) {
  911. inputs.mouse.isFrozen = true;
  912. clear_onTouch();
  913. deep_debug("Mousemove events are frozen.");
  914. }
  915. }
  916.  
  917. function unfreezeMouseMove() {
  918. if (inputs.mouse.isFrozen && !inputs.mouse.isShooting) {
  919. inputs.mouse.isFrozen = false;
  920. redefine_onTouch();
  921. deep_debug("Mousemove events are active.");
  922. }
  923. }
  924.  
  925. function click_at(input_or_extern, x, y, delay1 = 150, delay2 = 500) {
  926. i_e(input_or_extern, 'onTouchStart', -1, x, y);
  927. setTimeout(() => {
  928. i_e(input_or_extern, 'onTouchEnd', -1, x, y);
  929. }, delay1);
  930. setTimeout(() => {
  931. inputs.mouse.shooting = false;
  932. }, delay2);
  933. }
  934.  
  935. /* it was a bug and is now patched
  936. function ghost_click_at(input_or_extern, x, y, delay1 = 150, delay2 = 500) {
  937. i_e(input_or_extern, 'onTouchStart', -2, x, y);
  938. setTimeout(() => {
  939. i_e(input_or_extern, 'onTouchEnd', -2, x, y);
  940. }, delay1);
  941. setTimeout(() => {
  942. inputs.mouse.shooting = false;
  943. }, delay2);
  944. }
  945. */
  946.  
  947. function mouse_move(input_or_extern, x, y) {
  948. deep_debug('mouse move called with', x, y);
  949. apply_force(x, y);
  950. i_e(input_or_extern, 'onTouchMove', -1, x, y);
  951. disable_force();
  952. }
  953.  
  954. function anti_aim_at(input_or_extern, x, y) {
  955. deep_debug('frozen, shooting', inputs.mouse.isFrozen, inputs.mouse.isShooting);
  956. deep_debug('anti aim at called with:', x, y);
  957. if (inputs.mouse.shooting) {
  958. deep_debug('quit because inputs.mouse.shooting');
  959. return;
  960. }
  961. mouse_move(input_or_extern, x, y);
  962. }
  963. //////
  964.  
  965. //Sandbox Auto Lvl up
  966. function sandbox_lvl_up() {
  967. if (modules.Functional.Sandbox_lvl_up.active && player.connected && player.inGame && player.gamemode === "sandbox") {
  968. document.querySelector("#sandbox-max-level").click();
  969. }
  970. }
  971. setInterval(sandbox_lvl_up, 500);
  972.  
  973. //autorespawn
  974. function respawn() {
  975. deep_debug(modules);
  976. if (modules.Functional.Auto_respawn.active && player.connected && !player.inGame) {
  977. extern.try_spawn(player.name);
  978. }
  979. }
  980.  
  981. setInterval(respawn, 1000);
  982.  
  983. //AntiAfk Timeout
  984. function AntiAfkTimeout() {
  985. if (modules.Mouse.Anti_timeout.active && player.connected) {
  986. extern.onTouchMove(inputs.mouse.real.x, inputs.mouse.real.y);
  987. }
  988. }
  989. setInterval(AntiAfkTimeout, 1000);
  990.  
  991. //Zoom
  992. function HandleZoom() {
  993. window.requestAnimationFrame(HandleZoom);
  994. if (!player.isConnected) return;
  995. player.dpr = 1;
  996. let factor = modules.Functional.Zoom.value / 100;
  997. extern.setScreensizeZoom(player.ui_scale, player.dpr * factor);
  998. extern.updateDPR(player.dpr);
  999. }
  1000. window.requestAnimationFrame(HandleZoom);
  1001.  
  1002. //ctx helper functions
  1003. function ctx_text(fcolor, scolor, lineWidth, font, text, textX, textY) {
  1004. deep_debug('called crx_text with: ', fcolor, scolor, lineWidth, font, text, textX, textY);
  1005. ctx.fillStyle = fcolor;
  1006. ctx.lineWidth = lineWidth;
  1007. ctx.font = font;
  1008. ctx.strokeStyle = scolor;
  1009. ctx.strokeText(`${text}`, textX, textY)
  1010. ctx.fillText(`${text}`, textX, textY)
  1011. }
  1012.  
  1013. function ctx_rect(x, y, a, b, c) {
  1014. deep_debug('called ctx_rect with: ', x, y, a, b, c);
  1015. ctx.beginPath();
  1016. ctx.strokeStyle = c;
  1017. ctx.strokeRect(x, y, a, b);
  1018. }
  1019.  
  1020. function transparent_rect_fill(x, y, a, b, scolor, fcolor, opacity){
  1021. deep_debug('called transparent_rect_fill with: ', x, y, a, b, scolor, fcolor, opacity);
  1022. ctx.beginPath();
  1023. ctx.rect(x, y, a, b);
  1024.  
  1025. // Set stroke opacity
  1026. ctx.globalAlpha = 1;// Reset to 1 for stroke, or set as needed
  1027. ctx.strokeStyle = scolor;
  1028. ctx.stroke();
  1029.  
  1030. // Set fill opacity
  1031. ctx.globalAlpha = opacity;// Set the opacity for the fill color
  1032. ctx.fillStyle = fcolor;
  1033. ctx.fill();
  1034.  
  1035. // Reset globalAlpha back to 1 for future operations
  1036. ctx.globalAlpha = 1;
  1037. }
  1038.  
  1039. //key visualiser
  1040. let ctx_wasd = {
  1041. square_sizes: { //in windowScaling
  1042. a: 50,
  1043. b: 50
  1044. },
  1045. text_props: {
  1046. lineWidth: 3,
  1047. font: 1 + "em Ubuntu",
  1048. },
  1049. square_colors: {
  1050. stroke: "black",
  1051. unpressed: "yellow",
  1052. pressed: "orange"
  1053. },
  1054. text_colors: {
  1055. stroke: "black",
  1056. unpressed: "orange",
  1057. pressed: "red"
  1058. },
  1059. w: {
  1060. x: 300,
  1061. y: 200,
  1062. pressed: false,
  1063. text: 'W'
  1064. },
  1065. a: {
  1066. x: 350,
  1067. y: 150,
  1068. pressed: false,
  1069. text: 'A'
  1070. },
  1071. s: {
  1072. x: 300,
  1073. y: 150,
  1074. pressed: false,
  1075. text: 'S'
  1076. },
  1077. d: {
  1078. x: 250,
  1079. y: 150,
  1080. pressed: false,
  1081. text: 'D'
  1082. },
  1083. l_m: {
  1084. x: 350,
  1085. y: 75,
  1086. pressed: false,
  1087. text: 'LMC'
  1088. },
  1089. r_m: {
  1090. x: 250,
  1091. y: 75,
  1092. pressed: false,
  1093. text: 'RMC'
  1094. },
  1095. }
  1096.  
  1097. function visualise_keys(){
  1098. let keys = ['w', 'a', 's', 'd', 'l_m', 'r_m'];
  1099. let l = keys.length;
  1100. for(let i = 0; i < l; i++){
  1101. let args = {
  1102. x: canvas.width - dim_c.windowScaling_2_canvas(ctx_wasd[keys[i]].x),
  1103. y: canvas.height - dim_c.windowScaling_2_canvas(ctx_wasd[keys[i]].y),
  1104. a: dim_c.windowScaling_2_canvas(ctx_wasd.square_sizes.a),
  1105. b: dim_c.windowScaling_2_canvas(ctx_wasd.square_sizes.b),
  1106. s_c: ctx_wasd.square_colors.stroke,
  1107. f_c: ctx_wasd[keys[i]].pressed? ctx_wasd.square_colors.pressed : ctx_wasd.square_colors.unpressed,
  1108. t_s: ctx_wasd.text_colors.stroke,
  1109. t_f: ctx_wasd[keys[i]].pressed? ctx_wasd.text_colors.pressed : ctx_wasd.text_colors.unpressed,
  1110. t_lineWidth: ctx_wasd.text_props.lineWidth,
  1111. t_font: ctx_wasd.text_props.font,
  1112. text: ctx_wasd[keys[i]].text,
  1113. opacity: 0.25
  1114. }
  1115. deep_debug(args);
  1116. transparent_rect_fill(
  1117. args.x,
  1118. args.y,
  1119. args.a,
  1120. args.b,
  1121. args.s_c,
  1122. args.f_c,
  1123. args.opacity
  1124. );
  1125. ctx_text(
  1126. args.t_f,
  1127. args.t_s,
  1128. args.t_lineWidth,
  1129. args.t_font,
  1130. args.text,
  1131. args.x+(args.a/2),
  1132. args.y+(args.b/2)
  1133. );
  1134. }
  1135. }
  1136.  
  1137. //Key Binds for Tank Upgrading
  1138. let selected_box = null;
  1139. let _bp = { //box parameters
  1140. startX: 47,
  1141. startY: 67,
  1142. distX: 13,
  1143. distY: 9,
  1144. width: 86,
  1145. height: 86,
  1146. outer_xy: 2
  1147. }
  1148.  
  1149. let _bo = { //box offsets
  1150. offsetX: _bp.width + (_bp.outer_xy * 2) + _bp.distX,
  1151. offsetY: _bp.height + (_bp.outer_xy * 2) + _bp.distY
  1152. }
  1153.  
  1154. function step_offset(steps, offset){
  1155. let final_offset = 0;
  1156. switch(offset){
  1157. case "x":
  1158. final_offset = _bp.startX + (steps * _bo.offsetX);
  1159. break
  1160. case "y":
  1161. final_offset = _bp.startY + (steps * _bo.offsetY);
  1162. break
  1163. }
  1164. return final_offset;
  1165. }
  1166.  
  1167. const boxes = [
  1168. {
  1169. color: "lightblue",
  1170. LUcornerX: _bp.startX,
  1171. LUcornerY: _bp.startY,
  1172. KeyBind: "R"
  1173. },
  1174. {
  1175. color: "green",
  1176. LUcornerX: _bp.startX + _bo.offsetX,
  1177. LUcornerY: _bp.startY,
  1178. KeyBind: "T"
  1179. },
  1180. {
  1181. color: "red",
  1182. LUcornerX: _bp.startX,
  1183. LUcornerY: _bp.startY + _bo.offsetY,
  1184. KeyBind: "F"
  1185. },
  1186. {
  1187. color: "yellow",
  1188. LUcornerX: _bp.startX + _bo.offsetX,
  1189. LUcornerY: _bp.startY + _bo.offsetY,
  1190. KeyBind: "G"
  1191. },
  1192. {
  1193. color: "blue",
  1194. LUcornerX: _bp.startX,
  1195. LUcornerY: step_offset(2, "y"),
  1196. KeyBind: "V"
  1197. },
  1198. {
  1199. color: "purple",
  1200. LUcornerX: _bp.startX + _bo.offsetX,
  1201. LUcornerY: step_offset(2, "y"),
  1202. KeyBind: "B"
  1203. }
  1204. ]
  1205.  
  1206. //upgrading Tank logic
  1207. function upgrade_get_coords(color){
  1208. let l = boxes.length;
  1209. let upgrade_coords = {x: "not defined", y: "not defined"};
  1210. for(let i = 0; i < l; i++){
  1211. if(boxes[i].color === color){
  1212. upgrade_coords.x = dim_c.windowScaling_2_window(boxes[i].LUcornerX + (_bp.width/2));
  1213. upgrade_coords.y = dim_c.windowScaling_2_window(boxes[i].LUcornerY + (_bp.height/2));
  1214. }
  1215. }
  1216. deep_debug(upgrade_coords);
  1217. return upgrade_coords;
  1218. }
  1219.  
  1220. function upgrade(color, delay = 100, cdelay1, cdelay2){
  1221. let u_coords = upgrade_get_coords(color);
  1222. //ghost_click_at('extern', u_coords.x, u_coords.y, cdelay1, cdelay2);
  1223. click_at('extern', u_coords.x, u_coords.y, cdelay1, cdelay2); //using this since ghost_click was patched
  1224. }
  1225.  
  1226. function visualise_tank_upgrades(){
  1227. let l = boxes.length;
  1228. for (let i = 0; i < l; i++) {
  1229. let coords = upgrade_get_coords(boxes[i].color);
  1230. ctx_text(boxes[i].color, "black", 6, 1.5 + "em Ubuntu", `[${boxes[i].KeyBind}]`, coords.x, coords.y);
  1231. }
  1232. }
  1233.  
  1234. function check_tu_KeyBind(_KeyBind){
  1235. let l = boxes.length;
  1236. for (let i = 0; i < l; i++) {
  1237. if(_KeyBind === `Key${boxes[i].KeyBind}`){
  1238. deep_debug(_KeyBind, `Key${boxes[i].KeyBind}`, _KeyBind === `Key${boxes[i].KeyBind}`);
  1239. upgrade(boxes[i].color);
  1240. }
  1241. }
  1242. }
  1243.  
  1244. document.body.addEventListener("keydown", function(e) {
  1245. switch(e.code){
  1246. case "KeyW":
  1247. ctx_wasd.w.pressed = true;
  1248. break
  1249. case "KeyA":
  1250. ctx_wasd.a.pressed = true;
  1251. break
  1252. case "KeyS":
  1253. ctx_wasd.s.pressed = true;
  1254. break
  1255. case "KeyD":
  1256. ctx_wasd.d.pressed = true;
  1257. break
  1258. }
  1259. check_tu_KeyBind(e.code);
  1260. });
  1261.  
  1262. document.body.addEventListener("keyup", function(e) {
  1263. deep_debug(`unpressed ${e.code}`);
  1264. switch(e.code){
  1265. case "KeyW":
  1266. ctx_wasd.w.pressed = false;
  1267. break
  1268. case "KeyA":
  1269. ctx_wasd.a.pressed = false;
  1270. break
  1271. case "KeyS":
  1272. ctx_wasd.s.pressed = false;
  1273. break
  1274. case "KeyD":
  1275. ctx_wasd.d.pressed = false;
  1276. break
  1277. }
  1278. deep_debug('====DID UNPRESS??', ctx_wasd.w.pressed, ctx_wasd.a.pressed, ctx_wasd.s.pressed, ctx_wasd.d.pressed);
  1279. });
  1280.  
  1281. document.body.addEventListener("mousedown", function(e) {
  1282. switch(e.button){
  1283. case 0:
  1284. ctx_wasd.l_m.pressed = true;
  1285. break
  1286. case 2:
  1287. ctx_wasd.r_m.pressed = true;
  1288. break
  1289. }
  1290. });
  1291.  
  1292. document.body.addEventListener("mouseup", function(e) {
  1293. switch(e.button){
  1294. case 0:
  1295. ctx_wasd.l_m.pressed = false;
  1296. break
  1297. case 2:
  1298. ctx_wasd.r_m.pressed = false;
  1299. break
  1300. }
  1301. });
  1302.  
  1303.  
  1304. //canvas gui (try to keep this in the end
  1305. setTimeout(() => {
  1306. let gui = () => {
  1307. if (player.inGame) {
  1308. if(modules.Visual.display_hotkeys.active){
  1309. visualise_tank_upgrades();
  1310. }
  1311. if (modules.Visual.Key_inputs_visualiser.active) {
  1312. visualise_keys();
  1313. }
  1314. }
  1315. window.requestAnimationFrame(gui); // Start animation loop
  1316. };
  1317. gui();
  1318. }, 500); // Delay before starting the rendering