Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.01 KB | None | 0 0
  1. // Bot Client Class
  2. class Client {
  3. constructor(botServerIP) {
  4. this.botServerIP = botServerIP;
  5. this._ws = null;
  6. this.moveInterval = 0;
  7. this.clientX = 0;
  8. this.clientY = 0;
  9. this.currentServer = '';
  10. this.botMode = 'FEEDER';
  11. this.token = '';
  12. this.serverReady = false;
  13. this.serverInUse = false;
  14. this.validated = false;
  15. this.extraZoom = false;
  16. this.connect();
  17. this.addListener();
  18. }
  19.  
  20. connect() { // Connect
  21. this._ws = new WebSocket(this.botServerIP);
  22. this._ws.binaryType = 'arraybuffer';
  23. this._ws.onopen = this.onopen.bind(this);
  24. this._ws.onmessage = this.onmessage.bind(this);
  25. this._ws.onclose = this.onclose.bind(this);
  26. this._ws.onerror = this.onerror.bind(this);
  27. console.log('Client: Connecting to bot server....');
  28. }
  29.  
  30. onopen() {
  31. console.log('Client: Connected to bot server.');
  32. $('#botServer').removeClass('label-default');
  33. $('#botServer').removeClass('label-danger');
  34. $('#botServer').addClass('label-success');
  35. $('#botServer').html('Connected');
  36. this.sendToken();
  37. this.startMoveInterval();
  38. }
  39.  
  40. sendToken() {
  41. let buf = this.createBuffer(2 + this.token.length);
  42. buf.setUint8(0, 4);
  43. for (let i = 0; i < this.token.length; i++) buf.setUint8(1 + i, this.token.charCodeAt(i));
  44. this.send(buf);
  45. }
  46.  
  47. onmessage(msg) {
  48. let buf = new DataView(msg.data);
  49. let offset = 0;
  50. let opcode = buf.getUint8(offset++);
  51. switch (opcode) {
  52. case 0:
  53. let spawnedAmount = buf.getUint16(offset, true);
  54. offset += 2;
  55. let connectedAmount = buf.getUint16(offset, true);
  56. offset += 2;
  57. let maxBots = buf.getUint16(offset, true);
  58. $('#botCount').html(`${connectedAmount}/${spawnedAmount}/${maxBots}`);
  59. if (connectedAmount >= 1) {
  60. $('#botCount').removeClass('label-default');
  61. $('#botCount').addClass('label-success');
  62. } else if (connectedAmount < 1) {
  63. $('#botCount').addClass('label-default');
  64. $('#botCount').removeClass('label-success');
  65. }
  66. break;
  67. case 1:
  68. let serverStatus = buf.getUint8(offset++);
  69. let classes = 'label-';
  70. let message = 'Failed to read message';
  71. switch (serverStatus) {
  72. case 0:
  73. this.serverReady = false;
  74. classes += 'warning';
  75. message = 'Phantom loading';
  76. break;
  77. case 1:
  78. this.serverReady = true;
  79. classes += 'success';
  80. message = 'Ready';
  81. break;
  82. case 2:
  83. this.serverReady = false;
  84. this.serverInUse = true;
  85. classes += 'danger';
  86. message = 'In use';
  87. break;
  88. case 3:
  89. let stat = buf.getUint8(offset++);
  90. switch (stat) {
  91. case 0:
  92. this.serverReady = false;
  93. classes += 'warning';
  94. message = 'Getting proxies (0)';
  95. break;
  96. case 1:
  97. this.serverReady = true;
  98. classes += 'success';
  99. message = 'Ready';
  100. break;
  101. case 2:
  102. classes += 'warning';
  103. message = `Getting proxies (${buf.getUint16(offset, true)})`;
  104. break;
  105. }
  106. break;
  107. case 4:
  108. let isValid = buf.getUint8(offset++);
  109. if (isValid) {
  110. classes += 'success';
  111. message = 'Validated/Ready';
  112. this.validated = true;
  113. } else {
  114. classes += 'danger';
  115. message = 'Not validated';
  116. this.serverInUse = true;
  117. }
  118. break;
  119. case 5:
  120. classes += 'warning';
  121. message = 'Waiting for validation';
  122. break;
  123. default:
  124. alert(`Warning: Received unknown server status from bot server: ${serverStatus}`);
  125. break;
  126. }
  127. switch (classes) {
  128. case 'label-danger':
  129. $('#serverStatus').removeClass('label-success');
  130. $('#serverStatus').removeClass('label-warning');
  131. break;
  132. case 'label-success':
  133. $('#serverStatus').removeClass('label-danger')
  134. $('#serverStatus').removeClass('label-warning');
  135. break;
  136. case 'label-warning':
  137. $('#serverStatus').removeClass('label-success');
  138. $('#serverStatus').removeClass('label-danger');
  139. break;
  140. }
  141. $('#serverStatus').addClass(classes);
  142. $('#serverStatus').html(message);
  143. break;
  144. case 16:
  145. if (window.sniffer) {
  146. buf = this.getRealData(new Buffer(buf.buffer));
  147. let output = new Buffer(LZ4.encodeBound(buf.byteLength));
  148. const compressedSize = LZ4.encodeBlock(buf, output);
  149. output = output.slice(0, compressedSize);
  150. let packet = new Buffer(5);
  151. packet.writeUInt8(255, 0);
  152. packet.writeUInt32LE(compressedSize, 1);
  153. sniffer.fakeReceiveData(Buffer.concat([packet, output]));
  154. }
  155. break;
  156. default:
  157. console.log('Got invalid data from bot server');
  158. break;
  159. }
  160. }
  161.  
  162. getRealData(buf) {
  163. let offset = 1;
  164. let eatQueueLength = buf.readUInt16LE(offset); // Number of eat events
  165. offset += eatQueueLength * 8 + 2;
  166.  
  167. while (true) {
  168. if (buf.readUInt32LE(offset) === 0) break; // End of cell queue.
  169. offset += 4;
  170. let x = buf.readInt32LE(offset); // Cell X position.
  171. buf.writeInt32LE(x + window.offsetX, offset);
  172. offset += 4;
  173. let y = buf.readInt32LE(offset); // Cell Y position.
  174. buf.writeInt32LE(y + window.offsetY, offset);
  175. offset += 6;
  176. let flags = buf.readUInt8(offset++); // Cell flags
  177.  
  178. if (flags & 2) { // Cell color in RGB
  179. offset += 3;
  180. }
  181.  
  182. if (flags & 128) { // Added in protocol v11.
  183. offset++;
  184. }
  185.  
  186. if (flags & 4) { // Cell skin
  187. let char = 0;
  188. while ((char = buf.readUInt8(offset++)) !== 0) {}
  189. }
  190.  
  191. if (flags & 8) { // Cell name
  192. let char = 0;
  193. while ((char = buf.readUInt8(offset++)) !== 0) {}
  194. }
  195. }
  196. return buf;
  197. }
  198.  
  199. onclose() {
  200. console.log('Client: Connection to bot server closed.');
  201. $('#botServer').addClass('label-danger');
  202. $('#botServer').removeClass('label-success');
  203. $('#botCount').addClass('label-default');
  204. $('#botCount').removeClass('label-success');
  205. $('#serverStatus').addClass('label-default');
  206. $('#serverStatus').removeClass('label-success');
  207. $('#serverStatus').removeClass('label-warning');
  208. $('#serverStatus').removeClass('label-danger');
  209. if (!this.serverInUse) $('#serverStatus').html('Connecting...');
  210. $('#botCount').html('0/0/0');
  211. $('#botServer').html('Closed');
  212. $('#toggleButton').replaceWith(`<button id='toggleButton' onclick='window.client.startBots();' class='btn btn-success'>Start</button>`);
  213. clearInterval(this.moveInterval);
  214. this.serverReady = false;
  215. this.validated = false;
  216. if (!this.serverInUse) setTimeout(this.connect.bind(this), 500);
  217. }
  218.  
  219. onerror() {
  220. console.log('Client: Connection to bot server errored.');
  221. }
  222.  
  223. startBots() { //Send startBots
  224. if (!this.serverReady || !this.validated) return alert('Wow! Chill... Go and buy the bots before using them ??');
  225. this.changeBotMode(this.botMode);
  226. let botNick = $('#botNick').val();
  227. let botAmount = $('#botAmount').val();
  228. let currentServer = this.currentServer;
  229. console.log(botNick, currentServer);
  230. let buf = this.createBuffer(9 + 2 * botNick.length + 2 * currentServer.length);
  231. let offset = 0;
  232. buf.setUint8(offset++, 0);
  233. for (let i = 0; i < botNick.length; i++) {
  234. buf.setUint16(offset, botNick.charCodeAt(i), true);
  235. offset += 2;
  236. }
  237. buf.setUint16(offset, 0, true);
  238. offset += 2;
  239. for (let i = 0; i < currentServer.length; i++) {
  240. buf.setUint16(offset, currentServer.charCodeAt(i), true);
  241. offset += 2;
  242. }
  243. buf.setUint16(offset, 0, true);
  244. offset += 2;
  245. buf.setUint32(offset, botAmount, true);
  246. this.send(buf);
  247. $('#toggleButton').replaceWith(`<button id='toggleButton' onclick='window.client.stopBots();' class='btn btn-danger'>Stop</button>`);
  248. }
  249.  
  250. sendGetProxies() {
  251. let buf = this.createBuffer(3);
  252. buf.setUint8(0, 3);
  253. buf.setUint16(1, $('#proxyTimeout').val(), true);
  254. this.send(buf);
  255. }
  256.  
  257. changeBotMode(newMode) {
  258. let buf = this.createBuffer(3 + newMode.length * 2);
  259. buf.setUint8(0, 2);
  260. for (let i = 0; i < newMode.length; i++) buf.setUint16(1 + 2 * i, newMode.charCodeAt(i), true);
  261. this.send(buf);
  262. }
  263.  
  264. stopBots() { //Send stopBots
  265. let buf = this.createBuffer(1);
  266. buf.setUint8(0, 1);
  267. this.send(buf);
  268. $('#toggleButton').replaceWith(`<button id='toggleButton' onclick='window.client.startBots();' class='btn btn-success'>Start</button>`);
  269. }
  270.  
  271. toggleMove() {
  272. if ($('#botStopped').html() == 'ON') {
  273. $('#botStopped').html('OFF');
  274. $('#botStopped').removeClass('label-success');
  275. $('#botStopped').addClass('label-danger');
  276. this.changeBotMode(this.botMode);
  277. } else {
  278. $('#botStopped').html('ON');
  279. $('#botStopped').removeClass('label-danger');
  280. $('#botStopped').addClass('label-success');
  281. this.changeBotMode('STOPPED');
  282. $('#botAI').html('OFF');
  283. $('#botAI').removeClass('label-success');
  284. $('#botAI').addClass('label-danger');
  285. }
  286. }
  287.  
  288. toggleAI() {
  289. if ($('#botAI').html() == 'ON') {
  290. $('#botAI').html('OFF');
  291. $('#botAI').removeClass('label-success');
  292. $('#botAI').addClass('label-danger');
  293. this.changeBotMode(this.botMode);
  294. } else {
  295. $('#botAI').html('ON');
  296. $('#botAI').removeClass('label-danger');
  297. $('#botAI').addClass('label-success');
  298. this.changeBotMode('BOTAI');
  299. $('#botStopped').html('OFF');
  300. $('#botStopped').removeClass('label-success');
  301. $('#botStopped').addClass('label-danger');
  302. }
  303. }
  304. sendMove(xPos, yPos) { //Send xPos and yPos
  305. let buf = this.createBuffer(9);
  306. buf.setUint8(0, 16);
  307. buf.setInt32(1, xPos, true);
  308. buf.setInt32(5, yPos, true);
  309. this.send(buf);
  310. }
  311.  
  312. split() {
  313. let buf = this.createBuffer(1);
  314. buf.setUint8(0, 17);
  315. this.send(buf);
  316. }
  317.  
  318. eject() {
  319. let buf = this.createBuffer(1);
  320. buf.setUint8(0, 21);
  321. this.send(buf);
  322. }
  323.  
  324. startMoveInterval() {
  325. this.moveInterval = setInterval(() => {
  326. 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);
  327. }, 100);
  328. }
  329.  
  330. createBuffer(len) {
  331. return new DataView(new ArrayBuffer(len));
  332. }
  333.  
  334. send(data) { //Send the data to the BotServer if the WebSocket is connected.
  335. if (this._ws.readyState !== 1) return;
  336. this._ws.send(data, {
  337. binary: true
  338. });
  339. }
  340.  
  341. addListener() {
  342. document.addEventListener('mousemove', event => {
  343. this.clientX = event.clientX;
  344. this.clientY = event.clientY;
  345. });
  346. }
  347.  
  348. genToken() {
  349. const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  350. let token = '';
  351. for (let i = 0; i < 3; i++) {
  352. for (let a = 0; a < 7; a++) token += possible.charAt(Math.floor(Math.random() * possible.length));
  353. token += '-';
  354. }
  355. token = token.substring(0, token.length - 1);
  356. localStorage.setItem('AgarBotsToken', token);
  357. return token;
  358. }
  359. }
  360.  
  361. class GUITweaker {
  362. constructor() {
  363. this.removeStartupBackground();
  364. this.removeElements();
  365. this.addBotGUI();
  366. this.addGUI();
  367. this.loadCustomCSS();
  368. }
  369.  
  370. removeStartupBackground() {
  371. const oldEvt = CanvasRenderingContext2D.prototype.drawImage;
  372. CanvasRenderingContext2D.prototype.drawImage = function (a) {
  373. if (a.src && a.src == 'http://agar.io/img/background.png') return;
  374. oldEvt.apply(this, arguments);
  375. };
  376. }
  377.  
  378. removeElements() {
  379. $('#advertisement').remove();
  380. $('#bannerCarousel').remove();
  381. }
  382.  
  383. addBotGUI() {
  384. const botNick = localStorage.getItem('botNick') || 'MegaBots,pw';
  385. const proxyTimeout = localStorage.getItem('proxyTimeout') || 15000;
  386. const botAmount = localStorage.getItem('botAmount') || 500;
  387. const botMode = localStorage.getItem('botMode');
  388. $('.agario-promo-container').replaceWith(`
  389. <div class="agario-panel">
  390. <center><h3>MegaBots</h3></center>
  391. <div style="margin-top: 6px;" class="input-group">
  392. <span style="width:75px;" class="input-group-addon" id="basic-addon1">Token/UID</span>
  393. <input style="width:230px" disabled id="AgarBotsToken" class="form-control" placeholder="UUID" value="Loading client..."></input>
  394. </div>
  395. <br>
  396. <input onchange="localStorage.setItem('botNick', this.value);" id="botNick" maxlength="15" class="form-control" placeholder="Bot Name" value="${botNick}"></input>
  397. <br>
  398. <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>
  399. <br>
  400. <select onchange="window.client.botMode=this.value;localStorage.setItem('botMode', this.value);" class="form-control">
  401. <option ${botMode == "FEEDER" ? "selected" : ""} value="FEEDER">Feed Bots</option>
  402. <option ${botMode == "CRASHER" ? "selected" : ""} value="CRASHER">Server Crasher [Premium]</option>
  403. <option ${botMode == "AGARVIEW" ? "selected" : ""} value="AGARVIEW">Spectate [Beta]</option>
  404. </select>
  405. <br>
  406. <button id="toggleButton" onclick="window.client.startBots();" class="btn btn-success">Start!</button>
  407. <br><br>
  408. <input onkeypress="return event.charCode >= 48 &amp;&amp; event.charCode <= 57" onchange="localStorage.setItem('proxyTimeout', this.value);" id="proxyTimeout" class="form-control" placeholder="Checking Timeout" value="${proxyTimeout}">
  409. <br>
  410. </div>`);
  411. }
  412.  
  413. addGUI() {
  414. addGUI() {
  415. $('body').append(`<div id="xPanel" style="background-color: #2c3e50; margin:0 auto;clear:left;xt-align:center;/* Add This*/zoom: 1; border-radius: 6px;top: 3px;left: 22px;width: 535px;height: 74px;display: block;position: relative;text-align: center;font-size: 15px;color: #ffffff;padding: 5px;font-family: Ubuntu;"> <div style=" float: left; margin: 2px; "> <p style=" /*background: #0a5cce;*/ padding: 10px; font-size: 20px; width: 120px; height: 50px; -webkit-border-radius: 5px; /* Firefox 1-3.6 */ -moz-border-radius: 5px; /* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, iOS 4, Android 2.1+ */ border-radius: 5px; "<a href="#">MegaBots<r< p=""> </b></r<></p><div id="bot_t" style="display: none;background: #242720;font-size: 13px;font-weight: bold;margin-top: -18px;margin-left: -4px;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;"> Time Left: <br><span id="countdown" class="timer"></span></div> </div> <div style="float: left;margin: 2px;"> <a class="" id="clickbot" style="background: #2c3e50;font-size: 17px;font-weight: bold;width: 110px;">Bots: <span id="botCount" class="label label-warning">0/0/0</span></div><br><br></span><p style="display:none;background: rgb(35, 112, 152);padding: 3px;font-size: 16px;width: 120px;height: 50px;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;" id="botsOnline">Bots Online<br></p><div class="alert alert-success" id="succ" style=" display: none;background: #1b1b1f;padding: 7px;width: 116px;color:white;"> Time Left: <br><span id="countdown" class="timer"></span></div> </div> <div style=" float: left; margin: -7px; "> <p style=" background: #2d3227; padding: 0px; font-size: 16px; width: 100px; height: 45px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; "><button id='toggleButton' onclick='window.client.startBots();' class='btn btn-success'>Start</button></div><div style="float: right;margin: -6px;margin-top: 8px;"> <a class="btn btn-success btn-xs" id="hidePanel" style="background: #eccb13;padding: 3px;font-size: 5px;/* font-weight: bold; */width: -50px;height: -25px;/* -webkit-border-radius: 10px; */-moz-border-radius: 10px;/* border-radius: 10px; */" </div></div></div>`);
  416. $('#options').append(`
  417. <label>
  418. <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">
  419. <span data-itr="Extra Zoom">Extra Zoom</span>
  420. <input ${(JSON.parse(localStorage.getItem('showMinimap')))?'checked ':''}onclick="localStorage.setItem('showMinimap', this.checked);this.checked?$('#Minimap').show():$('#Minimap').hide();"type="checkbox"id="extraZoom"style="margin-top: 1px"><span data-itr="Minimap">Minimap</span>
  421. </label>`);
  422. $('#instructions').append(`<hr><br /><span style="font-size=xx-large;color:red;font-weight:bold">MEGABOTS.PW INFO:</span><br/><span color="black">No plan active? Check that you have correctly updated your IP ?</span><br />Press <b>R</b> to eject mass from your bot<br />Press <b>E</b> to split your bot (<b>Shift+X</b> fastSplit bots)<br />Press <b>W</b> to auto feed<br />Press <b>P</b> to stop moving<br />Press <b>Shift</b> to fast split<br />NEW : Infinite zoom<br />)
  423. <span style="color:red">BOTS WORK EVEN IN FFA NOW! [beta]</span><br /><b><span color="black">You need to enter the game for the bots to connect,if the bot isn\'t working try to refresh the page</span></b><br /><br /><a href="http://megabots.pw">MegaBots.pw</a> Disclaimer : <br />Remember that we have no link of any sort with agar.io and the bots can suddenly stop working if agar.io update its game. We will try our best to have our bot solution working and we won\'t refund you if its not. If you encounter any problem come to our <a href="#" target="_blank">SUPPORT</a>`);
  424. }
  425. loadCustomCSS() {
  426. $('head').append(`<style type="text/css">.agario-panel, .shop-blocker {opacity:2!important;background-color:rgb(255,0,15,)!important;color:#AAAAAA!important}</style>`);
  427. }
  428. }
  429. //background color gray? (170, 170, 170)
  430. let check = setInterval(() => {
  431. if (document.readyState == "complete") {
  432. clearInterval(check);
  433. setTimeout(() => {
  434. new GUITweaker();
  435. $('#AgarBotsToken').val(client.token);
  436. }, 1500);
  437. }
  438. }, 100);
  439.  
  440. class Macro {
  441. constructor() {
  442. this.ejectDown = false;
  443. this.stopped = false;
  444. this.speed = 15;
  445. this.addMoveHook();
  446. this.addKeyHooks();
  447. }
  448.  
  449. addKeyHooks() {
  450. window.addEventListener('keydown', this.onkeydown.bind(this));
  451. window.addEventListener('keyup', this.onkeyup.bind(this));
  452. }
  453.  
  454. onkeydown(event) {
  455. if (!window.MC || !MC.isInGame()) return;
  456. switch (event.key.toUpperCase()) {
  457. case 'W':
  458. this.ejectDown = true;
  459. setTimeout(this.eject.bind(this), this.speed);
  460. break;
  461. case 'P':
  462. this.stopped = !this.stopped;
  463. break;
  464. case 'E':
  465. client.split();
  466. break;
  467. case 'R':
  468. client.eject();
  469. break;
  470. case 'T':
  471. client.toggleAI();
  472. break;
  473. case 'O':
  474. client.toggleMove();
  475. break;
  476. }
  477. if (event.keyCode == 16) {
  478. for (let i = 0; i < 11; i++) setTimeout(window.core.split, this.speed * i);
  479. }
  480. }
  481.  
  482. onkeyup(event) {
  483. switch (String.fromCharCode(event.keyCode).toUpperCase()) {
  484. case 'W':
  485. this.ejectDown = false;
  486. break;
  487. }
  488. }
  489.  
  490. eject() {
  491. if (this.ejectDown) {
  492. window.core.eject();
  493. setTimeout(this.eject.bind(this), this.speed);
  494. }
  495. }
  496.  
  497. addMoveHook() {
  498. window.core._setTarget = window.core.setTarget;
  499. window.core.setTarget = function () {
  500. if (!this.stopped) window.core._setTarget.apply(this, arguments);
  501. else window.core._setTarget(window.innerWidth / 2, window.innerHeight / 2);
  502. }.bind(this);
  503. }
  504. }
  505.  
  506. window.onload = () => {
  507. new Macro();
  508. new Minimap();
  509. }
  510. class Minimap {
  511. constructor() {
  512. this.canvas = null;
  513. this.ctx = null;
  514. this.init();
  515. }
  516. init() {
  517. this.createCanvas();
  518. requestAnimationFrame(this.drawUpdate.bind(this));
  519. }
  520. createCanvas() {
  521. if (!document.body) return setTimeout(this.createCanvas.bind(this), 100);
  522. this.canvas = document.createElement("canvas");
  523. this.ctx = this.canvas.getContext('2d');
  524. this.addCanvasCustomization();
  525. document.body.appendChild(this.canvas);
  526. }
  527. addCanvasCustomization() {
  528. this.canvas.id = "Minimap";
  529. this.canvas.width = 200;
  530. this.canvas.height = 200;
  531. this.canvas.style.position = "absolute";
  532. this.canvas.style.border = '2px solid #ffffff';
  533. this.canvas.style.top = "74.9%";
  534. this.canvas.style.right = "0%";
  535. this.drawUpdate();
  536. }
  537. clearCanvas() {
  538. this.ctx.save();
  539. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  540. this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
  541. this.ctx.restore();
  542. }
  543. drawUpdate() {
  544. if (!this.ctx) return;
  545. this.clearCanvas();
  546. const cWidth = this.canvas.width;
  547. const cHeight = this.canvas.height;
  548. this.ctx.strokeStyle = "#ffffff";
  549. this.ctx.strokeWidth = 1;
  550. this.ctx.beginPath();
  551. this.ctx.globalAlpha = 0.9;
  552. this.ctx.rect(0, 0, cWidth, cHeight);
  553. this.ctx.fillStyle = "black";
  554. this.ctx.fill();
  555. this.ctx.beginPath();
  556. let iCount = Math.floor(cWidth / 40);
  557. let i;
  558. for (i = 1; i <= iCount; i++) {
  559. const x = i * 40;
  560. this.ctx.moveTo(x, 0);
  561. this.ctx.lineTo(x, cHeight);
  562. this.ctx.stroke();
  563. }
  564. iCount = Math.floor(cHeight / 40);
  565. for (i = 1; i <= iCount; i++) {
  566. const y = i * 40;
  567. this.ctx.moveTo(0, y);
  568. this.ctx.lineTo(cWidth, y);
  569. this.ctx.stroke();
  570. }
  571. this.ctx.closePath();
  572. this.drawCellUpdate(window.playerX, window.playerY, "#800000");
  573. requestAnimationFrame(this.drawUpdate.bind(this));
  574. }
  575. drawCellUpdate(x, y, color) {
  576. const transX = (7071 + x) / 14142 * this.canvas.height;
  577. const transY = (7071 + y) / 14142 * this.canvas.width;
  578. this.ctx.fillStyle = color;
  579. this.ctx.beginPath();
  580. this.ctx.arc(transX, transY, 6, 0, 2 * Math.PI);
  581. this.ctx.fill();
  582. }
  583. drawBotUpdate() {
  584. for (const bot of window.bots) {
  585. const botTransX = (7071 + bot.xPos) / 14142 * this.canvas.height;
  586. const botTransY = (7071 + bot.yPos) / 14142 * this.canvas.width;
  587. this.ctx.fillStyle = "#006400";
  588. this.ctx.beginPath();
  589. if (bot.xPos !== 0 && bot.yPos !== 0) {
  590. this.ctx.arc(botTransX, botTransY, 6, 0, 2 * Math.PI);
  591. }
  592. this.ctx.fill();
  593. }
  594. }
  595. }
  596. //Load custom core.
  597. $.ajax('http://agar.io/agario.core.js', {
  598. success: core => {
  599. 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;}');
  600. 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);');
  601. core = core.replace(/var (\w)=new WebSocket\((\w\(\w\))\);/, 'window.client.currentServer=$2;var $1=new WebSocket(window.client.currentServer);');
  602. core = core.replace(/if\((\+\w\[\w>>3\])<1\.0\){/i, 'if($1<!client.extraZoom){');
  603. core = core.replace(/(if\([\w$]+\[[\w$]+\+\d+\>\>0\]\|0\)\{[\w$]+\=[\w$]+;return\})(if\(\![\w$]+\))/, '$1if(false)$2');
  604. eval(core);
  605. },
  606. dataType: 'text',
  607. method: 'GET',
  608. cache: false,
  609. crossDomain: true
  610. });
  611.  
  612. function isInIncognito(callback) {
  613. var fs = window.RequestFileSystem || window.webkitRequestFileSystem;
  614. if (!fs) return callback(false);
  615. fs(window.TEMPORARY, 100, () => callback(false), () => callback(true));
  616. }
  617. isInIncognito(incognito => {
  618. 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.');
  619. else runClientLoad();
  620. });
  621.  
  622. function runClientLoad() {
  623. window.client = new Client('ws://94.177.189.246:4561'); // Bot Server IP.
  624. client.botMode = localStorage.getItem('botMode') || 'FEEDER'; // Set the bot mode to the stored bot mode.
  625. client.extraZoom = JSON.parse(localStorage.getItem('extraZoom'));
  626. client.token = localStorage.getItem('AgarBotsToken') || client.genToken();
  627. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement