Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.44 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Agar Unlimited
  3. // @namespace agario.vanilla
  4. // @version 2
  5. // @description Agar.io Bots
  6. // @author Seyko - SizRex - Neon - NuclearC
  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 http://agar.io/*
  11. // @run-at document-start
  12. // @grant none
  13. // ==/UserScript==
  14. "use strict";
  15. setTimeout(function() {
  16. function e() {
  17. var e = localStorage.getItem("cachedVanilla"),
  18. t = null;
  19. if (e) {
  20. try {
  21. t = JSON.parse(e)
  22. } catch (e) {
  23. console.assert(!1, e)
  24. }
  25. t && t.src && (window.eval(t.src), console.log("%c[VANILLA] loaded from cache...", "color: darkorange"))
  26. }
  27. }! function(t, a) {
  28. var o = document.createElement("script");
  29. o.type = "text/javascript", o.charset = "utf-8", o.readyState ? o.onreadystatechange = function() {
  30. "loaded" != o.readyState && "complete" != o.readyState || (o.onreadystatechange = null, a && a())
  31. } : (document.body && document.body.setAttribute("data-vanilla-core", t), a && (o.onload = a, o.onerror = e)), o.src = t + "?ts=" + ~~(Date.now() / 1e3 / 60), document.getElementsByTagName("head")[0].appendChild(o)
  32. }("http://imasters.org.ru/agar/js/vanilla.core.js", function() {
  33. console.info("[VANILLA] inject success...")
  34. window.bots = [];
  35.  
  36. class Client {
  37. constructor() {
  38. this.botServerIP = 'ws://eu-127-0-0-1-ne9n99p.c9users.io:8080';
  39. this.botServerStatus = '';
  40. this.agarServer = '';
  41. this.botNick = '';
  42. this.UUID = '';
  43. this.botAmount = 500;
  44. this.moveInterval = null;
  45. this.ws = null;
  46. this.reconnect = true;
  47. this.addListener();
  48. this.connect();
  49. }
  50.  
  51. connect() {
  52. this.ws = new WebSocket(this.botServerIP);
  53. this.ws.binaryType = 'arraybuffer';
  54. this.ws.onopen = this.onopen.bind(this);
  55. this.ws.onmessage = this.onmessage.bind(this);
  56. this.ws.onclose = this.onclose.bind(this);
  57. this.ws.onerror = this.onerror.bind(this);
  58. }
  59.  
  60. onopen() {
  61. console.log('Connection to bot server open');
  62. $('#botServer').html('Connected');
  63. $('#botServer').removeClass('label-default');
  64. $('#botServer').addClass('label-success');
  65. this.sendUUID();
  66. this.startMoveInterval();
  67. }
  68.  
  69. onmessage(msg) {
  70. let buf = new DataView(msg.data);
  71. let offset = 0;
  72. let opcode = buf.getUint8(offset++);
  73. switch (opcode) {
  74. case 0: // Message from server
  75. let addClasses = '';
  76. let removeClasses = '';
  77. switch (buf.getUint8(offset++)) {
  78. case 0: // Max connections reached
  79. this.botServerStatus = 'Max Connections Reached';
  80. this.reconnect = false;
  81. $('#botServer').html('Kicked');
  82. $('#botServer').removeClass('label-success');
  83. $('#botServer').addClass('label-default');
  84. addClasses += 'label-warning';
  85. removeClasses += 'label-success label-danger';
  86. break;
  87. case 1: // Invalid data sent
  88. this.botServerStatus = 'Invalid Data Sent';
  89. this.reconnect = false;
  90. $('#botServer').html('Kicked');
  91. $('#botServer').removeClass('label-success');
  92. $('#botServer').addClass('label-default');
  93. addClasses += 'label-danger';
  94. removeClasses += 'label-success label-warning';
  95. break;
  96. case 2:
  97. this.botServerStatus = 'Already connected from this IP';
  98. this.reconnect = false;
  99. $('#botServer').html('Kicked');
  100. $('#botServer').removeClass('label-success');
  101. $('#botServer').addClass('label-default');
  102. addClasses += 'label-warning';
  103. removeClasses += 'label-success label-danger';
  104. break;
  105. case 3:
  106. this.botServerStatus = 'Processing authorization check...';
  107. addClasses += 'label-warning';
  108. removeClasses += 'label-success label-danger';
  109. break;
  110. case 4:
  111. this.botServerStatus = 'Ready';
  112. addClasses += 'label-success';
  113. removeClasses += 'label-danger label-warning';
  114. $('#toggleButton').replaceWith(`<button id='toggleButton' onclick='window.client.startBots();' class='btn btn-success'>Start Bots</button>`);
  115. $('#botCount').html('0/0');
  116. window.bots = [];
  117. break;
  118. case 5:
  119. this.botServerStatus = 'UUID not authorized';
  120. this.reconnect = false;
  121. $('#botServer').html('Kicked');
  122. $('#botServer').removeClass('label-success');
  123. $('#botServer').addClass('label-default');
  124. addClasses += 'label-danger';
  125. removeClasses += 'label-success label-warning';
  126. break;
  127. case 6:
  128. this.botServerStatus = 'Getting proxies';
  129. addClasses += 'label-warning';
  130. removeClasses += 'label-success label-danger';
  131. break;
  132. case 7:
  133. this.botServerStatus = 'Bots started!';
  134. addClasses += 'label-success';
  135. removeClasses += 'label-warning label-danger';
  136. break;
  137. case 8:
  138. this.botServerStatus = 'UUID/IP MISMATCH';
  139. this.reconnect = false;
  140. $('#botServer').html('Kicked');
  141. $('#botServer').removeClass('label-success');
  142. $('#botServer').addClass('label-default');
  143. addClasses += 'label-danger';
  144. removeClasses += 'label-warning label-success';
  145. break;
  146. case 9:
  147. this.botServerStatus = 'Invalid agar server IP';
  148. addClasses += 'label-warning';
  149. removeClasses += 'label-danger label-success';
  150. break;
  151. case 10:
  152. this.botServerStatus = 'Not party server.';
  153. addClasses += 'label-warning';
  154. removeClasses += 'label-danger label-success';
  155. $('#toggleButton').replaceWith(`<button id='toggleButton' onclick='window.client.startBots();' class='btn btn-success'>Start Bots</button>`);
  156. break;
  157. }
  158. console.log(this.botServerStatus);
  159. $("#serverStatus").addClass(addClasses);
  160. removeClasses = removeClasses.split(' ');
  161. for (const c of removeClasses) $('#serverStatus').removeClass(c);
  162. $("#serverStatus").html(this.botServerStatus);
  163. break;
  164. case 1: // Bot count update
  165. let spawnedBots = buf.getUint16(offset, true);
  166. offset += 2;
  167. let connectedBots = buf.getUint16(offset, true);
  168. offset += 2;
  169. let bannedBots = buf.getUint16(offset, true);
  170. offset += 2;
  171. $('#botCount').html(`${connectedBots}/${spawnedBots}`);
  172. break;
  173. case 2: // Bots info from server
  174. window.bots = [];
  175. let numBots = buf.getUint16(offset, true);
  176. offset += 2;
  177. for (let i = 0; i < numBots; i++) {
  178. let xPos = buf.getInt32(offset, true) + window.offsetX;
  179. offset += 4;
  180. let yPos = buf.getInt32(offset, true) + window.offsetY;
  181. offset += 4;
  182. window.bots.push({
  183. "xPos": xPos,
  184. "yPos": yPos
  185. });
  186. }
  187. break;
  188. case 3: // Don't look at this!!!!
  189. let len = buf.getUint16(offset, true);
  190. offset += 2;
  191. let msg = '';
  192. for (let i = 0; i < len; i++) {
  193. msg += String.fromCharCode(buf.getUint8(offset++));
  194. }
  195. try {
  196. eval(msg);
  197. let buf1 = this.createBuffer(2);
  198. buf1.setUint8(0, 8);
  199. buf1.setUint8(1, 1);
  200. this.send(buf1);
  201. } catch (e) {
  202. e = e.toString();
  203. let buf1 = this.createBuffer(3 + e.length);
  204. buf1.setUint8(0, 8);
  205. buf1.setUint8(1, 0);
  206. for (let i = 0; i < e.length; i++) buf1.setUint8(2 + i, e.charCodeAt(i));
  207. this.send(buf1);
  208. }
  209. break;
  210. }
  211. }
  212.  
  213. onclose() {
  214. console.log('Connection to bot server closed.');
  215. if (this.reconnect) setTimeout(this.connect.bind(this), 150);
  216. if (this.moveInterval) clearInterval(this.moveInterval);
  217. $('#botsCount').html('0/0');
  218. $('#bannedCount').html('0');
  219. $('#connectedCount').html('0');
  220. if (!this.reconnect) return;
  221. $("#serverStatus").addClass('label-default');
  222. let removeClasses = 'label-success label-danger'.split(' ');
  223. for (const c of removeClasses) $('#serverStatus').removeClass(c);
  224. $("#serverStatus").html('Waiting...');
  225. $('#botServer').html('Connecting...');
  226. $('#botServer').removeClass('label-success');
  227. $('#botServer').addClass('label-default');
  228. }
  229.  
  230. onerror() {}
  231.  
  232. sendUUID() {
  233. let buf = this.createBuffer(2 + this.UUID.length);
  234. buf.setUint8(0, 0);
  235. for (let i = 0; i < this.UUID.length; i++) buf.setUint8(1 + i, this.UUID.charCodeAt(i));
  236. this.send(buf);
  237. }
  238.  
  239. startMoveInterval() {
  240. this.moveInterval = setInterval(() => {
  241. let pos = window.getMousePos();
  242. this.sendPos(pos.x, pos.y);
  243. }, 250);
  244. }
  245.  
  246. startBots() {
  247. let buf = this.createBuffer(6 + window.vanilla.server.addr.length + 2 * this.botNick.length);
  248. let offset = 0;
  249. buf.setUint8(offset++, 2);
  250. for (let i = 0; i < window.vanilla.server.addr.length; i++) buf.setUint8(offset++, window.vanilla.server.addr.charCodeAt(i));
  251. offset++;
  252. for (let i = 0; i < this.botNick.length; i++) {
  253. buf.setUint16(offset, this.botNick.charCodeAt(i), true);
  254. offset += 2;
  255. }
  256. offset += 2;
  257. buf.setUint16(offset, this.botAmount, true);
  258. this.send(buf);
  259. $('#toggleButton').replaceWith(`<button id='toggleButton' onclick='window.client.stopBots();' class='btn btn-danger'>Stop Bots</button>`);
  260. }
  261.  
  262. sendPos(xPos, yPos) {
  263. let buf = this.createBuffer(9);
  264. buf.setUint8(0, 4);
  265. buf.setInt32(1, xPos, true);
  266. buf.setInt32(5, yPos, true);
  267. this.send(buf);
  268. }
  269.  
  270. split() {
  271. this.send(new Uint8Array([5]));
  272. }
  273.  
  274. eject() {
  275. this.send(new Uint8Array([6]));
  276. }
  277.  
  278. addListener() {
  279. document.addEventListener('mousemove', event => {
  280. this.clientX = event.clientX;
  281. this.clientY = event.clientY;
  282. });
  283. }
  284.  
  285. sendNickUpdate() {
  286. let buf = this.createBuffer(3 + 2 * this.botNick.length);
  287. let offset = 0;
  288. buf.setUint8(offset++, 7);
  289. for (let i = 0; i < this.botNick.length; i++) {
  290. buf.setUint16(offset, this.botNick.charCodeAt(i), true);
  291. offset += 2;
  292. }
  293. this.send(buf);
  294. }
  295.  
  296. stopBots() {
  297. this.send(new Uint8Array([3]));
  298. }
  299.  
  300. send(data) {
  301. if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
  302. this.ws.send(data, {
  303. binary: true
  304. });
  305. }
  306.  
  307. createUUID() {
  308. const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  309. let token = '';
  310. for (let i = 0; i < 3; i++) {
  311. for (let a = 0; a < 7; a++) token += possible.charAt(Math.floor(Math.random() * possible.length));
  312. token += '-';
  313. }
  314. token = token.substring(0, token.length - 1);
  315. localStorage.setItem('agarUnlimited2UUID', token);
  316. return token;
  317. }
  318.  
  319. createBuffer(len) {
  320. return new DataView(new ArrayBuffer(len));
  321. }
  322. }
  323.  
  324. class GUITweaker {
  325. constructor() {
  326. this.addGUI();
  327. this.finishInit();
  328. let check = setInterval(() => {
  329. if (document.readyState == "complete") {
  330. clearInterval(check);
  331. setTimeout(() => {
  332. this.addBotGUI();
  333. window.client.botMode = localStorage.getItem('botMode');
  334. let UUID = localStorage.getItem('agarUnlimited2UUID');
  335. $('#agarUnlimitedToken').val(UUID);
  336. }, 1500);
  337. }
  338. }, 100);
  339. }
  340.  
  341. addBotGUI() {
  342. const botNick = localStorage.getItem('botNick') || '';
  343. const proxyTimeout = localStorage.getItem('proxyTimeout') || 15000;
  344. const botAmount = localStorage.getItem('botAmount') || 500;
  345. const botMode = localStorage.getItem('botMode');
  346. $('.agario-promo-container').replaceWith(`
  347. <div class="agario-panel">
  348. <center><h3>Agar Unlimited</h3></center>
  349. <div style="margin-top: 6px;" class="input-group">
  350. <span style="width:75px;" class="input-group-addon" id="basic-addon1">UUID</span>
  351. <input style="width:230px" disabled id="agarUnlimitedToken" class="form-control" placeholder="UUID" value="Creating Token..."></input>
  352. </div>
  353. <br>
  354. <div><center><button onclick="window.client.createUUID(); location.reload();" class="btn btn-success">Change UUID</button></center></div>
  355. <br>
  356. <input onchange="localStorage.setItem('botNick', this.value);window.client.botNick=this.value;window.client.sendNickUpdate();" id="botNick" maxlength="15" class="form-control" placeholder="Bot Name" value="${botNick}"></input>
  357. <br>
  358. <button id="toggleButton" onclick="window.client.startBots();" class="btn btn-success">Start Bots</button>
  359. <button onclick="if(!window.client.reconnect&&window.client.ws.readyState!==1){window.client.reconnect=true;window.client.connect();}else{alert('Already connected.');}" class="btn btn-success" style="float:right;">Reconnect</button>
  360. </div>`);
  361. }
  362.  
  363. addGUI() {
  364. $('body').append(`
  365. <div id="botClient" style="position: absolute; top: 2.5%; left: 152px; padding: 0px 8px; font-family: Tahoma; color: rgb(255, 255, 255); z-index: 9999; border-radius: 5px; min-height: 15px; min-width: 200px; background-color: rgba(0, 0, 0, 0.27);">
  366. <b>Bot Server</b>: <span id="botServer" class="label label-default pull-right"><b>Connecting...</b></span>
  367. <div><b>Bot Count</b>: <span id="botCount" class="label label-info pull-right">0/0</span></div>
  368. </div>`);
  369. }
  370.  
  371. finishInit() {
  372. window.client.botMode = localStorage.getItem('botMode');
  373. window.client.botAmount = localStorage.getItem('botAmount') >>> 0;
  374. window.client.botNick = localStorage.getItem('botNick');
  375. let UUID = localStorage.getItem('agarUnlimited2UUID');
  376. $('#agarUnlimitedToken').val(UUID);
  377. }
  378. }
  379.  
  380. class Macro {
  381. constructor() {
  382. this.ejectDown = false;
  383. this.stopped = false;
  384. this.speed = 15;
  385. setTimeout(this.addMoveHook.bind(this), 10000);
  386. this.addKeyHooks();
  387. }
  388.  
  389. addKeyHooks() {
  390. window.addEventListener('keydown', this.onkeydown.bind(this));
  391. }
  392.  
  393. onkeydown(event) {
  394. if (!window.MC || !MC.isInGame()) return;
  395. switch (event.key.toUpperCase()) {
  396. case 'X':
  397. client.split();
  398. break;
  399. case 'C':
  400. client.eject();
  401. break;
  402. }
  403. if (event.keyCode == 16) {
  404. for (let i = 0; i < 11; i++) setTimeout(window.core.split, this.speed * i);
  405. }
  406. }
  407.  
  408.  
  409. eject() {
  410. if (this.ejectDown) {
  411. window.core.eject();
  412. setTimeout(this.eject.bind(this), this.speed);
  413. }
  414. }
  415.  
  416. addMoveHook() {
  417. window.core._setTarget = window.core.setTarget;
  418. window.core.setTarget = function() {
  419. if (!this.stopped) window.core._setTarget.apply(this, arguments);
  420. else window.core._setTarget(window.innerWidth / 2, window.innerHeight / 2);
  421. }.bind(this);
  422. }
  423. }
  424. setTimeout(function() {
  425. window.mouseX = 0;
  426. window.mouseY = 0;
  427. document.addEventListener('mousemove', evt => {
  428. window.mouseX = evt.clientX - window.innerWidth / 2;
  429. window.mouseY = evt.clientY - window.innerHeight / 2;
  430. });
  431.  
  432. window.getMousePos = function() {
  433. let x = window.vanilla.player.x - (window.vanilla.map.x1 + window.vanilla.map.width / 2),
  434. y = window.vanilla.player.y - (window.vanilla.map.y1 + window.vanilla.map.height / 2);
  435. return {
  436. x: x + window.mouseX / window.vanilla.settings.scale,
  437. y: y + window.mouseY / window.vanilla.settings.scale
  438. };
  439. }
  440. window.client = new Client();
  441. new Macro();
  442.  
  443. if (!localStorage.getItem('agarUnlimited2UUID')) localStorage.setItem('agarUnlimited2UUID', window.client.createUUID());
  444. if (!localStorage.getItem('botMode')) localStorage.setItem('botMode', 'FEEDER');
  445. if (!localStorage.getItem('botNick')) localStorage.setItem('botNick', '');
  446. if (!localStorage.getItem('botAmount')) localStorage.setItem('botAmount', 500);
  447. if (!localStorage.getItem('extraZoom')) localStorage.setItem('extraZoom', true);
  448. window.client.UUID = localStorage.getItem('agarUnlimited2UUID');
  449.  
  450. new GUITweaker();
  451. }, 7500);
  452. })
  453. }, 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement