Advertisement
facundop

Untitled

Aug 28th, 2019
560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.41 KB | None | 0 0
  1. // ==UserScript==
  2. // @name AgarBots2019
  3. // @namespace bots for agar
  4. // @version 2.0
  5. // @description ...
  6. // @author hubhttp
  7. // @icon64 http://imasters.org.ru/agar/agar_allys_ext_favicon.png
  8. // @icon64URL http://imasters.org.ru/agar/agar_allys_ext_favicon.png
  9. // @icon http://imasters.org.ru/agar/agar_allys_ext_favicon.png
  10. // @match https://agar.io/*
  11. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
  12. // @require http://code.jquery.com/jquery-latest.js
  13. // @require https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.5/socket.io.min.jss
  14. // @require https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js
  15. // @resource https://raw.githubusercontent.com/necolas/css3-github-buttons/master/gh-buttons.css
  16. // @resource https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css
  17. // @resource https://raw.githubusercontent.com/necolas/css3-github-buttons/master/gh-icons.png
  18. // @run-at document-start
  19. // @grant none
  20. // ==/UserScript==
  21. setTimeout(function(){
  22. var script = document.createElement("script");
  23. script.src = "https://unpkg.com/sweetalert/dist/sweetalert.min.js";
  24. document.getElementsByTagName("head")[0].appendChild(script);
  25. }, 3000);
  26.  
  27. "use strict";
  28. setTimeout(function() {
  29. function e() {
  30. var e = localStorage.getItem("cachedVanilla"),
  31. a = null;
  32. if (e) {
  33. try {
  34. a = JSON.parse(e)
  35. } catch (e) {
  36. console.assert(!1, e)
  37. }
  38. a && a.src && (window.eval(a.src), console.log("%c[VANILLA] loaded from cache...", "color: darkorange"))
  39. }
  40. }
  41. var a, t, o;
  42. a = "//imaster.space/agar.io/js/vanilla.core.js", t = function() {
  43. console.info("[VANILLA] inject success...")
  44. }, (o = document.createElement("script")).type = "text/javascript", o.charset = "utf-8", o.readyState ? o.onreadystatechange = function() {
  45. "loaded" != o.readyState && "complete" != o.readyState || (o.onreadystatechange = null, t && t())
  46. } : (document.body && document.body.setAttribute("data-vanilla-core", a), t && (o.onload = t, o.onerror = e)), o.src = a + "?_=" + ~~(Date.now() / 1e3 / 60), document.getElementsByTagName("head")[0].appendChild(o)
  47.  
  48. class Client {
  49. constructor() {
  50. this.botServerIP = 'ws://127.0.0.1:8081';
  51. this.botServerStatus = '';
  52. this.agarServer = '';
  53. this.botNick = '';
  54. this.UUID = '';
  55. this.botAmount = 500;
  56. this.moveInterval = null;
  57. this.ws = null;
  58. this.reconnect = true;
  59. this.addListener();
  60. this.connect();
  61. }
  62.  
  63. connect() {
  64. this.ws = new WebSocket(this.botServerIP);
  65. this.ws.binaryType = 'arraybuffer';
  66. this.ws.onopen = this.onopen.bind(this);
  67. this.ws.onmessage = this.onmessage.bind(this);
  68. this.ws.onclose = this.onclose.bind(this);
  69. this.ws.onerror = this.onerror.bind(this);
  70. }
  71.  
  72. onopen() {
  73. swal("Server: Online!", "xxxbots.xyz", "success");
  74. console.log('Connection to bot server open');
  75. $('#serverStatus').text('Connected');
  76. this.sendUUID();
  77. this.startMoveInterval();
  78. }
  79.  
  80. onmessage(msg) {
  81. let buf = new DataView(msg.data);
  82. let offset = 0;
  83. let opcode = buf.getUint8(offset++);
  84. if ($("#reconnectButton").prop('disabled', false)) {
  85. $("#reconnectButton").prop('disabled', true);
  86. }
  87. switch (opcode) {
  88. case 0:
  89. {
  90. let addClasses = '';
  91. let removeClasses = '';
  92. switch (buf.getUint8(offset++)) {
  93. case 0:
  94. this.botServerStatus = 'Max сonnections';
  95. this.reconnect = false;
  96. break;
  97. case 1:
  98. this.botServerStatus = 'Invalid Data';
  99. this.reconnect = false;
  100. break;
  101. case 2:
  102. this.botServerStatus = 'IP limit';
  103. this.reconnect = false;
  104. break;
  105. case 3:
  106. this.botServerStatus = 'Auth';
  107. break;
  108. case 4:
  109. this.botServerStatus = 'Ready';
  110. $('#toggleButton').replaceWith(`<button id='toggleButton' onclick='window.client.startBots();' class='btn btn-success'>Start Bots</button>`);
  111. $("#botCounter").html("0/0");
  112. // swal("Bots Stopped!", "Time : Paused!", "success");
  113. window.bots = [];
  114. break;
  115. case 5:
  116. this.botServerStatus = 'UUID not auth';
  117. this.reconnect = false;
  118. break;
  119. case 6:
  120. this.botServerStatus = 'Getting proxies';
  121. break;
  122. case 7:
  123. this.botServerStatus = 'Bots started!';
  124. break;
  125. case 8:
  126. this.botServerStatus = 'Auth error!';
  127. swal("Auth Error!", "Your Time Expired!", "error");
  128. this.reconnect = false;
  129. break;
  130. case 9:
  131. this.botServerStatus = 'Invalid server';
  132. swal("Invalid Server!", "Invalid Party Server!", "error");
  133. break;
  134. case 10:
  135. this.botServerStatus = 'Not Party Server';
  136. swal("Bots Can't Start!", "Invalid Party Server", "error");
  137. $('#toggleButton').replaceWith(`<button id='toggleButton' onclick='window.client.startBots();' class='btn btn-success'>Start Bots</button>`);
  138. break;
  139. case 11:
  140. this.botServerStatus = 'Coins are over!';
  141. this.reconnect = false;
  142. break;
  143. case 12:
  144. this.botServerStatus = 'Server in maintenance...';
  145. this.reconnect = false;
  146. break;
  147. case 13:
  148. this.totalUsers = buf.getUint8(offset++, true);
  149. $("#userStatus").css("display", "block");
  150. $("#usersCounter").text(this.totalUsers);
  151. break;
  152. }
  153. $("#serverStatus").text(this.botServerStatus);
  154. }
  155. break;
  156. case 1:
  157. {
  158. let spawnedBots = buf.getUint16(offset, true);
  159. offset += 2;
  160. let connectedBots = buf.getUint16(offset, true);
  161. offset += 2;
  162. let maxBots = buf.getUint16(offset, true);
  163. offset += 2;
  164. let coins = buf.getFloat64(offset, true);
  165. offset += 2;
  166. if (connectedBots >= maxBots) {
  167. $("#botCounter").html(maxBots + "/" + maxBots);
  168. }
  169. else {
  170. $("#botCounter").html(connectedBots + "/" + maxBots);
  171. }
  172. $('#coinsCounter').html(`${coins}`);
  173. }
  174. break;
  175. case 2:
  176. {
  177. window.bots = [];
  178. let numBots = buf.getUint16(offset, true);
  179. offset += 2;
  180. for (let i = 0; i < numBots; i++) {
  181. let xPos = buf.getInt32(offset, true);
  182. offset += 4;
  183. let yPos = buf.getInt32(offset, true);
  184. offset += 4;
  185. window.bots.push({
  186. "xPos": xPos,
  187. "yPos": yPos
  188. });
  189. }
  190. }
  191. break;
  192. }
  193. }
  194.  
  195. onclose() {
  196. console.log('Connection to bot server closed.');
  197. $("#reconnectButton").prop('disabled', false);
  198. if (this.reconnect) setTimeout(this.connect.bind(this), 150);
  199. if (this.moveInterval) clearInterval(this.moveInterval);
  200. if (!this.reconnect) return;
  201. swal("Server: Offline!", "Maybe in Maintenance!", "error");
  202. $('#serverStatus').text('Connecting...');
  203. }
  204.  
  205. onerror() {}
  206.  
  207. sendUUID() {
  208. let buf = this.createBuffer(2 + this.UUID.length);
  209. buf.setUint8(0, 0);
  210. for (let i = 0; i < this.UUID.length; i++) buf.setUint8(1 + i, this.UUID.charCodeAt(i));
  211. this.send(buf);
  212. }
  213.  
  214. startMoveInterval() {
  215. this.moveInterval = setInterval(() => {
  216. let pos = window.getMousePos();
  217. this.sendPos(pos.x, pos.y);
  218. }, 30);
  219. }
  220.  
  221. startBots() {
  222. let buf = this.createBuffer(6 + window.vanilla.server.addr.length + 2 * this.botNick.length);
  223. let offset = 0;
  224. buf.setUint8(offset++, 2);
  225. for (let i = 0; i < window.vanilla.server.addr.length; i++) buf.setUint8(offset++, window.vanilla.server.addr.charCodeAt(i));
  226. buf.setUint8(offset++, 0);
  227. for (let i = 0; i < this.botNick.length; i++) {
  228. buf.setUint16(offset, this.botNick.charCodeAt(i), true);
  229. offset += 2;
  230. }
  231. buf.setUint16(offset, 0, true);
  232. offset += 2;
  233. buf.setUint16(offset, this.botAmount, true);
  234. this.send(buf);
  235. swal("Bots Started!", "xxxbots.xyz", "success");
  236. $('#toggleButton').replaceWith(`<button id='toggleButton' onclick='window.client.stopBots();' class='btn btn-danger'>Stop Bots</button>`);
  237. }
  238.  
  239. sendPos(xPos, yPos) {
  240. let buf = this.createBuffer(9);
  241. buf.setUint8(0, 4);
  242. buf.setInt32(1, xPos, true);
  243. buf.setInt32(5, yPos, true);
  244. this.send(buf);
  245. }
  246.  
  247. split() {
  248. this.send(new Uint8Array([5]));
  249. }
  250.  
  251. eject() {
  252. this.send(new Uint8Array([6]));
  253. }
  254.  
  255. addListener() {
  256. document.addEventListener('mousemove', event => {
  257. this.clientX = event.clientX;
  258. this.clientY = event.clientY;
  259. });
  260. }
  261.  
  262. sendNickUpdate() {
  263. let buf = this.createBuffer(3 + 2 * this.botNick.length);
  264. let offset = 0;
  265. buf.setUint8(offset++, 7);
  266. for (let i = 0; i < this.botNick.length; i++) {
  267. buf.setUint16(offset, this.botNick.charCodeAt(i), true);
  268. offset += 2;
  269. }
  270. this.send(buf);
  271. }
  272.  
  273. stopBots() {
  274. this.send(new Uint8Array([3]));
  275. swal("Bots Stopped!", "Time : Paused!", "success");
  276. }
  277.  
  278. send(data) {
  279. if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
  280. this.ws.send(data, {
  281. binary: true
  282. });
  283. }
  284.  
  285. createUUID() {
  286. const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  287. let token = '';
  288. for (let i = 0; i < 3; i++) {
  289. for (let a = 0; a < 7; a++) token += possible.charAt(Math.floor(Math.random() * possible.length));
  290. token += '-';
  291. }
  292. token = token.substring(0, token.length - 1);
  293. localStorage.setItem('agarUnlimited2UUID', token);
  294. return token;
  295. }
  296.  
  297. createBuffer(len) {
  298. return new DataView(new ArrayBuffer(len));
  299. }
  300. sUUID(a) {
  301. if (a) {
  302. $("#UUID").text(localStorage.getItem('agarUnlimited2UUID'));
  303. }
  304. else if (!a) {
  305. $("#UUID").text("hover for show");
  306. }
  307. }
  308. }
  309.  
  310. class GUITweaker {
  311. constructor() {
  312. this.removeElements();
  313. this.addGUI();
  314. this.finishInit();
  315. let check = setInterval(() => {
  316. if (document.readyState == "complete") {
  317. clearInterval(check);
  318. setTimeout(() => {
  319. this.addBotGUI();
  320. window.client.botMode = localStorage.getItem('botMode');
  321. let UUID = localStorage.getItem('agarUnlimited2UUID');
  322. $('#agarUnlimitedToken').val(UUID);
  323. }, 1500);
  324. }
  325. }, 100);
  326. }
  327.  
  328. addBotGUI() {
  329. const botAmount = localStorage.getItem('botAmount') || 500;
  330. const botMode = localStorage.getItem('botMode');
  331. $('head').append(`<style type="text/css">.agario-panel,#mainui-grid{border-top: 5px solid #09f4ff; background-image: url("http://cdn.ogario.ovh/static/img/pattern.png"); background-repeat: repeat; background-position: top center;}</style>`);
  332. $('head').append(`<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">`);
  333. setTimeout(function() {
  334. $('.agario-promo-container').replaceWith(`<div class="agario-panel" style="position:absolute;margin-top: 4px; width: 330px; height: 500; background-color: #fff;";><center><h3>xxxbots.xyz</h3></center>
  335. <span> </span><button id="toggleButton" onclick="window.client.startBots();" class="btn btn-success">Start Bots</button>
  336. <button class="btn btn-success" onclick="UUIDChecker()">|-Your UUID-|</button>
  337. <button onclick="if(!window.client.reconnect&&window.client.ws.readyState!==1){window.client.reconnect=true;window.client.connect();}else{}" class="btn btn-success" style="float:right;">Reconnect</button></div></div>
  338. <span> </span>
  339.  
  340. <script>
  341. function UUIDChecker() {
  342. swal("Your UUID: ${window.client.UUID}", {
  343. icon: "success",
  344. title: "UUID Checked!",
  345. buttons: {
  346. cancel: "Close",
  347. catch: {
  348. text: "Copy",
  349. value: "catch",
  350. },
  351. },
  352. })
  353. .then((value) => {
  354. switch (value) {
  355.  
  356. case "catch":
  357. navigator.clipboard.writeText(window.client.UUID);
  358. swal("UUID Copied!", {
  359. icon: "success",
  360. });
  361. break;
  362.  
  363. case "Close":
  364. swal.close();
  365. break;
  366.  
  367.  
  368. }
  369. });
  370. }
  371.  
  372. </script></div>
  373. <div>`);
  374. }, 5000);
  375. }
  376.  
  377. removeElements() {
  378. $('#advertisement').remove();
  379. $('#bannerCarousel').remove();
  380. $('#user-id-tag').remove();
  381. $('#Potion_Regular_RareCanvas').remove();
  382. }
  383.  
  384. addGUI() {
  385. $("body").append(`<div style="position:fixed; margin-top: 140px; min-width: 200px; z-index:9999; min-height: 100px; max-width: 900px; max-height: 200px"><div id="botSector" style="min-width: 25px;color:#fff; min-height: 25px;background: #333;max-width: 200px; max-height: 200px; border-radius: 10px"><div id="botText" style="margin-left: 10px;color:#fff0; width: 49px; height: 53; background: url('https://i.imgur.com/WZdqjIs.png') no-repeat;background-position-y: 1px;background-size: 45%">_<span style="color: #fff; margin-left: 15px; ">Minions:</span><span style="color: #fff; margin-left: 5px;"id="botCounter">0/0</span></div>
  386. </div><div id="botSector" style="min-width: 25px;color:#fff; min-height: 25px;background: #333;max-width: 200px; max-height: 200px; border-radius: 10px; margin-top: 5px"><div id="botText" style="margin-left: 10px;color:#fff0; width: 49px; height: 53; background: url('https://i.imgur.com/bIUuG5a.png') no-repeat;background-position-y: 1px;background-size: 45%">_<span style="color: #fff; margin-left: 15px; ">Coins:</span><span style="color: #fff; margin-left: 5px;"id="coinsCounter">0</span></div>
  387. </div><div id="botSector" style="min-width: 25px;color:#fff; min-height: 25px;background: #333;max-width: 200px; max-height: 200px; border-radius: 10px; margin-top: 5px"><div id="botText" style="margin-left: 10px;color:#fff0; width: 100%; background: url('https://i.imgur.com/F8B58GB.png') no-repeat;background-position-y: 1px;background-size: 11%">_<span style="color: #fff; margin-left: 15px; ">Status:</span><span style="color: #fff; margin-left: 5px;"id="serverStatus">Waiting</span></div></div></div></div>`);
  388. }
  389.  
  390. finishInit() {
  391. window.client.botMode = localStorage.getItem('botMode');
  392. window.client.botAmount = localStorage.getItem('botAmount') >>> 0;
  393. window.client.botNick = localStorage.getItem('botNick');
  394. let UUID = localStorage.getItem('agarUnlimited2UUID');
  395. $('#agarUnlimitedToken').val(UUID);
  396. }
  397. }
  398.  
  399. class Macro {
  400. constructor() {
  401. this.ejectDown = false;
  402. this.stopped = false;
  403. this.speed = 15;
  404. this.addKeyHooks();
  405. }
  406.  
  407. addKeyHooks() {
  408. this.onkeydown();
  409. }
  410. onkeydown() {
  411. document.addEventListener('keydown', function(event) {
  412. console.log(event.keyCode, event.which);
  413. switch (event.keyCode || event.which) {
  414. case 87:
  415. window.core.eject();
  416. break;
  417. case 88:
  418. client.split();
  419. break;
  420. case 67:
  421. client.eject();
  422. break;
  423. }
  424. }.bind(this));
  425. }
  426. eject() {
  427. if (this.ejectDown) {
  428. window.core.eject();
  429. setTimeout(this.eject.bind(this), this.speed);
  430. }
  431. }
  432. }
  433. setTimeout(function() {
  434. window.mouseX = 0;
  435. window.mouseY = 0;
  436. document.addEventListener('mousemove', evt => {
  437. window.mouseX = evt.clientX - window.innerWidth / 2;
  438. window.mouseY = evt.clientY - window.innerHeight / 2;
  439. });
  440.  
  441. window.getMousePos = function() {
  442. let x = window.vanilla.player.x - (window.vanilla.map.x1 + window.vanilla.map.width / 2),
  443. y = window.vanilla.player.y - (window.vanilla.map.y1 + window.vanilla.map.height / 2);
  444. return {
  445. x: x + window.mouseX / window.vanilla.settings.scale,
  446. y: y + window.mouseY / window.vanilla.settings.scale
  447. };
  448. }
  449. window.client = new Client();
  450. new Macro();
  451.  
  452. if (!localStorage.getItem('agarUnlimited2UUID')) localStorage.setItem('agarUnlimited2UUID', window.client.createUUID());
  453. if (!localStorage.getItem('botMode')) localStorage.setItem('botMode', 'FEEDER');
  454. if (!localStorage.getItem('botNick')) localStorage.setItem('botNick', '');
  455. if (!localStorage.getItem('botAmount')) localStorage.setItem('botAmount', 500);
  456. if (!localStorage.getItem('extraZoom')) localStorage.setItem('extraZoom', true);
  457. window.client.UUID = localStorage.getItem('agarUnlimited2UUID');
  458.  
  459. new GUITweaker();
  460. }, 12000);
  461. }, 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement