Size
4.0 KB
Version
1.1
Created
Jan 10, 2026
Updated
25 days ago
1// ==UserScript==
2// @name Diep.io Auto-leveler Bot (Improved)
3// @namespace http://tampermonkey.net/
4// @version 1.1
5// @description Improved auto-leveler bot for Diep.io. Press Q to toggle.
6// @author Mi300 (Improved by AI)
7// @match https://diep.io/*
8// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
9// @license Apache License 2.0
10// @grant none
11// @run-at document-start
12// @downloadURL https://update.greasyfork.org/scripts/528154/Diepio%20Auto-leveler%20Bot%20%28Improved%29.user.js
13// @updateURL https://update.greasyfork.org/scripts/528154/Diepio%20Auto-leveler%20Bot%20%28Improved%29.meta.js
14// ==/UserScript==
15
16const ARENA_WIDTH = 26000;
17const ARENA_HEIGHT = 26000;
18const T4_BASE_WIDTH = 3900;
19const T4_BASE_HEIGHT = 3900;
20
21const T2_BASES = [
22 { id: 0, name: "blue", hex: "#00b2e1", x: 0, y: 0, cX: 0, cY: 0, dirX: 1, dirY: 1 },
23 { id: 3, name: "red", hex: "#f14e54", x: 23500, y: 0, cX: ARENA_WIDTH, cY: ARENA_HEIGHT, dirX: -1, dirY: 1 },
24];
25
26const T4_BASES = [
27 { id: 0, name: "blue", hex: "#00b2e1", x: 0, y: 0, cX: 0, cY: 0, dirX: 1, dirY: 1 },
28 { id: 1, name: "purple", hex: "#bf7ff5", x: 22100, y: 0, cX: 0, cY: ARENA_HEIGHT, dirX: -1, dirY: 1 },
29 { id: 2, name: "green", hex: "#00e16e", x: 0, y: 22100, cX: ARENA_WIDTH, cY: 0, dirX: 1, dirY: -1 },
30 { id: 3, name: "red", hex: "#f14e54", x: 22100, y: 22100, cX: ARENA_WIDTH, cY: ARENA_HEIGHT, dirX: -1, dirY: -1 },
31];
32
33alert("Auto Leveler: Press Q to toggle on / off.");
34
35let OMG = setInterval(function () {
36 if (!window.input) return;
37 clearInterval(OMG);
38
39 const canvas = document.getElementById("canvas");
40 const ctx = canvas.getContext("2d");
41 let baseArea = null;
42 let inBase = false;
43 let toggled = false;
44 let is2T = false;
45 let lastCheck = Date.now();
46 let minimapArrow = [0, 0];
47 let minimapPos = [0, 0];
48 let minimapDim = [0, 0];
49 let playerPos = [0, 0];
50
51 document.addEventListener("keydown", function (e) {
52 if (e.key === "q") {
53 toggled = !toggled;
54 setTimeout(() => {
55 input.key_up(87); // W
56 input.key_up(83); // S
57 input.key_up(65); // A
58 input.key_up(68); // D
59 }, 200);
60 }
61 });
62
63 function getCentre(vertices) {
64 return vertices.reduce((acc, vertex) => [acc[0] + vertex[0], acc[1] + vertex[1]], [0, 0])
65 .map(sum => sum / vertices.length);
66 }
67
68 function getDist(t1, t2) {
69 const distX = t1[0] - t2[0];
70 const distY = t1[1] - t2[1];
71 return [Math.hypot(distX, distY), distX, distY];
72 }
73
74 function getClosest(entities) {
75 return entities.reduce((acc, entity) => {
76 const dist = getDist(entity[0], [canvas.width / 2, canvas.height / 2])[0];
77 return dist < getDist(acc[0], [canvas.width / 2, canvas.height / 2])[0] ? entity : acc;
78 }, [[0, 0], Infinity]);
79 }
80
81 function move(aimTarget, moveTarget) {
82 if (!window.input || !window.input.should_prevent_unload()) return;
83
84 input.mouse(...aimTarget);
85 input.key_down(1); // Shoot
86
87 const moveTargetDistance = getDist(moveTarget, [canvas.width / 2, canvas.height / 2]);
88
89 // Horizontal movement
90 if (moveTargetDistance[1] > 0) {
91 input.key_down(68); // D
92 input.key_up(65); // A
93 } else if (moveTargetDistance[1] < 0) {
94 input.key_up(68); // D
95 input.key_down(65); // A
96 } else {
97 input.key_up(68); // D
98 input.key_up(65); // A
99 }
100
101 // Vertical movement
102 if (moveTargetDistance[2] > 0) {
103 input.key_down(83); // S
104 input.key_up(87); // W
105 } else if (moveTargetDistance[2] < 0) {
106 input.key_up(83); // S
107 input.key_down(87); // W
108 } else {
109 input.key_up(83); // S
110 input.key_up(87); // W
111 }
112 }
113
114 function main() {
115 if (!toggled) return;
116 window.requestAnimationFrame(main);
117
118 playerPos = getPlayerPos();
119 getBase(playerPos);
120
121 if (Date.now() - lastCheck > 2000) is2T = true;
122 else is2T = false;
123
124 if (!input.should_prevent_unload()) {
125 window.input.try_spawn(localStorage.name);
126 }
127
128 getCurrentTargets();
129 }
130
131 window.requestAnimationFrame(main);
132}, 400);