Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.72 KB | None | 0 0
  1. // Bot Client Class
  2. let currentServer = null;
  3. class Client {
  4. constructor(botServerIP) {
  5. this.botServerIP = botServerIP;
  6. this._ws = null;
  7. this.moveInterval = 0;
  8. this.clientX = 0;
  9. this.clientY = 0;
  10. this.currentServer = '';
  11. this.botMode = 'FEEDER';
  12. this.token = '';
  13. this.serverReady = false;
  14. this.serverInUse = false;
  15. this.validated = false;
  16. this.extraZoom = false;
  17. this.connect();
  18. this.addListener();
  19. }
  20.  
  21. connect() { // Connect
  22. this._ws = new WebSocket(this.botServerIP);
  23. this._ws.binaryType = 'arraybuffer';
  24. this._ws.onopen = this.onopen.bind(this);
  25. this._ws.onmessage = this.onmessage.bind(this);
  26. this._ws.onclose = this.onclose.bind(this);
  27. this._ws.onerror = this.onerror.bind(this);
  28. console.log('Client: Connecting to bot server....');
  29. }
  30.  
  31. onopen() {
  32. console.log('Client: Connected to bot server.');
  33. $('#botServer').removeClass('label-default');
  34. $('#botServer').removeClass('label-danger');
  35. $('#botServer').addClass('label-success');
  36. $('#botServer').html('Online');
  37. this.sendToken();
  38. this.startMoveInterval();
  39. }
  40.  
  41. sendToken() {
  42. let buf = this.createBuffer(2 + this.token.length);
  43. buf.setUint8(0, 4);
  44. for (let i = 0; i < this.token.length; i++) buf.setUint8(1 + i, this.token.charCodeAt(i));
  45. this.send(buf);
  46. }
  47.  
  48. onmessage(msg) {
  49. let buf = new DataView(msg.data);
  50. let offset = 0;
  51. let opcode = buf.getUint8(offset++);
  52. switch (opcode) {
  53. case 0:
  54. let spawnedAmount = buf.getUint16(offset, true);
  55. offset += 2;
  56. let connectedAmount = buf.getUint16(offset, true);
  57. offset += 2;
  58. let maxBots = buf.getUint16(offset, true);connectedAmount
  59. $('#botCount').html(`${spawnedAmount}/${connectedAmount}`);
  60. if (connectedAmount >= 1) {
  61. $('#botCount').removeClass('label-default');
  62. $('#botCount').addClass('label-success');
  63. } else if (connectedAmount < 1) {
  64. $('#botCount').addClass('label-default');
  65. $('#botCount').removeClass('label-success');
  66. }
  67. break;
  68. case 1:
  69. let serverStatus = buf.getUint8(offset++);
  70. let classes = 'label-';
  71. let message = 'Failed to read message';
  72. switch (serverStatus) {
  73. case 0:
  74. this.serverReady = false;
  75. classes += 'warning';
  76. message = 'Phantom loading';
  77. break;
  78. case 1:
  79. this.serverReady = true;
  80. classes += 'success';
  81. message = 'Ready';
  82. break;
  83. case 2:
  84. this.serverReady = false;
  85. this.serverInUse = true;
  86. classes += 'danger';
  87. message = 'In use';
  88. break;
  89. case 3:
  90. let stat = buf.getUint8(offset++);
  91. switch (stat) {
  92. case 0:
  93. this.serverReady = false;
  94. classes += 'warning';
  95. message = 'Getting proxies (0)';
  96. break;
  97. case 1:
  98. this.serverReady = true;
  99. classes += 'success';
  100. message = 'Ready';
  101. break;
  102. case 2:
  103. classes += 'warning';
  104. message = `Getting proxies (${buf.getUint16(offset, true)})`;
  105. break;
  106. }
  107. break;
  108. case 4:
  109. let isValid = buf.getUint8(offset++);
  110. if (isValid) {
  111. classes += 'success';
  112. message = 'Validated/Ready';
  113. this.validated = true;
  114. } else {
  115. classes += 'danger';
  116. message = 'Not validated';
  117. this.serverInUse = true;
  118. }
  119. break;
  120. case 5:
  121. classes += 'warning';
  122. message = 'Waiting for validation';
  123. break;
  124. default:
  125. alert(`Warning: Received unknown server status from bot server: ${serverStatus}`);
  126. break;
  127. }
  128. switch (classes) {
  129. case 'label-danger':
  130. $('#serverStatus').removeClass('label-success');
  131. $('#serverStatus').removeClass('label-warning');
  132. break;
  133. case 'label-success':
  134. $('#serverStatus').removeClass('label-danger')
  135. $('#serverStatus').removeClass('label-warning');
  136. break;
  137. case 'label-warning':
  138. $('#serverStatus').removeClass('label-success');
  139. $('#serverStatus').removeClass('label-danger');
  140. break;
  141. }
  142. $('#serverStatus').addClass(classes);
  143. $('#serverStatus').html(message);
  144. break;
  145. case 16:
  146. if (window.sniffer) {
  147. buf = this.getRealData(new Buffer(buf.buffer));
  148. let output = new Buffer(LZ4.encodeBound(buf.byteLength));
  149. const compressedSize = LZ4.encodeBlock(buf, output);
  150. output = output.slice(0, compressedSize);
  151. let packet = new Buffer(5);
  152. packet.writeUInt8(255, 0);
  153. packet.writeUInt32LE(compressedSize, 1);
  154. sniffer.fakeReceiveData(Buffer.concat([packet, output]));
  155. }
  156. break;
  157. default:
  158. console.log('Got invalid data from bot server');
  159. break;
  160. }
  161. }
  162.  
  163. getRealData(buf) {
  164. let offset = 1;
  165. let eatQueueLength = buf.readUInt16LE(offset); // Number of eat events
  166. offset += eatQueueLength * 8 + 2;
  167.  
  168. while (true) {
  169. if (buf.readUInt32LE(offset) === 0) break; // End of cell queue.
  170. offset += 4;
  171. let x = buf.readInt32LE(offset); // Cell X position.
  172. buf.writeInt32LE(x + window.offsetX, offset);
  173. offset += 4;
  174. let y = buf.readInt32LE(offset); // Cell Y position.
  175. buf.writeInt32LE(y + window.offsetY, offset);
  176. offset += 6;
  177. let flags = buf.readUInt8(offset++); // Cell flags
  178.  
  179. if (flags & 2) { // Cell color in RGB
  180. offset += 3;
  181. }
  182.  
  183. if (flags & 128) { // Added in protocol v11.
  184. offset++;
  185. }
  186.  
  187. if (flags & 4) { // Cell skin
  188. let char = 0;
  189. while ((char = buf.readUInt8(offset++)) !== 0) {}
  190. }
  191.  
  192. if (flags & 8) { // Cell name
  193. let char = 0;
  194. while ((char = buf.readUInt8(offset++)) !== 0) {}
  195. }
  196. }
  197. return buf;
  198. }
  199.  
  200. onclose() {
  201. console.log('Client: Connection to bot server closed.');
  202. $('#botServer').addClass('label-danger');
  203. $('#botServer').removeClass('label-success');
  204. $('#botCount').addClass('label-default');
  205. $('#botCount').removeClass('label-success');
  206. $('#serverStatus').addClass('label-default');
  207. $('#serverStatus').removeClass('label-success');
  208. $('#serverStatus').removeClass('label-warning');
  209. $('#serverStatus').removeClass('label-danger');
  210. if (!this.serverInUse) $('#serverStatus').html('Waiting...');
  211. $('#botCount').html('0/0');
  212. $('#botServer').html('Closed');
  213. $('#toggleButton').replaceWith(`<button id='toggleButton' onclick='window.client.startBots();' class='btn btn-success'>Start Bots</button>`);
  214. clearInterval(this.moveInterval);
  215. this.serverReady = false;
  216. this.validated = false;
  217. if (!this.serverInUse) setTimeout(this.connect.bind(this), 500);
  218. }
  219.  
  220. onerror() {
  221. console.log('Client: Connection to bot server errored.');
  222. }
  223.  
  224. startBots() { //Send startBots
  225. if (!this.serverReady || !this.validated) return alert('Bot server is not ready for bots to be started yet!');
  226. this.changeBotMode(this.botMode);
  227. let botNick = $('#botNick').val();
  228. let botAmount = $('#botAmount').val();
  229. let currentServer = this.currentServer;
  230. $("#serverIP").html(this.currentServer);
  231. console.log(botNick, currentServer);
  232. let buf = this.createBuffer(9 + 2 * botNick.length + 2 * currentServer.length);
  233. let offset = 0;
  234. buf.setUint8(offset++, 0);
  235. for (let i = 0; i < botNick.length; i++) {
  236. buf.setUint16(offset, botNick.charCodeAt(i), true);
  237. offset += 2;
  238. }
  239. buf.setUint16(offset, 0, true);
  240. offset += 2;
  241. for (let i = 0; i < currentServer.length; i++) {
  242. buf.setUint16(offset, currentServer.charCodeAt(i), true);
  243. offset += 2;
  244. }
  245. buf.setUint16(offset, 0, true);
  246. offset += 2;
  247. buf.setUint32(offset, botAmount, true);
  248. this.send(buf);
  249. }
  250.  
  251. sendGetProxies() {
  252. let buf = this.createBuffer(3);
  253. buf.setUint8(0, 3);
  254. buf.setUint16(1, $('#proxyTimeout').val(), true);
  255. this.send(buf);
  256. }
  257.  
  258. changeBotMode(newMode) {
  259. let buf = this.createBuffer(3 + newMode.length * 2);
  260. buf.setUint8(0, 2);
  261. for (let i = 0; i < newMode.length; i++) buf.setUint16(1 + 2 * i, newMode.charCodeAt(i), true);
  262. this.send(buf);
  263. }
  264.  
  265. stopBots() { //Send stopBots
  266. let buf = this.createBuffer(1);
  267. buf.setUint8(0, 1);
  268. this.send(buf);
  269. }
  270.  
  271. sendMove(xPos, yPos) { //Send xPos and yPos
  272. let buf = this.createBuffer(9);
  273. buf.setUint8(0, 16);
  274. buf.setInt32(1, xPos, true);
  275. buf.setInt32(5, yPos, true);
  276. this.send(buf);
  277. }
  278.  
  279. split() {
  280. let buf = this.createBuffer(1);
  281. buf.setUint8(0, 17);
  282. this.send(buf);
  283. }
  284.  
  285. eject() {
  286. let buf = this.createBuffer(1);
  287. buf.setUint8(0, 21);
  288. this.send(buf);
  289. }
  290.  
  291. startMoveInterval() {
  292. this.moveInterval = setInterval(() => {
  293. if (window.playerX && window.playerX && window.coordOffsetFixed && this.clientX && this.clientY) this.sendMove(((this.clientX - window.innerWidth / 2) / window.viewScale) + window.playerX, ((this.clientY - window.innerHeight / 2) / window.viewScale) + window.playerY);
  294. }, 200);
  295. }
  296.  
  297. createBuffer(len) {
  298. return new DataView(new ArrayBuffer(len));
  299. }
  300.  
  301. send(data) { //Send the data to the BotServer if the WebSocket is connected.
  302. if (this._ws.readyState !== 1) return;
  303. this._ws.send(data, {
  304. binary: true
  305. });
  306. }
  307.  
  308. addListener() {
  309. document.addEventListener('mousemove', event => {
  310. this.clientX = event.clientX;
  311. this.clientY = event.clientY;
  312. });
  313. }
  314.  
  315. genToken() {
  316. const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  317. let token = '';
  318. for (let i = 0; i < 1; i++) {
  319. for (let a = 0; a < 1; a++) token += possible.charAt(Math.floor(Math.random() * possible.length));
  320. token += '-';
  321. }
  322. token = token.substring(0, token.length - 1);
  323. localStorage.setItem('agarUnlimitedToken', token);
  324. return token;
  325. }
  326.  
  327. serverIP() {
  328. if (this.currentServer !== null || this.currentServer !== "") {
  329. $("#serverIP").html(this.currentServer);
  330. }
  331. }
  332. }
  333. setInterval(function() {
  334. document.getElementById("serverIP").value = window.client.currentServer;
  335. }, 1000)
  336.  
  337.  
  338. class GUITweaker {
  339. constructor() {
  340. this.removeStartupBackground();
  341. this.removeElements();
  342. this.addBotGUI();
  343. this.addBotGUI2();
  344. this.addGUI();
  345. this.loadCustomCSS();
  346. }
  347.  
  348. removeStartupBackground() {
  349. const oldEvt = CanvasRenderingContext2D.prototype.drawImage;
  350. CanvasRenderingContext2D.prototype.drawImage = function(a) {
  351. if (a.src && a.src == 'http://agar.io/img/background.png') return;
  352. oldEvt.apply(this, arguments);
  353. };
  354. }
  355.  
  356. removeElements() {
  357. $('#advertisement').hide();
  358. $('#bannerCarousel').remove();
  359. }
  360.  
  361. addBotGUI2() {
  362. $('.center-container').replaceWith(`
  363. <div class="agario-panel">
  364. <div class="form-group clearfix">
  365. <div style="float: left; margin-left: 20px;"><h2>Agar.io</h2></div>
  366.  
  367. <div style="float: right; margin-top: 10px; height: 40px;">
  368. <div id="agarYoutube">
  369. <div id="___ytsubscribe_0" style="text-indent: 0px; margin: 0px; padding: 0px; background: transparent; border-style: none; float: none; line-height: normal; font-size: 1px; vertical-align: baseline; display: inline-block; width: 111px; height: 24px;"><iframe ng-non-bindable="" frameborder="0" hspace="0" marginheight="0" marginwidth="0" scrolling="no" style="position: static; top: 0px; width: 111px; margin: 0px; border-style: none; left: 0px; visibility: visible; height: 24px;" tabindex="0" vspace="0" width="100%" id="I0_1498540482998" name="I0_1498540482998" src="https://www.youtube.com/subscribe_embed?usegapi=1&amp;channelid=UCC6hurPo_LxL7C0YFYgYnIw&amp;layout=default&amp;count=default&amp;hl=en-US&amp;origin=http%3A%2F%2Fagar.io&amp;gsrc=3p&amp;ic=1&amp;jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en.L06ziPgL5F0.O%2Fm%3D__features__%2Fam%3DAQ%2Frt%3Dj%2Fd%3D1%2Frs%3DAGLTcCOnbjS-FskKXErWbZEztXj_N3KVvQ#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled%2Cdrefresh%2Cerefresh&amp;id=I0_1498540482998&amp;parent=http%3A%2F%2Fagar.io&amp;pfname=&amp;rpctoken=25594004" data-gapiattached="true"></iframe></div>
  370. </div>
  371. <div class="clearfix">
  372. <div class="fb-like pull-right fb_iframe_widget" data-href="https://www.facebook.com/playagar.io" data-layout="button" data-action="like" data-show-faces="true" data-share="true" fb-xfbml-state="rendered" fb-iframe-plugin-query="action=like&amp;app_id=677505792353827&amp;container_width=0&amp;href=https%3A%2F%2Fwww.facebook.com%2Fplayagar.io&amp;layout=button&amp;locale=en_US&amp;sdk=joey&amp;share=true&amp;show_faces=true"><span style="vertical-align: bottom; width: 98px; height: 20px;"><iframe name="f3ba6e67b02fc18" width="1000px" height="1000px" frameborder="0" allowtransparency="true" allowfullscreen="true" scrolling="no" title="fb:like Facebook Social Plugin" src="https://www.facebook.com/v2.8/plugins/like.php?action=like&amp;app_id=677505792353827&amp;channel=http%3A%2F%2Fstaticxx.facebook.com%2Fconnect%2Fxd_arbiter%2Fr%2FXBwzv5Yrm_1.js%3Fversion%3D42%23cb%3Df2c487e8849c4fc%26domain%3Dagar.io%26origin%3Dhttp%253A%252F%252Fagar.io%252Ff26e7984864468c%26relation%3Dparent.parent&amp;container_width=0&amp;href=https%3A%2F%2Fwww.facebook.com%2Fplayagar.io&amp;layout=button&amp;locale=en_US&amp;sdk=joey&amp;share=true&amp;show_faces=true" style="border: none; visibility: visible; width: 98px; height: 20px;" class=""></iframe></span></div>
  373. <hr>
  374. </div>
  375. </div>
  376. </div>
  377. <div class="form-group clearfix">
  378. <input id="nick" class="form-control" placeholder="Nick" maxlength="15" autofocus="">
  379. <select id="gamemode" class="form-control" required="">
  380. <option value="" data-itr="page_gamemode_ffa">FFA</option>
  381. <option value=":teams" data-itr="page_gamemode_teams">Teams</option>
  382. <option value=":experimental" data-itr="page_gamemode_experimental">Experimental</option>
  383. <option value=":party" data-itr="page_party">Party Mode</option>
  384. </select>
  385.  
  386. <div class="form-group" id="agario-main-buttons">
  387. <div class="row">
  388. <div>
  389. <select id="region" class="form-control" onchange="MC.setRegion($('#region').val());" required="">
  390. <option selected="" disabled="" value="" data-itr="page_region_select" style="display: none;"> -- Select a Region -- </option>
  391. <option value="US-Atlanta" data-itr="page_region_north_america" style="display: block;">North America (4122)</option>
  392. <option value="BR-Brazil" data-itr="page_region_south_america" style="display: block;">South America (1831)</option>
  393. <option value="EU-London" data-itr="page_region_europe" style="display: block;">Europe (1946)</option>
  394. <option value="RU-Russia" data-itr="page_region_russia" style="display: block;">Russia (766)</option>
  395. <option value="TK-Turkey" data-itr="page_region_turkey" style="display: block;">Turkey (385)</option>
  396. <option value="JP-Tokyo" data-itr="page_region_east_asia" style="display: block;">East Asia (1685)</option>
  397. <option value="CN-China" data-itr="page_region_china" style="display: block;">China (382)</option>
  398. <option value="SG-Singapore" data-itr="page_region_oceania" style="display: block;">Oceania (771)</option>
  399. </select>
  400. </div>
  401. <div>
  402. <select id="quality" class="form-control" onchange="MC.setQuality($('#quality').val());" required="">
  403. <option disabled="" value="" data-itr="page_graphics_title">-- Graphics Quality --</option>
  404. <option value="Retina" selected="" data-itr="page_graphics_retina">Graphics: Retina</option>
  405. <option value="High" selected="" data-itr="page_graphics_high">Graphics: High</option>
  406. <option value="Medium" data-itr="page_graphics_medium">Graphics: Medium</option>
  407. <option value="Low" data-itr="page_graphics_low">Graphics: Low</option>
  408. <option value="VeryLow" data-itr="page_graphics_very_low">Graphics: Very Low</option>
  409. </select>
  410. </div>
  411. <button type="submit" class="btn btn-play-guest btn-success btn-needs-server" data-itr="page_play_as_guest">Play as guest</button>
  412. <button type="submit" onclick="toggleSocialLogin(); return false" class="btn btn-warning btn-login-play btn-needs-server" data-itr="page_login_and_play" data-original-title="" title="">Login and play</button>
  413. <div style="float: left; width: 200px;">
  414. </div>
  415. <div id="socialLoginContainer" style="display:none;">
  416. <div class="row">
  417. <button onclick="MC.facebookLogin(); return false;" class="btn btn-primary btn-login btn-fb">
  418. <span class="social social-facebook fb-icon"></span>
  419. <span class="btn-text" data-itr="page_menu_login_facebook">Sign in with Facebook</span>
  420. </button>
  421. </div>
  422. <div class="row">
  423. <button id="gplusLogin" class="btn btn-primary btn-login btn-gplus">
  424. <span class="gplus-icon"></span>
  425. <span class="btn-text" data-itr="page_menu_login_google">Sign in with Google</span>
  426. </button>
  427. </div>
  428. </div>
  429. </div>
  430. <button id="stop-bots" type="submit" style="float: center; margin-left:auto; margin-top: 6px; margin-right:auto; width: 300px; text-decoration: none; color: #fff; font-weight: bold; background- padding: 20px 70px; border: 1px solid white;" class="btn btn-play btn-primary btn-needs-server" data-itr="page_play">Play</button>
  431. <button id="stop-bots" onclick="logout();" style="float: center; margin-top: 6px; margin-left:auto; margin-right:auto; width: 300px; text-decoration: none; color: #fff; font-weight: bold; background- padding: 20px 70px; border: 1px solid white;" class="btn btn-danger btn-logout">Logout</button>
  432. <button class="btn btn-warning btn- btn-needs-server" data-itr="page_spectate" style="float: center; margin-left:auto; margin-top: 3px; margin-right:auto; width: 300px; text-decoration: none; color: #fff; font-weight: bold; background- padding: 20px 70px; border: 1px solid white;" class="btn raised btn-danger">Spectate</button>
  433. </div>
  434.  
  435. <div id="settings" style="margin-top: 5px; font-size: 12px; display:flex; flex-wrap: wrap; justify-content: flex-start;">
  436. <label><input type="checkbox" id="noSkins" style="margin-top: 1px;display:block;width:20px;float:left"><span data-itr="page_option_no_skins">No skins</span></label>
  437. <label><input type="checkbox" id="noNames" style="margin-top: 1px;display:block;width:20px;float:left"><span data-itr="page_option_no_names">No names</span></label>
  438. <label><input type="checkbox" id="noColors" style="margin-top: 1px;display:block;width:20px;float:left"><span data-itr="page_option_no_colors">No colors</span></label>
  439. <label><input type="checkbox" id="showMass" style="margin-top: 1px;display:block;width:20px;float:left"><span data-itr="page_option_show_mass">Show mass</span></label>
  440. <label><input type="checkbox" id="darkTheme" style="margin-top: 1px;display:block;width:20px;float:left"><span data-itr="page_option_dark_theme">Dark theme</span></label>
  441. <label><input type="checkbox" id="skipStats" style="margin-top: 1px;display:block;width:20px;float:left"><span data-itr="page_option_skip_stats">Skip stats</span></label>
  442. <label><input type="checkbox" id="showQuest" style="margin-top: 1px;display:block;width:20px;float:left"><span data-itr="page_option_show_quest">Show Quest</span></label>
  443. <label style="display:none"><input type="checkbox" id="showOnlineStatus" style="margin-top: 1px;display:block;width:20px;float:left"><span data-itr="page_option_show_online_status">Show Online Status</span></label>
  444.  
  445. <label>
  446. <input checked="" onclick="localStorage.setItem('extraZoom', this.checked);client.extraZoom=this.checked;" type="checkbox" id="extraZoom" style="margin-top: 1px">
  447. <span data-itr="Extra Zoom">Extra Zoom</span>
  448. </label></div>
  449.  
  450. </div>
  451. <hr>
  452.  
  453. <center><h3>Bot Controls</h3></center>
  454. <div><left><b style='color: #fff; font-family: arial;'>C - Bots Feed </left></div>
  455. <div><left><b style='color: #fff; font-family: arial;'>X - Split Bots </left></div>
  456. <button id="start-bots" onclick="window.client.startBots();" style="margin: 10px; width: 100px; text-decoration: none; color: #fff; font-weight: bold; background- padding: 20px 70px; border: 1px solid white;" class="btn raised btn-success">Start Bots</button>
  457. <button id="stop-bots" onclick="window.client.stopBots();" style="float: right; margin: 10px; width: 100px; text-decoration: none; color: #fff; font-weight: bold; background- padding: 20px 70px; border: 1px solid white;" class="btn raised btn-danger">Stop Bots</button>
  458. <br>
  459. </div>`);
  460. }
  461.  
  462. addBotGUI() {
  463. const botNick = localStorage.getItem('botNick') || 'CraftBots';
  464. const botAmount = localStorage.getItem('botAmount') || 750;
  465. const botMode = localStorage.getItem('botMode');
  466. $('.agario-promo-container').replaceWith(`
  467. <div class="agario-panel">
  468. <center><h3>Bot Settings</h3></center>
  469. <br><div class="input-group"><span class="input-group-addon" id="basic-addon1" style="border-radius: 0px;">Max Bots(1000)</span><input onkeypress="return event.charCode >= 48 && event.charCode <= 57" onchange="localStorage.setItem('botAmount', this.value);" id="botAmount" maxlength="4" class="form-control" placeholder="Bot Amount" value="${botAmount}"></input></div>
  470. <br><div class="input-group"><span class="input-group-addon" id="basic-addon1" style="border-radius: 0px;">Bot Names</span><input onchange="localStorage.setItem('botNick', this.value);" id="botNick" maxlength="15" class="form-control" placeholder="Bot Name" value="${botNick}"></div>
  471. <br><div class="input-group"><span class="input-group-addon" id="basic-addon1" style="border-radius: 0px;">UUID</span><input style="width:230px" disabled id="agarUnlimitedToken" class="form-control" placeholder="UUID" value="Loading UUID..."></div>
  472. <br><div class="input-group"><span class="input-group-addon" id="basic-addon1" style="border-radius: 0px;">Server Ip</span><input id="serverIP" disabled class="form-control" placeholder=".." value="Server IP"></div>
  473. <br><div class="input-group"><span class="input-group-addon" id="basic-addon1" style="border-radius: 0px;">INFO</span><input style="border-radius: 0px;" type="text" value="Agar.io Bots" readonly class="form-control"></div>
  474. <br><div class="input-group"><span class="input-group-addon" id="basic-addon1" style="border-radius: 0px;">Version</span><input style="border-radius: 0px;" type="text" value="3.1" readonly class="form-control"></div>
  475. <br>
  476. <br>
  477. </div>`);
  478. }
  479.  
  480. addGUI() {
  481. $('body').append(`
  482. <div id="botClient" style="position:absolute;top:110px; font-size: 200%; left:0px;padding:0 8px;font-family:Tahoma;color:#800000;z-index:9999;border-radius:15px;min-height:15px;min-width:200px;background-color: ;">
  483. <div><b>Bot Count</b>: <span id="botCount" style="float: right; margin: 10px; width: 100px; text-decoration: none; color: #800000; font-weight: bold; background- padding: 20px 70px; border: 1px solid white;" class="label label-default pull-right">0/0</span></div>
  484. <br>
  485. </div>`);
  486. $('#options').append(`
  487. <label>
  488. <input ${(JSON.parse(localStorage.getItem('extraZoom'))) ? 'checked' : ''} onclick="localStorage.setItem('extraZoom', this.checked);client.extraZoom=this.checked;" type="checkbox" id="extraZoom" style="margin-top: 1px">
  489. <span data-itr="Extra Zoom">Extra Zoom</span>
  490. </label>`);
  491. }
  492.  
  493. loadCustomCSS() {
  494. $('head').append(`<style type="text/css">.agario-panel, .shop-blocker {background-color:rgba(23,23,23,0.73)!important;color:#fff!important}</style>`);
  495. }
  496. }
  497.  
  498. let check = setInterval(() => {
  499. if (document.readyState == "complete") {
  500. clearInterval(check);
  501. setTimeout(() => {
  502. new GUITweaker();
  503. $('#agarUnlimitedToken').val(client.token);
  504. }, 1500);
  505. }
  506. }, 100);
  507.  
  508. class Macro {
  509. constructor() {
  510. this.ejectDown = false;
  511. this.stopped = false;
  512. this.speed = 15;
  513. this.addMoveHook();
  514. this.addKeyHooks();
  515. }
  516.  
  517. addKeyHooks() {
  518. window.addEventListener('keydown', this.onkeydown.bind(this));
  519. window.addEventListener('keyup', this.onkeyup.bind(this));
  520. }
  521.  
  522. onkeydown(event) {
  523. if (!window.MC || !MC.isInGame()) return;
  524. switch (event.key.toUpperCase()) {
  525. case 'W':
  526. this.ejectDown = true;
  527. setTimeout(this.eject.bind(this), this.speed);
  528. break;
  529. case 'X':
  530. client.split();
  531. break;
  532. case 'C':
  533. client.eject();
  534. break;
  535. }
  536. if (event.keyCode == 16) {
  537. for (let i = 0; i < 11; i++) setTimeout(window.core.split, this.speed * i);
  538. }
  539. }
  540.  
  541. onkeyup(event) {
  542. switch (String.fromCharCode(event.keyCode).toUpperCase()) {
  543. case 'W':
  544. this.ejectDown = false;
  545. break;
  546. }
  547. }
  548.  
  549. eject() {
  550. if (this.ejectDown) {
  551. window.core.eject();
  552. setTimeout(this.eject.bind(this), this.speed);
  553. }
  554. }
  555.  
  556. addMoveHook() {
  557. window.core._setTarget = window.core.setTarget;
  558. window.core.setTarget = function() {
  559. if (!this.stopped) window.core._setTarget.apply(this, arguments);
  560. else window.core._setTarget(window.innerWidth / 2, window.innerHeight / 2);
  561. }.bind(this);
  562. }
  563. }
  564.  
  565. window.onload = () => {
  566. new Macro();
  567. }
  568. //Load custom core.
  569. $.ajax('http://agar.io/agario.core.js', {
  570. success: core => {
  571. core = core.replace(/([\w$]+\(\d+,\w\[\w>>2\]\|0,(\+\w),(\+\w)\)\|0;[\w$]+\(\d+,\w\[\w>>2\]\|0,\+-(\+\w\[\w\+\d+>>3\]),\+-(\+\w\[\w\+\d+>>3\])\)\|0;)/i, '$1 window.viewScale=$2; if (window.coordOffsetFixed) { window.playerX=$4+window.offsetX; window.playerY=$5+window.offsetY;}');
  572. core = core.replace(/(\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);)/i, '$1 function setMapCoords(_0x7e8bx1, _0x7e8bx2, _0x7e8bx3, _0x7e8bx4, _0x7e8bx5, _0x7e8bx6) { if (_0x7e8bx6 - _0x7e8bx5 == 24) { if (_0x7e8bx3 - _0x7e8bx1 > 14E3) { if (_0x7e8bx4 - _0x7e8bx2 > 14E3) { window.offsetX = 7071.067811865476 - _0x7e8bx3; window.offsetY = 7071.067811865476 - _0x7e8bx4; window.coordOffsetFixed = true; } } } } setMapCoords($3,$5,$7,$9,$2,$8);');
  573. core = core.replace(/var (\w)=new WebSocket\((\w\(\w\))\);/, 'window.client.currentServer=$2;var $1=new WebSocket(window.client.currentServer);');
  574. core = core.replace(/if\((\+\w\[\w>>3\])<1\.0\){/i, 'if($1<!client.extraZoom){');
  575. core = core.replace(/(if\([\w$]+\[[\w$]+\+\d+\>\>0\]\|0\)\{[\w$]+\=[\w$]+;return\})(if\(\![\w$]+\))/, '$1if(false)$2');
  576. eval(core);
  577. },
  578. dataType: 'text',
  579. method: 'GET',
  580. cache: false,
  581. crossDomain: true
  582. });
  583.  
  584. function isInIncognito(callback) {
  585. var fs = window.RequestFileSystem || window.webkitRequestFileSystem;
  586. if (!fs) return callback(false);
  587. fs(window.TEMPORARY, 100, () => callback(false), () => callback(true));
  588. }
  589. isInIncognito(incognito => {
  590. if (incognito) alert('This script will not work fully in incognito, settings won\'t save, and your UID would be forcefully changed. Please exit incognito mode and try again.');
  591. else runClientLoad();
  592. });
  593.  
  594. function runClientLoad() {
  595. window.client = new Client('ws://127.0.0.1:4569'); // Bot Server IP.
  596. client.botMode = localStorage.getItem('botMode') || 'FEEDER'; // Set the bot mode to the stored bot mode.
  597. client.extraZoom = JSON.parse(localStorage.getItem('extraZoom'));
  598. client.token = localStorage.getItem('agarUnlimitedToken') || client.genToken();
  599. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement