Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.75 KB | None | 0 0
  1. function escapeHtml(a) {
  2. return String(a).replace(/[&<>"'\/]/g, function(a) {
  3. return entityMap[a];
  4. });
  5. }
  6. function updateBotCount(a, b) {
  7. Singa.localBotsAlive[a] = b;
  8. var c = Singa.serverBots;
  9. var d = 5 + Singa.serverBots;
  10. var e = 0;
  11. for (;e < 2;e++) {
  12. if (Singa.localBotsAlive[e]) {
  13. c++;
  14. }
  15. }
  16. if (0 == c) {
  17. $("#botCount").html('<font color="red">0 / ' + d + "</font>");
  18. } else {
  19. $("#botCount").html('<font color="#7FFF00">' + "60" + " / " + "60" + "</font>");
  20. }
  21. }
  22. function startLocalBots() {
  23. var a$$0 = 0;
  24. for (;a$$0 < Singa.startBotAmount;a$$0++) {
  25. Singa.localBotsAlive[a$$0] = false;
  26. Singa.localBots[a$$0] = new Worker(URL.createObjectURL(new Blob(["(" + generateBotFunction() + ")()"], {
  27. type : "text/javascript"
  28. })));
  29. Singa.localBots[a$$0].onmessage = function(a) {
  30. var b = a.data;
  31. switch(b.name) {
  32. case "add":
  33. updateBotCount(b.botID, true);
  34. addBallToMinimap(true, "bot" + b.botID, b.botName, b.x, b.y, "#FF00FF", true);
  35. break;
  36. case "remove":
  37. updateBotCount(b.botID, false);
  38. removeBallFromMinimap("bot" + b.botID);
  39. break;
  40. case "position":
  41. moveBallOnMinimap("bot" + b.botID, b.x, b.y);
  42. break;
  43. default:
  44. console.log("Unknown command received from bot");
  45. }
  46. };
  47. Singa.localBots[a$$0].postMessage({
  48. name : "botID",
  49. botID : a$$0
  50. });
  51. }
  52. updateBotNames();
  53. }
  54. function startRemoteBots() {
  55. var a = 0;
  56. for (;a < 3;a++) {
  57. Singa.remoteBots[a] = new Worker(URL.createObjectURL(new Blob(["(" + generateBotFunction() + ")()"], {
  58. type : "text/javascript"
  59. })));
  60. }
  61. }
  62. function sendLocalBotsMessage(a) {
  63. for (i in Singa.localBots) {
  64. Singa.localBots[i].postMessage(a);
  65. }
  66. }
  67. function sendRemoteBotsMessage(a) {
  68. for (i in Singa.remoteBots) {
  69. Singa.remoteBots[i].postMessage(a);
  70. }
  71. }
  72. function insertCore() {
  73. var f = new XMLHttpRequest;
  74. f.open("GET", "/agario.core.js", true);
  75. f.onload = function() {
  76. var script = f.responseText;
  77. script = replaceNormalFile(script, "if(h.MC&&h.MC.onPlayerSpawn)", "Singa.playerSpawned();if(h.MC&&h.MC.onPlayerSpawn)");
  78. script = replaceNormalFile(script, "if(h.MC&&h.MC.onPlayerDeath)", "Singa.playerDied();if(h.MC&&h.MC.onPlayerDeath)");
  79. script = replaceNormalFile(script, "if(h.MC&&h.MC.onAgarioCoreLoaded)", "Singa.onAgarioCoreLoaded();if(h.MC&&h.MC.onAgarioCoreLoaded)");
  80. script = replaceNormalFile(script, "if(h.MC&&h.MC.onDisconnect)", "Singa.playerDisconnected();if(h.MC&&h.MC.onDisconnect)");
  81. script = replaceNormalFile(script, "connect:function(a){", "connect:function(a){Singa.playerConnected(a);");
  82. script = replaceNormalFile(script, "sendSpectate:function(){", "sendSpectate:function(){Singa.playerSpectated();");
  83. script = replaceNormalFile(script, "sendNick:function(a){", "sendNick:function(a){Singa.updateNickname(a);");
  84. script = replaceNormalFile(script, "setTarget:function(a,b){", "setTarget:function(a,b){if(Singa.stopMovement){a = $('#canvas').width() / 2; b = $('#canvas').height() / 2;}");
  85. script = replaceRegexFile(script, /(\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);)/i, "$1 if(Singa.setMapCoords){Singa.setMapCoords($3,$5,$7,$9,$2,$8);}");
  86. script = replaceRegexFile(script, /([\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 Singa.playerX=$4; Singa.playerY=$5;");
  87. script = replaceRegexFile(script, /if\((\+\w\[\w>>3\])<1\.0\){/i, "if($1 < Singa.zoomResetValue){");
  88. script = replaceRegexFile(script, /(if\(\w<=)(20\.0)(\){\w=\w;return})(if\(!\w\){if\(\(\w\[\d+\]\|0\)!=\(\w\[\d+\]\|0\)\){\w=\w;return}if\(\(\w\[\w\+\d+>>0\]\|0\)!=0\?\(\w\[\w>>0\]\|0\)==0:0\){\w=\w;return}})/i, "$140.0$3");
  89. script = replaceRegexFile(script, /(\w)(=\+\w\[\w>>3\]\*\+\w\()(.\d)(,\+\w\);)/i, "$1$2 (Singa.zoomSpeedValue||0.9) $4 Singa.zoomValue=$1;");
  90. script = replaceRegexFile(script, /(\w=\w\[\w>>2\]\|0;)((\w\[\w>>3\])=(\w);)(\w\[\w>>0\]=a\[\w>>0\];)/i, "$1 if(!Singa.autoZoom){$3 = Singa.zoomValue;}else{$2}$5");
  91. script = replaceRegexFile(script, /((\w)=(\+\(\(\w\[\w\+\d+>>\d.*;)(\w)=(\+\(\(\w\[.*\/2\|\d\)\|0\)\/\w\+\s\+\w\[\w\+\d+>>3\];).*\4=\4<\w\?\w:\w;)/, "Singa.mouseX = $3 Singa.mouseY = $5 $1");
  92. eval(script);
  93. };
  94. f.send();
  95. }
  96. function MinimapBall(a, b, c, d, e, f) {
  97. this.isDefault = a;
  98. this.name = b;
  99. this.x = c;
  100. this.y = d;
  101. this.lastX = c;
  102. this.lastY = d;
  103. this.color = e;
  104. this.visible = f;
  105. }
  106. function drawMinimap() {
  107. if (null != miniMap ? minimapCtx.clearRect(0, 0, 200, 200) : (miniMap = document.getElementById("minimap"), minimapCtx = miniMap.getContext("2d"), miniMap.width = 400, miniMap.height = 400, miniMap.style.width = "200px", miniMap.style.height = "200px", minimapCtx.scale(2, 2)), Singa.mapOffsetFixed && Singa.drawMinimap) {
  108. minimapCtx.globalAlpha = 0.4;
  109. minimapCtx.fillStyle = "#000000";
  110. minimapCtx.fillRect(0, 0, miniMap.width, miniMap.height);
  111. var a = 200 / Singa.mapSize;
  112. var b = 200 / Singa.mapSize;
  113. minimapCtx.globalAlpha = 1;
  114. for (ball in minimapBalls) {
  115. minimapBalls[ball].draw(minimapCtx, a, b);
  116. }
  117. }
  118. }
  119. function resetMinimap() {
  120. for (ball in minimapBalls) {
  121. if (!minimapBalls[ball].isDefault) {
  122. delete minimapBalls[ball];
  123. }
  124. }
  125. }
  126. function addBallToMinimap(a, b, c, d, e, f, g) {
  127. minimapBalls[b] = new MinimapBall(a, c, d, e, f, g);
  128. }
  129. function removeBallFromMinimap(a) {
  130. if (minimapBalls[a]) {
  131. delete minimapBalls[a];
  132. }
  133. }
  134. function moveBallOnMinimap(a, b, c) {
  135. if (minimapBalls[a]) {
  136. minimapBalls[a].x = b;
  137. minimapBalls[a].y = c;
  138. }
  139. }
  140. function setBallVisible(a, b) {
  141. if (minimapBalls[a]) {
  142. minimapBalls[a].visible = b;
  143. }
  144. }
  145. function changeNicknameOnBall(a, b) {
  146. if (minimapBalls[a]) {
  147. minimapBalls[a].name = b;
  148. }
  149. }
  150. function replaceRegexFile(a, b, c) {
  151. var d = new RegExp(b);
  152. return d.test(a) ? a = a.replace(b, c) : console.log("[Failed] to replace: " + b), a;
  153. }
  154. function replaceNormalFile(a, b, c) {
  155. return a.indexOf(b) != -1 ? a = a.replace(b, c) : console.log("[Failed] to replace: " + b), a;
  156. }
  157. function sendCommand(a) {
  158. if (null != socket) {
  159. if (socket.connected) {
  160. socket.emit("command", a);
  161. }
  162. }
  163. }
  164. function connectToSingaServer() {
  165. socket = io.connect("ws://52.62.86.95:8000", {
  166. reconnection : true,
  167. query : "key=" + client_uuid
  168. });
  169. socket.on("command", function(a) {
  170. if (void 0 === a.name) {
  171. return void console.log("Recieved a command with no name.");
  172. }
  173. switch(a.name) {
  174. case "force-update":
  175. resetMinimap();
  176. transmit_current_server(true);
  177. if (Singa.isAlive) {
  178. sendCommand({
  179. name : "alive",
  180. playerName : Singa.playerName
  181. });
  182. }
  183. break;
  184. case "add":
  185. addBallToMinimap(false, a.socketID, a.playerName, a.x, a.y, "#FFFFFF", true);
  186. break;
  187. case "remove":
  188. removeBallFromMinimap(a.socketID);
  189. break;
  190. case "position":
  191. moveBallOnMinimap(a.socketID, a.x, a.y);
  192. break;
  193. case "count":
  194. Singa.serverBots = a.count;
  195. break;
  196. case "auth":
  197. Singa.isAuthorized = false;
  198. console.log("Your client is authorized for use of more bots.");
  199. break;
  200. default:
  201. return void console.log("Received a command with an unknown name: " + a.name);
  202. }
  203. });
  204. socket.on("bots", function(a) {
  205. if ("server" == a.name) {
  206. Singa.remoteBotsServer = a.server;
  207. }
  208. sendRemoteBotsMessage(a);
  209. });
  210. socket.on("disconnect", function() {
  211. resetMinimap();
  212. sendRemoteBotsMessage({
  213. name : "disconnect"
  214. });
  215. });
  216. }
  217. function updateBotNames() {
  218. sendLocalBotsMessage({
  219. name : "names",
  220. botNames : Singa.botNames
  221. });
  222. if (Singa.isAuthorized) {
  223. sendCommand({
  224. name : "names",
  225. botNames : Singa.botNames
  226. });
  227. }
  228. }
  229. function validateNames(a) {
  230. if (void 0 === a) {
  231. return null;
  232. }
  233. if (a.indexOf(",") > -1) {
  234. var b = a.split(",");
  235. for (name in b) {
  236. if (b[name].length <= 0 || b[name].length > 15) {
  237. return null;
  238. }
  239. }
  240. return b;
  241. }
  242. return a.length > 0 && a.length <= 15 ? [a] : null;
  243. }
  244. function emitSplit() {
  245. if (Singa.isAuthorized) {
  246. sendCommand({
  247. name : "split"
  248. });
  249. }
  250. sendLocalBotsMessage({
  251. name : "split"
  252. });
  253. }
  254. function emitMassEject() {
  255. if (Singa.isAuthorized) {
  256. sendCommand({
  257. name : "eject"
  258. });
  259. }
  260. sendLocalBotsMessage({
  261. name : "eject"
  262. });
  263. }
  264. function emitLocalPosition() {
  265. var a = Singa.mouseX;
  266. var b = Singa.mouseY;
  267. if (!Singa.moveToMouse) {
  268. a = Singa.playerX;
  269. b = Singa.playerY;
  270. }
  271. sendLocalBotsMessage({
  272. name : "position",
  273. x : a + Singa.mapOffsetX,
  274. y : b + Singa.mapOffsetY
  275. });
  276. }
  277. function emitPosition() {
  278. var a = Singa.mouseX;
  279. var b = Singa.mouseY;
  280. if (!Singa.moveToMouse) {
  281. a = Singa.playerX;
  282. b = Singa.playerY;
  283. }
  284. sendCommand({
  285. name : "position",
  286. x : Singa.realPlayerX,
  287. y : Singa.realPlayerY,
  288. botX : a + Singa.mapOffsetX,
  289. botY : b + Singa.mapOffsetY
  290. });
  291. }
  292. function transmit_current_server(a) {
  293. if (a || last_transmited_game_server != Singa.server) {
  294. last_transmited_game_server = Singa.server;
  295. sendCommand({
  296. name : "servers",
  297. server : last_transmited_game_server
  298. });
  299. }
  300. }
  301. function generateBotFunction() {
  302. return function() {
  303. function replaceRegexFile(a, b, c) {
  304. var d = new RegExp(b);
  305. return d.test(a) ? a = a.replace(b, c) : console.log("[Failed] to replace: " + b), a;
  306. }
  307. function replaceNormalFile(a, b, c) {
  308. return a.indexOf(b) != -1 ? a = a.replace(b, c) : console.log("[Failed] to replace: " + b), a;
  309. }
  310. function getRandomInt(a, b) {
  311. return Math.floor(Math.random() * (b - a + 1)) + a;
  312. }
  313. function getBotCore() {
  314. var e = new XMLHttpRequest;
  315. e.open("GET", "http://agar.io/agario.core.js", true);
  316. e.onload = function() {
  317. var script = e.responseText;
  318. script = replaceRegexFile(script, /\w+\.location\.hostname/g, '"agar.io"');
  319. script = replaceNormalFile(script, "window", "self");
  320. script = replaceNormalFile(script, "c.setStatus=function(a){console.log(a)};", "c.setStatus=function(a){};");
  321. script = replaceNormalFile(script, 'console.log("postRun");', "");
  322. script = replaceRegexFile(script, /(\w)=\+\(\(\w\[\w\+\d+>>\d.*;(\w)=\+\(\(\w\[.*\/2\|\d\)\|0\)\/\w\+\s\+\w\[\w\+\d+>>3\];/, "$1 = Singa.newX; $2 = Singa.newY;");
  323. script = replaceNormalFile(script, "if(h.MC&&h.MC.onPlayerSpawn)", "Singa.playerSpawned();if(h.MC&&h.MC.onPlayerSpawn)");
  324. script = replaceNormalFile(script, "if(h.MC&&h.MC.onPlayerDeath)", "Singa.playerDied();if(h.MC&&h.MC.onPlayerDeath)");
  325. script = replaceNormalFile(script, "if(h.MC&&h.MC.onAgarioCoreLoaded)", "Singa.onAgarioCoreLoaded();if(h.MC&&h.MC.onAgarioCoreLoaded)");
  326. script = replaceNormalFile(script, "if(h.MC&&h.MC.onDisconnect)", "Singa.playerDisconnected();if(h.MC&&h.MC.onDisconnect)");
  327. script = replaceNormalFile(script, "h.MC&&h.MC.corePendingReload", "Singa.reloadCore();h.MC&&h.MC.corePendingReload");
  328. script = replaceRegexFile(script, /(\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);)/i, "$1 if(Singa.setMapCoords){Singa.setMapCoords($3,$5,$7,$9,$2,$8);}");
  329. script = replaceRegexFile(script, /([\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 Singa.playerX=$4; Singa.playerY=$5; Singa.setPath();");
  330. script = replaceRegexFile(script, /(do\sif\(\w\){)((\w)=!\(\+\w\[\w>>2]<=20.0\);)(.+,\w\[\w>>2\]\|0,(\+\(\+\w\[\w>>2\]\)),(\+\(\+\w\[\w>>2\]\)),\+\((\+\w\[\w>>2\]))/, "$1var cellSize=$7;$2if(!$3){Singa.recordPellet($5,$6,cellSize);}$4");
  331. eval(script);
  332. };
  333. e.send(null);
  334. }
  335. self.innerWidth = 1;
  336. self.innerHeight = 1;
  337. const window = {};
  338. elementMock = {
  339. getContext : function() {
  340. return{
  341. canvas : {
  342. width : 1,
  343. height : 1
  344. },
  345. clearRect : function() {
  346. },
  347. save : function() {
  348. },
  349. translate : function() {
  350. },
  351. scale : function() {
  352. },
  353. stroke : function() {
  354. },
  355. arc : function() {
  356. },
  357. fill : function() {
  358. },
  359. moveTo : function() {
  360. },
  361. lineTo : function() {
  362. },
  363. closePath : function() {
  364. },
  365. beginPath : function() {
  366. },
  367. restore : function() {
  368. },
  369. fillRect : function() {
  370. },
  371. measureText : function() {
  372. return{};
  373. },
  374. strokeText : function() {
  375. },
  376. fillText : function() {
  377. },
  378. drawImage : function() {
  379. }
  380. };
  381. },
  382. innerText : "",
  383. div : {
  384. appendChild : function() {
  385. }
  386. },
  387. appendChild : function() {
  388. },
  389. style : {}
  390. };
  391. document = {
  392. getElementById : function() {
  393. return elementMock;
  394. },
  395. createElement : function(a) {
  396. return elementMock;
  397. },
  398. body : {
  399. firstChild : {},
  400. insertBefore : function() {
  401. }
  402. }
  403. };
  404. Image = function() {
  405. };
  406. self.Singa = {
  407. server : null,
  408. botID : 0,
  409. botName : "BFAgar Bots",
  410. playerX : 0,
  411. playerY : 0,
  412. newX : 0,
  413. newY : 0,
  414. realPlayerX : null,
  415. realPlayerY : null,
  416. mapOffset : 7071,
  417. mapOffsetX : 0,
  418. mapOffsetY : 0,
  419. mapOffsetFixed : false,
  420. collectPellets : false,
  421. pelletTargetX : 99999,
  422. pelletTargetY : 99999,
  423. pellets : [],
  424. recordPellet : function(a, b, c) {
  425. this.pellets.push({
  426. x : a,
  427. y : b,
  428. size : c
  429. });
  430. },
  431. setMapCoords : function(a, b, c, d, e, f) {
  432. if (f - e == 24) {
  433. if (c - a > 14E3) {
  434. if (d - b > 14E3) {
  435. this.mapOffsetX = this.mapOffset - c;
  436. this.mapOffsetY = this.mapOffset - d;
  437. this.mapOffsetFixed = true;
  438. }
  439. }
  440. }
  441. },
  442. playerDied : function() {
  443. postMessage({
  444. name : "remove",
  445. botID : Singa.botID
  446. });
  447. },
  448. playerSpawned : function() {
  449. postMessage({
  450. name : "add",
  451. botID : Singa.botID,
  452. botName : Singa.botName,
  453. x : Singa.realPlayerX,
  454. y : Singa.realPlayerY
  455. });
  456. },
  457. playerDisconnected : function() {
  458. postMessage({
  459. name : "remove",
  460. botID : Singa.botID
  461. });
  462. if (self.core) {
  463. if (null != Singa.server) {
  464. core.connect(Singa.server);
  465. }
  466. }
  467. },
  468. reloadCore : function() {
  469. if (self.core) {
  470. self.core.destroy();
  471. }
  472. getBotCore();
  473. },
  474. onAgarioCoreLoaded : function() {
  475. if (self.core) {
  476. if (null != Singa.server) {
  477. core.connect(Singa.server);
  478. }
  479. }
  480. },
  481. setPath : function() {
  482. var a = -1;
  483. var b = 0;
  484. var c = 0;
  485. for (;c < this.pellets.length;c++) {
  486. var d = this.getDistanceBetweenPositions(this.pellets[c].x, this.pellets[c].y, this.playerX, this.playerY);
  487. if (!(a != -1 && d > b)) {
  488. a = c;
  489. b = d;
  490. }
  491. }
  492. if (a == -1) {
  493. this.pelletTargetX = 99999;
  494. this.pelletTargetY = 99999;
  495. } else {
  496. this.pelletTargetX = this.pellets[a].x;
  497. this.pelletTargetY = this.pellets[a].y;
  498. }
  499. this.pellets = [];
  500. },
  501. getDistanceBetweenPositions : function(a, b, c, d) {
  502. return Math.sqrt(Math.pow(c - a, 2) + Math.pow(b - d, 2));
  503. }
  504. };
  505. onmessage = function(a) {
  506. var b = a.data;
  507. switch(b.name) {
  508. case "botID":
  509. Singa.botID = b.botID;
  510. break;
  511. case "server":
  512. Singa.server = b.server;
  513. if (self.core) {
  514. if (null != b.server) {
  515. core.connect(b.server);
  516. }
  517. }
  518. break;
  519. case "position":
  520. if (Singa.collectPellets && (99999 != Singa.pelletTargetX && 99999 != Singa.pelletTargetY)) {
  521. Singa.newX = Singa.pelletTargetX;
  522. Singa.newY = Singa.pelletTargetY;
  523. } else {
  524. Singa.newX = b.x - Singa.mapOffsetX;
  525. Singa.newY = b.y - Singa.mapOffsetY;
  526. }
  527. break;
  528. case "split":
  529. if (self.core) {
  530. core.split();
  531. }
  532. break;
  533. case "eject":
  534. if (self.core) {
  535. core.eject();
  536. }
  537. break;
  538. case "names":
  539. if (null == b.botNames) {
  540. Singa.botName = "NickBots";
  541. break;
  542. }
  543. Singa.botName = b.botNames[getRandomInt(0, b.botNames.length - 1)];
  544. break;
  545. case "disconnect":
  546. Singa.server = null;
  547. if (self.core) {
  548. core.disconnect();
  549. }
  550. break;
  551. case "collectPellets":
  552. Singa.collectPellets = b.collectPellets;
  553. break;
  554. default:
  555. console.log("Unknown message received.");
  556. }
  557. };
  558. setInterval(function() {
  559. Singa.realPlayerX = Singa.mapOffsetX + Singa.playerX;
  560. Singa.realPlayerY = Singa.mapOffsetY + Singa.playerY;
  561. postMessage({
  562. botID : Singa.botID,
  563. name : "position",
  564. x : Singa.realPlayerX,
  565. y : Singa.realPlayerY
  566. });
  567. if (self.core) {
  568. core.sendNick(Singa.botName);
  569. }
  570. }, 100);
  571. getBotCore();
  572. }.toString();
  573. }
  574. window.history.replaceState("", "", "/" + location.hash), window.getTextWidth = function(a, b) {
  575. var c = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
  576. var d = c.getContext("2d");
  577. d.font = b;
  578. var e = d.measureText(a);
  579. return e.width;
  580. };
  581. var entityMap = {
  582. "&" : "&amp;",
  583. "<" : "&lt;",
  584. ">" : "&gt;",
  585. '"' : "&quot;",
  586. "'" : "&#39;",
  587. "/" : "&#x2F;"
  588. };
  589. var client_uuid = escapeHtml(localStorage.getItem("singa_uuid"));
  590. if (null === client_uuid || 15 != client_uuid.length) {
  591. client_uuid = "";
  592. var ranStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  593. var ii = 0;
  594. for (;ii < 15;ii++) {
  595. client_uuid += ranStr.charAt(Math.floor(Math.random() * ranStr.length));
  596. }
  597. localStorage.setItem("singa_uuid", client_uuid);
  598. }
  599. window.Singa = {
  600. server : null,
  601. playerName : "BFAgar",
  602. startBotAmount: 36,
  603. playerX : 0,
  604. playerY : 0,
  605. mouseX : 0,
  606. mouseY : 0,
  607. realPlayerX : null,
  608. realPlayerY : null,
  609. mapSize : 14142,
  610. mapOffset : 7071,
  611. mapOffsetX : 0,
  612. mapOffsetY : 0,
  613. mapOffsetFixed : false,
  614. zoomValue : 1,
  615. zoomResetValue : 0,
  616. zoomSpeedValue : 0.9,
  617. autoZoom : true,
  618. stopMovement : false,
  619. isAlive : false,
  620. moveToMouse : true,
  621. localBots : {},
  622. localBotsAlive : {},
  623. remoteBotsServer : null,
  624. remoteBots : {},
  625. remoteBotsAlive : {},
  626. leaderboardData : "",
  627. serverBots : 36,
  628. isAuthorized : false,
  629. drawMinimap : true,
  630. setMapCoords : function(a, b, c, d, e, f) {
  631. if (f - e == 24) {
  632. if (c - a > 14E3) {
  633. if (d - b > 14E3) {
  634. this.mapOffsetX = this.mapOffset - c;
  635. this.mapOffsetY = this.mapOffset - d;
  636. this.mapOffsetFixed = true;
  637. }
  638. }
  639. }
  640. },
  641. playerDied : function() {
  642. Singa.isAlive = false;
  643. moveBallOnMinimap("player_death", this.realPlayerX, this.realPlayerY);
  644. setBallVisible("player_pointer", false);
  645. setBallVisible("player_death", true);
  646. sendCommand({
  647. name : "dead"
  648. });
  649. },
  650. playerSpawned : function() {
  651. Singa.isAlive = true;
  652. changeNicknameOnBall("player_pointer", Singa.playerName);
  653. setBallVisible("player_spectate", false);
  654. setBallVisible("player_pointer", true);
  655. sendCommand({
  656. name : "alive",
  657. playerName : Singa.playerName
  658. });
  659. },
  660. playerConnected : function(a) {
  661. resetMinimap();
  662. if (null != this.remoteBotsServer) {
  663. if (this.remoteBotsServer == a) {
  664. sendRemoteBotsMessage({
  665. name : "disconnect"
  666. });
  667. }
  668. }
  669. Singa.server = a;
  670. console.log("Connecting to: " + a);
  671. setBallVisible("player_pointer", false);
  672. setBallVisible("player_death", false);
  673. setBallVisible("player_spectate", false);
  674. sendLocalBotsMessage({
  675. name : "server",
  676. server : a
  677. });
  678. },
  679. playerDisconnected : function() {
  680. resetMinimap();
  681. sendCommand({
  682. name : "dead"
  683. });
  684. setBallVisible("player_pointer", false);
  685. setBallVisible("player_death", false);
  686. setBallVisible("player_spectate", false);
  687. Singa.server = null;
  688. Singa.isAlive = false;
  689. },
  690. playerSpectated : function() {
  691. setBallVisible("player_pointer", false);
  692. setBallVisible("player_spectate", true);
  693. sendCommand({
  694. name : "dead"
  695. });
  696. },
  697. updateNickname : function(a) {
  698. this.playerName = a;
  699. },
  700. loadCore : function() {
  701. setTimeout(function() {
  702. startLocalBots();
  703. startRemoteBots();
  704. }, 2E3);
  705. console.log("Loading core.");
  706. var b$$0 = (document.getElementById("canvas"), localStorage.getItem("botnames"));
  707. if (null !== b$$0) {
  708. Singa.botNames = validateNames(b$$0);
  709. if (null !== Singa.botNames) {
  710. $("#botnames").val(b$$0);
  711. }
  712. updateBotNames();
  713. }
  714. $("#botnames").on("input", function() {
  715. var a = $("#botnames").val();
  716. var b = validateNames(a);
  717. Singa.botNames = b;
  718. updateBotNames();
  719. if (null !== b) {
  720. localStorage.setItem("botnames", a);
  721. }
  722. });
  723. $("#leaderboardcopy").click(function(a) {
  724. var b = $("#leaderboard")[0];
  725. b.setSelectionRange(0, b.value.length);
  726. b.select();
  727. try {
  728. document.execCommand("copy");
  729. } catch (a$$0) {
  730. console.log("Failed to copy leaderboard.");
  731. }
  732. });
  733. $("#uuidcopy").click(function(a) {
  734. var b = $("#uuid")[0];
  735. b.setSelectionRange(0, b.value.length);
  736. b.select();
  737. try {
  738. document.execCommand("copy");
  739. } catch (a$$0) {
  740. console.log("Failed to copy uuid.");
  741. }
  742. });
  743. var c;
  744. var d = false;
  745. var f$$0 = false;
  746. $(document).keydown(function(a) {
  747. switch(a.which) {
  748. case 65:
  749. Singa.moveToMouse = !Singa.moveToMouse;
  750. if (Singa.moveToMouse) {
  751. $("#ismoveToMouse").html("<font color='#7FFF00'>On</font>");
  752. } else {
  753. $("#ismoveToMouse").html("<font color='red'>Off</font>");
  754. }
  755. break;
  756. case 68:
  757. Singa.stopMovement = !Singa.stopMovement;
  758. if (Singa.stopMovement) {
  759. $("#isStopMove").html("<font color='#7FFF00'>On</font>");
  760. } else {
  761. $("#isStopMove").html("<font color='red'>Off</font>");
  762. }
  763. break;
  764. case 69:
  765. emitSplit();
  766. break;
  767. case 82:
  768. emitMassEject();
  769. break;
  770. case 77:
  771. Singa.drawMinimap = !Singa.drawMinimap;
  772. if (Singa.drawMinimap) {
  773. $("#botcanvas").show();
  774. } else {
  775. $("#botcanvas").hide();
  776. }
  777. break;
  778. case 80:
  779. f$$0 = !f$$0;
  780. if (f$$0) {
  781. $("#collectPellets").html("<font color='#7FFF00'>On</font>");
  782. } else {
  783. $("#collectPellets").html("<font color='red'>Off</font>");
  784. }
  785. sendLocalBotsMessage({
  786. name : "collectPellets",
  787. collectPellets : f$$0
  788. });
  789. if (Singa.isAuthorized) {
  790. sendCommand({
  791. name : "collectPellets",
  792. collectPellets : f$$0
  793. });
  794. }
  795. break;
  796. case 87:
  797. if (d) {
  798. return;
  799. }
  800. d = true;
  801. c = setInterval(function() {
  802. core.eject();
  803. }, 50);
  804. }
  805. });
  806. $(document).keyup(function(a) {
  807. switch(a.which) {
  808. case 87:
  809. d = false;
  810. clearInterval(c);
  811. break;
  812. case 84:
  813. var b = 0;
  814. var e = setInterval(function() {
  815. return b > 7 ? void clearInterval(e) : (b++, void core.split());
  816. }, 50);
  817. break;
  818. case 81:
  819. var f = 0;
  820. var g = setInterval(function() {
  821. return f > 1 ? void clearInterval(g) : (f++, void core.split());
  822. }, 50);
  823. }
  824. });
  825. addBallToMinimap(true, "player_pointer", Singa.playerName, Singa.realPlayerX, Singa.realPlayerY, "#00FF00", false);
  826. addBallToMinimap(true, "player_death", "Last Death", Singa.realPlayerX, Singa.realPlayerY, "#FF2400", false);
  827. addBallToMinimap(true, "player_spectate", "Spectate", Singa.realPlayerX, Singa.realPlayerY, "#0000FF", false);
  828. connectToSingaServer();
  829. insertCore();
  830. setInterval(function() {
  831. MC.singaFreeCoins();
  832. }, 5E3);
  833. setInterval(function() {
  834. drawMinimap();
  835. }, 33);
  836. },
  837. reloadCore : function() {
  838. console.log("Reloading Core.");
  839. insertCore();
  840. },
  841. onAgarioCoreLoaded : function() {
  842. console.log("Loading settings into agario core.");
  843. core.setSkins(!$("#noSkins").is(":checked"));
  844. core.setNames(!$("#noNames").is(":checked"));
  845. core.setColors(!$("#noColors").is(":checked"));
  846. core.setShowMass($("#showMass").is(":checked"));
  847. core.setDarkTheme($("#darkTheme").is(":checked"));
  848. }
  849. };
  850. var tempLeaderBoard = "";
  851. var tempLeaderBoardIndex = 1;
  852. CanvasRenderingContext2D.prototype._fillText = CanvasRenderingContext2D.prototype.fillText, CanvasRenderingContext2D.prototype.fillText = function() {
  853. this._fillText.apply(this, arguments);
  854. if ("Leaderboard" === arguments[0]) {
  855. if ("" != tempLeaderBoard) {
  856. Singa.leaderboardData = tempLeaderBoard;
  857. $("#leaderboard").val(Singa.leaderboardData);
  858. }
  859. tempLeaderBoardIndex = 1;
  860. tempLeaderBoard = "";
  861. } else {
  862. if (":teams" != $("#gamemode").val() && (0 == arguments[0].indexOf(tempLeaderBoardIndex + ".") && tempLeaderBoardIndex < 11)) {
  863. tempLeaderBoard += arguments[0] + (tempLeaderBoardIndex <= 9 ? ", " : "");
  864. tempLeaderBoardIndex++;
  865. } else {
  866. this._fillText.apply(this, arguments);
  867. }
  868. }
  869. }, CanvasRenderingContext2D.prototype._drawImage = CanvasRenderingContext2D.prototype.drawImage, CanvasRenderingContext2D.prototype.drawImage = function() {
  870. if (arguments[0].src) {
  871. if ("http://agar.io/img/background.png" == arguments[0].src) {
  872. arguments[0].src = "";
  873. }
  874. }
  875. this._drawImage.apply(this, arguments);
  876. };
  877. var miniMap = null;
  878. var minimapCtx = null;
  879. minimapBalls = {}, MinimapBall.prototype = {
  880. draw : function(a, b, c) {
  881. if (this.visible) {
  882. this.lastX = (29 * this.lastX + this.x) / 30;
  883. this.lastY = (29 * this.lastY + this.y) / 30;
  884. var d = ((this.isDefault ? this.x : this.lastX) + Singa.mapOffset) * b;
  885. var e = ((this.isDefault ? this.y : this.lastY) + Singa.mapOffset) * c;
  886. a.fillStyle = this.color;
  887. a.font = "10px Ubuntu";
  888. a.textAlign = "center";
  889. a.fillText("" == this.name ? "An unnamed cell" : this.name, d, e - 10);
  890. a.beginPath();
  891. a.arc(d, e, 4.5, 0, 2 * Math.PI, false);
  892. a.closePath();
  893. a.fillStyle = this.color;
  894. a.fill();
  895. }
  896. }
  897. };
  898. var b = new XMLHttpRequest;
  899. b.open("GET", "/mc/agario.js", true), b.onload = function() {
  900. var script = b.responseText;
  901. script = replaceNormalFile(script, 'if(js.keyCode==32&&i1!="nick"){js.preventDefault()}', "");
  902. script = replaceNormalFile(script, "showAds:function(i){if", "showAds:function(i){},showFuck:function(i){if");
  903. script = replaceNormalFile(script, "showPromoBadge:function(", "showPromoBadge:function(i){},fuckbacks: function(");
  904. script = replaceRegexFile(script, /(return\s\w+.tab.toUpperCase\(\)).indexOf\(\w+.toUpperCase\(\)\)!=-1/, "$1 != 'VETERAN'");
  905. script = replaceRegexFile(script, /if\(\w+.shouldSkipConfigEntry\(\w+.productIdToQuantify.*visibility\)\)\{continue\}/, "");
  906. script = replaceNormalFile(script, "if(this.getSkinsByCategory(i1.tabDescription).length>0", 'if (this.getSkinsByCategory(i1.tabDescription).length > 0 && (i1.tabDescription.toUpperCase() == "PREMIUM" || i1.tabDescription.toUpperCase() == "VETERAN" || i1.tabDescription.toUpperCase() == "OWNED")');
  907. script = replaceRegexFile(script, /var\si2=window.document.createElement..script..+head.appendChild.i2../i, "Singa.reloadCore();");
  908. script = replaceRegexFile(script, /(showFreeCoins:function\(\)\{var.*showContainer\(\);if\(([a-zA-Z0-9]+[a-zA-Z0-9]+.user.userInfo==null).*false\);([a-zA-Z0-9]+[a-zA-Z0-9]+.triggerFreeCoins\(\)).*this.onShopClose\)\)\}},)/, "$1 singaFreeCoins: function(){if($2){return;}$3;},");
  909. script = replaceNormalFile(script, "onPlayerBanned:function(i)", "onPlayerBanned: function(i){},shitfacefuck:function(i)");
  910. script = replaceNormalFile(script, "setPopupActiveState:function(i){", "setPopupActiveState:function(i){console.log('stopped annoying ad');return;");
  911. eval(script);
  912. var e = new XMLHttpRequest;
  913. e.open("GET", "/", true);
  914. e.onload = function() {
  915. var a = e.responseText;
  916. a = replaceNormalFile(a, "UCC6hurPo_LxL7C0YFYgYnIw", "UCsuDSwIvD_VpX5EOrc39uow");
  917. a = replaceRegexFile(a, /<footer[\S\s]*\/footer>/i, "");
  918. a = replaceNormalFile(a, '<script src="agario.core.js" async>\x3c/script>', "<div id='botcanvas' style='background:rgba(0,0,0,0.4); width: 200px; top: 5px; left: 9px; display: block; position: absolute; text-align: center; font-size: 15px; color: #ffffff; padding: 5px; font-family: Impact;'> <font color='#7FFF00'>BFAgar</font><br>Bots: <a id='botCount'><font color='red'>0 / 25</font></a><br><font color='#FFFFFF'>A</font> - Move To Mouse: <a id='ismoveToMouse'><font color='#7FFF00'>On</font></a><br><font color='#FFFFFF'>P</font> - Collect Pellets: <a id='collectPellets'><font color='red'>Off</font></a><br><font color='#FFFFFF'>D</font> - Stop Movement: <a id='isStopMove'><font color='red'>Off</font></a></div>");
  919. a = replaceNormalFile(a, "<body>", '<body onload="Singa.loadCore()">');
  920. a = replaceRegexFile(a, /<script type="text\/javascript" src="mc\/agario\.js.*"><\/script>/i, "");
  921. a = replaceRegexFile(a, /<div id="adsBottom".*display:block;">/i, '<div id="adsBottom" style="display:none">');
  922. a = replaceNormalFile(a, '<div class="diep-cross" style="', '<div class="diep-cross" style="display:none;');
  923. a = replaceNormalFile(a, '<div id="promo-badge-container">', '<div id="promo-badge-container" style="display:none;">');
  924. a = replaceNormalFile(a, '<span data-itr="page_instructions_w"></span><br/>', '<span data-itr="page_instructions_w"></span><br/><span>Press <b>Q</b> to double split</span><br><span>Hold <b>W</b> to rapid fire mass</span><br><span>Press <b>M</b> to hide/show the minimap</span><br><span>Press <b>E</b> to split bots</span><br><span>Press <b>R</b> to eject some bots mass</span><br><span>Press <b>P</b> to make bots collect pellets</span>');
  925. a = replaceNormalFile(a, '<div id="tags-container">', '<div id="leaders" class="input-group" style="margin-top: 6px;"><span class="input-group-addon" style="width:75px"id="basic-addon1">BOARD</span><input id="leaderboard" type="text" value="" style="width:185px" readonly class="form-control"><button id="leaderboardcopy" class="btn btn-primary" style="float: right; width: 60px; border-radius: 0px 4px 4px 0px;" data-original-title="" title="">Copy</button></div><div class="input-group" style="margin-top: 6px;"><span class="input-group-addon" style="width:75px"id="basic-addon1">UUID</span><input id="uuid" type="text" value="' +
  926. client_uuid + '" style="width:185px" readonly class="form-control"><button id="uuidcopy" class="btn btn-primary" style="float: right; width: 60px; border-radius: 0px 4px 4px 0px;" data-original-title="" title="">Copy</button></div><div class="input-group" style="margin-top: 6px;"><span class="input-group-addon" style="width:75px" id="basic-addon1">NAMES</span><input id="botnames" class="form-control" style="width:245px" placeholder="Separate bot names using commas" autofocus=""></div><div id="tags-container">');
  927. a = replaceNormalFile(a, "</body>", '<div style="display:block;position:absolute;z-index:100;pointer-events:none;right:9px;bottom:9px;"><canvas id="minimap"></div></body>');
  928. document.open();
  929. document.write(a);
  930. document.close();
  931. };
  932. e.send();
  933. }, b.send(), setInterval(function() {
  934. Singa.realPlayerX = Singa.mapOffsetX + Singa.playerX;
  935. Singa.realPlayerY = Singa.mapOffsetY + Singa.playerY;
  936. moveBallOnMinimap("player_pointer", Singa.realPlayerX, Singa.realPlayerY);
  937. moveBallOnMinimap("player_spectate", Singa.realPlayerX, Singa.realPlayerY);
  938. }, 50);
  939. var last_transmited_game_server = null;
  940. var socket = null;
  941. setInterval(function() {
  942. if (!Singa.isAuthorized) {
  943. emitPosition();
  944. }
  945. }, 10), setInterval(function() {
  946. if (Singa.isAuthorized) {
  947. emitPosition();
  948. }
  949. emitLocalPosition();
  950. transmit_current_server(false);
  951. }, 10);
  952. window.interval = setInterval(function() {
  953. if (MC.coreWasLoaded == true && $("#nick")[0]) {
  954. clearInterval(interval);
  955. $("#agarTwitter").remove();
  956. $("h2").replaceWith("<h2>BFAgar</h2>");
  957. }
  958. }, 100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement