Diep.io+ (2.2 OUT NOW!)

Work in progres...

目前为 2025-02-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Diep.io+ (2.2 OUT NOW!)
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.2.0
  5. // @description Work in progres...
  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. //not finished with importing old functions yet
  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. },
  530. Functional: {
  531. CopyLink: new Module("Copy Party Link", "button", null, null, () => {
  532. document.getElementById("copy-party-link").click();
  533. }),
  534. //glitched Name
  535. Sandbox_lvl_up: new Module("Sandbox Auto Level Up", "toggle"),
  536. Auto_respawn: new Module("Auto Respawn", "toggle"),
  537. Anti_timeout: new Module("Anti AFK Timeout", "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. },
  544. DiepConsole: {
  545. con_toggle: new Module("Show/hide Diep Console", "toggle"),
  546. net_predict_movement: new Module("predict movement", "toggle"),
  547. //game builds
  548. //render
  549. },
  550. Addons: {},
  551. };
  552.  
  553. let categories = [];
  554.  
  555. function create_categories() {
  556. for (let key in modules) {
  557. categories.push(new Category(key, modules[key]));
  558. }
  559. }
  560. create_categories();
  561.  
  562. function load_modules(category_name) {
  563. const current_category = categories.find(
  564. (category) => category.name === category_name
  565. );
  566. for (let moduleName in current_category.modules) {
  567. current_category.modules[moduleName].load();
  568. }
  569. }
  570.  
  571. function unload_modules(category_name) {
  572. const current_category = categories.find(
  573. (category) => category.name === category_name
  574. );
  575. for (let moduleName in current_category.modules) {
  576. current_category.modules[moduleName].unload();
  577. }
  578. }
  579.  
  580. function handle_categories_selection(current_name) {
  581. categories.forEach((category) => {
  582. if (category.name !== current_name && category.selected) {
  583. category.unselect();
  584. unload_modules(category.name);
  585. }
  586. });
  587.  
  588. load_modules(current_name);
  589. }
  590.  
  591. function loadCategories() {
  592. const categoryCont = document.querySelector("#sub-container-gray");
  593. categories.forEach((category) =>
  594. categoryCont.appendChild(category.element.el)
  595. );
  596. }
  597.  
  598. function load_selected() {
  599. categories.forEach((category) => {
  600. if (category.selected) {
  601. load_modules(category.name);
  602. }
  603. });
  604. }
  605.  
  606. function loadGUI() {
  607. document.body.style.margin = "0";
  608. document.body.style.display = "flex";
  609. document.body.style.justifyContent = "left";
  610.  
  611. mainCont = new El("Main Cont", "div", "rgb(38, 38, 38)", "500px", "400px");
  612. mainCont.setBorder("normal", "2px", "lime", "10px");
  613. mainCont.el.style.display = "flex";
  614. mainCont.el.style.flexDirection = "column";
  615. mainCont.add(document.body);
  616.  
  617. header = new El("Headline Dp", "div", "transparent", "100%", "40px");
  618. header.setBorder("bottom", "2px", "rgb(106, 173, 84)");
  619. header.setText(
  620. "Diep.io+ by r!PsAw (Hide GUI with J)",
  621. "white",
  622. "Calibri",
  623. "bold",
  624. "20px",
  625. "2px",
  626. "center",
  627. "center"
  628. );
  629. header.add(mainCont.el);
  630.  
  631. const contentWrapper = document.createElement("div");
  632. contentWrapper.style.display = "flex";
  633. contentWrapper.style.gap = "10px";
  634. contentWrapper.style.padding = "10px";
  635. contentWrapper.style.flex = "1";
  636. mainCont.el.appendChild(contentWrapper);
  637.  
  638. subContGray = new El(
  639. "Sub Container Gray",
  640. "div",
  641. "transparent",
  642. "100px",
  643. "100%"
  644. );
  645. subContGray.el.style.display = "flex";
  646. subContGray.el.style.flexDirection = "column";
  647. subContGray.el.style.overflowY = "auto";
  648. subContGray.add(contentWrapper);
  649.  
  650. subContBlack = new El("Sub Container Black", "div", "black", "360px", "100%");
  651. subContBlack.el.style.display = "flex";
  652. subContBlack.el.style.gap = "10px";
  653. subContBlack.add(contentWrapper);
  654.  
  655. modCont = new El("Module Container", "div", "transparent", "50%", "100%");
  656. modCont.el.style.display = "flex";
  657. modCont.el.style.flexDirection = "column";
  658. modCont.el.style.overflowY = "auto";
  659. modCont.setBorder("right", "2px", "white");
  660. modCont.add(subContBlack.el);
  661.  
  662. settCont = new El("Settings Container", "div", "transparent", "50%", "100%");
  663. settCont.el.style.display = "flex";
  664. settCont.el.style.flexDirection = "column";
  665. settCont.el.style.overflowY = "auto";
  666. settCont.add(subContBlack.el);
  667.  
  668. loadCategories();
  669. load_selected();
  670. }
  671.  
  672. loadGUI();
  673. document.addEventListener("keydown", toggleGUI);
  674.  
  675. function toggleGUI(e) {
  676. if (e.key === "j" || e.key === "J") {
  677. if (mainCont.el) {
  678. mainCont.remove(document.body);
  679. mainCont.el = null;
  680. } else {
  681. loadGUI();
  682. }
  683. }
  684. }
  685.  
  686. //actual logic
  687.  
  688. // ]-[ HTML RELATED STUFF
  689. let homescreen = document.getElementById("home-screen");
  690. let ingamescreen = document.getElementById("in-game-screen");
  691. let gameOverScreen = document.getElementById('game-over-screen');
  692. let gameOverScreenContainer = document.querySelector("#game-over-screen > div > div.game-details > div:nth-child(1)");
  693. function update_scale_option(selector, label, min, max) {
  694. let element = document.querySelector(selector);
  695. let label_element = element.closest("div").querySelector("span");
  696. label_element.innerHTML = `[DIEP.IO+] ${label}`;
  697. label_element.style.background = "black";
  698. label_element.style.color = "purple";
  699. element.min = min;
  700. element.max = max;
  701. }
  702.  
  703. function new_ranges_for_scales() {
  704. update_scale_option("#subsetting-option-ui_scale", "UI Scale", '0.01', '1000');
  705. update_scale_option("#subsetting-option-border_radius", "UI Border Radius", '0.01', '1000');
  706. update_scale_option("#subsetting-option-border_intensity", "UI Border Intensity", '0.01', '1000');
  707. }
  708.  
  709. new_ranges_for_scales();
  710.  
  711. //detect gamemode
  712. let gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  713. let last_gamemode = localStorage.getItem(`[Diep.io+] last_gm`);
  714. localStorage.setItem(`[Diep.io+] last_gm}`, gamemode);
  715.  
  716. function check_gamemode() {
  717. gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  718. save_gm();
  719. }
  720.  
  721. setInterval(check_gamemode, 250);
  722.  
  723. function save_gm() {
  724. let saved_gm = localStorage.getItem(`[Diep.io+] last_gm`);
  725. if (saved_gm != null && saved_gm != gamemode) {
  726. last_gamemode = saved_gm;
  727. }
  728. saved_gm === null ? localStorage.setItem(`[Diep.io+] last_gm}`, gamemode) : null;
  729. }
  730.  
  731. //personal best
  732. let your_final_score = 0;
  733. const personal_best = document.createElement('div');
  734. const gameDetail = document.createElement('div');
  735. const label = document.createElement('div');
  736. //applying class
  737. gameDetail.classList.add("game-detail");
  738. label.classList.add("label");
  739. personal_best.classList.add("value");
  740. //text context
  741. label.textContent = "Best:";
  742. //adding to html
  743. gameOverScreenContainer.appendChild(gameDetail);
  744. gameDetail.appendChild(label);
  745. gameDetail.appendChild(personal_best);
  746.  
  747. function load_ls() {
  748. return localStorage.getItem(gamemode);
  749. }
  750.  
  751. function save_ls() {
  752. localStorage.setItem(gamemode, your_final_score);
  753. }
  754.  
  755. function check_final_score() {
  756. if (window.__common__.screen_state === "game-over") {
  757. your_final_score = window.__common__.death_score;
  758. let saved_score = parseFloat(load_ls());
  759. personal_best.textContent = saved_score;
  760. if (saved_score < your_final_score) {
  761. personal_best.textContent = your_final_score;
  762. save_ls();
  763. }
  764. }
  765. }
  766.  
  767. setInterval(check_final_score, 100);
  768.  
  769. //remove annoying html elements
  770. function instant_remove() {
  771. // Define selectors for elements to remove
  772. const selectors = [
  773. "#cmpPersistentLink",
  774. "#apes-io-promo",
  775. "#apes-io-promo > img",
  776. "#last-updated",
  777. "#diep-io_300x250"
  778. ];
  779.  
  780. // Remove each selected element
  781. selectors.forEach(selector => {
  782. const element = document.querySelector(selector);
  783. if (element) {
  784. element.remove();
  785. }
  786. });
  787.  
  788. // If all elements have been removed, clear the interval
  789. if (selectors.every(selector => !document.querySelector(selector))) {
  790. console.log("Removed all ads, quitting...");
  791. clearInterval(interval);
  792. }
  793. }
  794.  
  795. // Set an interval to check for ads
  796. const interval = setInterval(instant_remove, 100);
  797.  
  798. // ]-[
  799.  
  800. //DiepConsole
  801. function handle_con_toggle(state){
  802. if(extern.isConActive() != state){
  803. extern.execute('con_toggle');
  804. }
  805. }
  806.  
  807. function update_diep_console(){
  808. for(let param in modules.DiepConsole){
  809. let state = modules.DiepConsole[param].active;
  810. if(param === "con_toggle"){
  811. handle_con_toggle(state)
  812. }else{
  813. extern.set_convar(param, state);
  814. }
  815. }
  816. }
  817. setInterval(update_diep_console, 100);
  818.  
  819. //////
  820. //mouse functions
  821.  
  822. window.addEventListener('mousemove', function(event) {
  823. inputs.mouse.real.x = event.clientX;
  824. inputs.mouse.real.y = event.clientY;
  825. });
  826.  
  827. window.addEventListener('mousedown', function(event) {
  828. if (modules.Mouse.Anti_aim.active) {
  829. if (inputs.mouse.shooting) {
  830. return;
  831. }
  832. inputs.mouse.shooting = true;
  833. freezeMouseMove();
  834. setTimeout(function() {
  835. inputs.mouse.shooting = false;
  836. mouse_move('extern', inputs.mouse.real.x, inputs.mouse.real.y);
  837. click_at('extern', inputs.mouse.real.x, inputs.mouse.real.y);
  838. }, 50);
  839. };
  840. });
  841.  
  842. function handle_mouse_functions() {
  843. window.requestAnimationFrame(handle_mouse_functions);
  844. if (!player.connected) {
  845. return;
  846. }
  847. modules.Mouse.Freeze_mouse.active ? freezeMouseMove() : unfreezeMouseMove();
  848. modules.Mouse.Anti_aim.active ? anti_aim("On") : anti_aim("Off");
  849. }
  850. window.requestAnimationFrame(handle_mouse_functions);
  851.  
  852. //anti aim
  853. function detect_corner() {
  854. deep_debug('corner detect called');
  855. let w = window.innerWidth;
  856. let h = window.innerHeight;
  857. let center = {
  858. x: w / 2,
  859. y: h / 2
  860. };
  861. let lr, ud;
  862. inputs.mouse.real.x > center.x ? lr = "r" : lr = "l";
  863. inputs.mouse.real.y > center.y ? ud = "d" : ud = "u";
  864. deep_debug('output: ', lr + ud);
  865. return lr + ud;
  866. }
  867.  
  868. function look_at_corner(corner) {
  869. deep_debug('look at corner called with corner', corner);
  870. if (!inputs.mouse.shooting) {
  871. let w = window.innerWidth;
  872. let h = window.innerHeight;
  873. deep_debug('w and h', w, h);
  874. deep_debug('inputs: ', inputs);
  875. switch (corner) {
  876. case "lu":
  877. anti_aim_at('extern', w, h);
  878. break
  879. case "ld":
  880. anti_aim_at('extern', w, 0);
  881. break
  882. case "ru":
  883. anti_aim_at('extern', 0, h);
  884. break
  885. case "rd":
  886. anti_aim_at('extern', 0, 0);
  887. break
  888. }
  889. }
  890. }
  891.  
  892. function anti_aim(toggle) {
  893. deep_debug('anti aim called with:', toggle);
  894. switch (toggle) {
  895. case "On":
  896. if (modules.Mouse.Anti_aim.active) {
  897. deep_debug('condition !modules.Mouse.Anti_aim.active met');
  898. look_at_corner(detect_corner());
  899. }
  900. break
  901. case "Off":
  902. deep_debug('inputs.mouse.isFrozen ', inputs.mouse.isFrozen);
  903. (inputs.mouse.isFrozen && !modules.Mouse.Freeze_mouse.active) ? unfreezeMouseMove(): null;
  904. break
  905. }
  906. }
  907. // Example: Freeze and unfreeze
  908. function freezeMouseMove() {
  909. if (!inputs.mouse.isFrozen) {
  910. inputs.mouse.isFrozen = true;
  911. clear_onTouch();
  912. deep_debug("Mousemove events are frozen.");
  913. }
  914. }
  915.  
  916. function unfreezeMouseMove() {
  917. if (inputs.mouse.isFrozen && !inputs.mouse.isShooting) {
  918. inputs.mouse.isFrozen = false;
  919. redefine_onTouch();
  920. deep_debug("Mousemove events are active.");
  921. }
  922. }
  923.  
  924. function click_at(input_or_extern, x, y, delay1 = 150, delay2 = 500) {
  925. apply_force(x, y);
  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. disable_force();
  934. }
  935.  
  936. function ghost_click_at(input_or_extern, x, y, delay1 = 150, delay2 = 500) {
  937. apply_force(x, y);
  938. i_e(input_or_extern, 'onTouchStart', -2, x, y);
  939. setTimeout(() => {
  940. i_e(input_or_extern, 'onTouchEnd', -2, x, y);
  941. }, delay1);
  942. setTimeout(() => {
  943. inputs.mouse.shooting = false;
  944. }, delay2);
  945. disable_force();
  946. }
  947.  
  948. function mouse_move(input_or_extern, x, y) {
  949. deep_debug('mouse move called with', x, y);
  950. apply_force(x, y);
  951. i_e(input_or_extern, 'onTouchMove', -1, x, y);
  952. disable_force();
  953. }
  954.  
  955. function anti_aim_at(input_or_extern, x, y) {
  956. deep_debug('frozen, shooting', inputs.mouse.isFrozen, inputs.mouse.isShooting);
  957. deep_debug('anti aim at called with:', x, y);
  958. if (inputs.mouse.shooting) {
  959. deep_debug('quit because inputs.mouse.shooting');
  960. return;
  961. }
  962. mouse_move(input_or_extern, x, y);
  963. }
  964. //////
  965.  
  966. //Sandbox Auto Lvl up
  967. function sandbox_lvl_up() {
  968. if (modules.Functional.Sandbox_lvl_up.active && player.connected && player.inGame && player.gamemode === "sandbox") {
  969. document.querySelector("#sandbox-max-level").click();
  970. }
  971. }
  972. setInterval(sandbox_lvl_up, 500);
  973.  
  974. //autorespawn
  975. function respawn() {
  976. deep_debug(modules);
  977. if (modules.Functional.Auto_respawn.active && player.connected && !player.inGame) {
  978. extern.try_spawn(player.name);
  979. }
  980. }
  981.  
  982. setInterval(respawn, 1000);
  983.  
  984. //AntiAfk Timeout
  985. function AntiAfkTimeout() {
  986. if (modules.Functional.Anti_timeout.active && player.connected) {
  987. extern.onTouchMove(inputs.mouse.real.x, inputs.mouse.real.y);
  988. }
  989. }
  990. setInterval(AntiAfkTimeout, 1000);
  991.  
  992. //Zoom
  993. function HandleZoom() {
  994. window.requestAnimationFrame(HandleZoom);
  995. if (!player.isConnected) return;
  996. player.dpr = 1;
  997. let factor = modules.Functional.Zoom.value / 100;
  998. extern.setScreensizeZoom(player.ui_scale, player.dpr * factor);
  999. extern.updateDPR(player.dpr);
  1000. }
  1001. window.requestAnimationFrame(HandleZoom);
  1002.  
  1003. //ctx helper functions
  1004. function ctx_text(fcolor, scolor, lineWidth, font, text, textX, textY) {
  1005. deep_debug('called crx_text with: ', fcolor, scolor, lineWidth, font, text, textX, textY);
  1006. ctx.fillStyle = fcolor;
  1007. ctx.lineWidth = lineWidth;
  1008. ctx.font = font;
  1009. ctx.strokeStyle = scolor;
  1010. ctx.strokeText(`${text}`, textX, textY)
  1011. ctx.fillText(`${text}`, textX, textY)
  1012. }
  1013.  
  1014. function ctx_rect(x, y, a, b, c) {
  1015. deep_debug('called ctx_rect with: ', x, y, a, b, c);
  1016. ctx.beginPath();
  1017. ctx.strokeStyle = c;
  1018. ctx.strokeRect(x, y, a, b);
  1019. }
  1020.  
  1021. function transparent_rect_fill(x, y, a, b, scolor, fcolor, opacity){
  1022. deep_debug('called transparent_rect_fill with: ', x, y, a, b, scolor, fcolor, opacity);
  1023. ctx.beginPath();
  1024. ctx.rect(x, y, a, b);
  1025.  
  1026. // Set stroke opacity
  1027. ctx.globalAlpha = 1;// Reset to 1 for stroke, or set as needed
  1028. ctx.strokeStyle = scolor;
  1029. ctx.stroke();
  1030.  
  1031. // Set fill opacity
  1032. ctx.globalAlpha = opacity;// Set the opacity for the fill color
  1033. ctx.fillStyle = fcolor;
  1034. ctx.fill();
  1035.  
  1036. // Reset globalAlpha back to 1 for future operations
  1037. ctx.globalAlpha = 1;
  1038. }
  1039.  
  1040. //key visualiser
  1041. let ctx_wasd = {
  1042. square_sizes: { //in windowScaling
  1043. a: 50,
  1044. b: 50
  1045. },
  1046. text_props: {
  1047. lineWidth: 3,
  1048. font: 1 + "em Ubuntu",
  1049. },
  1050. square_colors: {
  1051. stroke: "black",
  1052. unpressed: "yellow",
  1053. pressed: "orange"
  1054. },
  1055. text_colors: {
  1056. stroke: "black",
  1057. unpressed: "orange",
  1058. pressed: "red"
  1059. },
  1060. w: {
  1061. x: 300,
  1062. y: 200,
  1063. pressed: false,
  1064. text: 'W'
  1065. },
  1066. a: {
  1067. x: 350,
  1068. y: 150,
  1069. pressed: false,
  1070. text: 'A'
  1071. },
  1072. s: {
  1073. x: 300,
  1074. y: 150,
  1075. pressed: false,
  1076. text: 'S'
  1077. },
  1078. d: {
  1079. x: 250,
  1080. y: 150,
  1081. pressed: false,
  1082. text: 'D'
  1083. },
  1084. l_m: {
  1085. x: 350,
  1086. y: 75,
  1087. pressed: false,
  1088. text: 'LMC'
  1089. },
  1090. r_m: {
  1091. x: 250,
  1092. y: 75,
  1093. pressed: false,
  1094. text: 'RMC'
  1095. },
  1096. }
  1097.  
  1098. function visualise_keys(){
  1099. let keys = ['w', 'a', 's', 'd', 'l_m', 'r_m'];
  1100. let l = keys.length;
  1101. for(let i = 0; i < l; i++){
  1102. let args = {
  1103. x: canvas.width - dim_c.windowScaling_2_canvas(ctx_wasd[keys[i]].x),
  1104. y: canvas.height - dim_c.windowScaling_2_canvas(ctx_wasd[keys[i]].y),
  1105. a: dim_c.windowScaling_2_canvas(ctx_wasd.square_sizes.a),
  1106. b: dim_c.windowScaling_2_canvas(ctx_wasd.square_sizes.b),
  1107. s_c: ctx_wasd.square_colors.stroke,
  1108. f_c: ctx_wasd[keys[i]].pressed? ctx_wasd.square_colors.pressed : ctx_wasd.square_colors.unpressed,
  1109. t_s: ctx_wasd.text_colors.stroke,
  1110. t_f: ctx_wasd[keys[i]].pressed? ctx_wasd.text_colors.pressed : ctx_wasd.text_colors.unpressed,
  1111. t_lineWidth: ctx_wasd.text_props.lineWidth,
  1112. t_font: ctx_wasd.text_props.font,
  1113. text: ctx_wasd[keys[i]].text,
  1114. opacity: 0.25
  1115. }
  1116. deep_debug(args);
  1117. transparent_rect_fill(
  1118. args.x,
  1119. args.y,
  1120. args.a,
  1121. args.b,
  1122. args.s_c,
  1123. args.f_c,
  1124. args.opacity
  1125. );
  1126. ctx_text(
  1127. args.t_f,
  1128. args.t_s,
  1129. args.t_lineWidth,
  1130. args.t_font,
  1131. args.text,
  1132. args.x+(args.a/2),
  1133. args.y+(args.b/2)
  1134. );
  1135. }
  1136. }
  1137.  
  1138. document.body.addEventListener("keydown", function(e) {
  1139. deep_debug(`pressed ${e.code}`);
  1140. switch(e.code){
  1141. case "KeyW":
  1142. ctx_wasd.w.pressed = true;
  1143. break
  1144. case "KeyA":
  1145. ctx_wasd.a.pressed = true;
  1146. break
  1147. case "KeyS":
  1148. ctx_wasd.s.pressed = true;
  1149. break
  1150. case "KeyD":
  1151. ctx_wasd.d.pressed = true;
  1152. break
  1153. }
  1154. deep_debug('====DID PRESS??', ctx_wasd.w.pressed, ctx_wasd.a.pressed, ctx_wasd.s.pressed, ctx_wasd.d.pressed);
  1155. });
  1156.  
  1157. document.body.addEventListener("keyup", function(e) {
  1158. deep_debug(`unpressed ${e.code}`);
  1159. switch(e.code){
  1160. case "KeyW":
  1161. ctx_wasd.w.pressed = false;
  1162. break
  1163. case "KeyA":
  1164. ctx_wasd.a.pressed = false;
  1165. break
  1166. case "KeyS":
  1167. ctx_wasd.s.pressed = false;
  1168. break
  1169. case "KeyD":
  1170. ctx_wasd.d.pressed = false;
  1171. break
  1172. }
  1173. deep_debug('====DID UNPRESS??', ctx_wasd.w.pressed, ctx_wasd.a.pressed, ctx_wasd.s.pressed, ctx_wasd.d.pressed);
  1174. });
  1175.  
  1176. document.body.addEventListener("mousedown", function(e) {
  1177. switch(e.button){
  1178. case 0:
  1179. ctx_wasd.l_m.pressed = true;
  1180. break
  1181. case 2:
  1182. ctx_wasd.r_m.pressed = true;
  1183. break
  1184. }
  1185. });
  1186.  
  1187. document.body.addEventListener("mouseup", function(e) {
  1188. switch(e.button){
  1189. case 0:
  1190. ctx_wasd.l_m.pressed = false;
  1191. break
  1192. case 2:
  1193. ctx_wasd.r_m.pressed = false;
  1194. break
  1195. }
  1196. });
  1197.  
  1198. //canvas gui (try to keep this in the end
  1199. setTimeout(() => {
  1200. let gui = () => {
  1201. if (player.inGame) {
  1202.  
  1203. if (modules.Visual.Key_inputs_visualiser.active) {
  1204. visualise_keys();
  1205. }
  1206. }
  1207. window.requestAnimationFrame(gui); // Start animation loop
  1208. };
  1209. gui();
  1210. }, 500); // Delay before starting the rendering