Advertisement
JOOTAA

Untitled

Jun 11th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.16 KB | None | 0 0
  1. window.agarServer = 'none';
  2. window.started = false;
  3. window.__connected = 'Disconnected';
  4. window.pelletMode = false;
  5. window._ws = null;
  6. window.wobsocket = null;
  7. window._boarders = {};
  8. window.boarders = {};
  9. var mapWidth = 200;
  10. (function() {
  11. 'use strict';
  12. function bufToArray(buf) {
  13. var ab = [];
  14. for (var i = 0; i < buf.byteLength; i++) {
  15. ab.push(buf.getUint8(i, true));
  16. }
  17. return ab;
  18. }
  19. function toArrayBuffer(buf) {
  20. var ab = new ArrayBuffer(buf.length);
  21. var view = new Uint8Array(ab);
  22. for (var i = 0; i < buf.length; ++i) {
  23. view[i] = buf[i];
  24. }
  25. return ab;
  26. }
  27. connect();
  28. function connect() {
  29. window._ws = new WebSocket('wss://' + window.botConfig.botServer + ':8888?origin=' + location.origin + '&token=' + Math.floor(Math.random() * 100000));
  30. window._ws.onclose = onclose;
  31. window._ws.onopen = onopen;
  32. window._ws._send = window._ws.send;
  33. window._ws.send = send;
  34. window._ws.onmessage = onmessage;
  35. //console.log('Connecting!');
  36. }
  37. function onmessage(msg) {
  38. // console.log(msg.data);
  39. try {
  40. msg = JSON.parse(msg.data);
  41. if (msg.count)
  42. $('#count').html(msg.count);
  43. else if (msg.y)
  44. window.boarders = msg;
  45. else if (msg.timeLeft)
  46. timeLeft(msg.timeLeft);
  47. } catch(e) {
  48. try {
  49. msg = msg.data.split(',');
  50. var c = document.getElementById("shotCanvas");
  51. var ctx = c.getContext("2d");
  52. ctx.clearRect(0, 0, c.width, c.height);
  53. drawMap();
  54. for (var i of msg) {
  55. var split = i.split('|'); //x|y|mass
  56. var x = split[0];
  57. var y = split[1];
  58. var size = split[2];
  59. //console.log(`x: ${x}, y: ${y}, x on map: ${getMiniMapCoord(parseInt(x), 200)}, y on map: ${getMiniMapCoord(parseInt(y), 200)}`);
  60. addToMinimap(getMiniMapCoord(parseInt(x), 200), getMiniMapCoord(parseInt(y), 200), size / 50);
  61. }
  62. } catch(e) {}
  63. }
  64. }
  65. function timeLeft(timeleft) {
  66. if (timeleft == 'unlimited')
  67. $('#timeLeft').html('Unlimited');
  68. else
  69. setInterval(() => {
  70. $('#timeLeft').html(timeleft-- + ' seconds');
  71. }, 1000);
  72. }
  73. function onopen() {
  74. // console.log('Connected!');
  75. $('#serverStat').html('Connected');
  76. window.__connected = 'Connected';
  77. let buf = new DataView(new ArrayBuffer(1 + 2 * window.agarServer.length));
  78. let offset = 0;
  79. buf.setUint8(offset++, 3);
  80. for (let i = 0; i < window.agarServer.length; i++) {
  81. buf.setUint16(offset, window.agarServer.charCodeAt(i), true);
  82. offset += 2;
  83. }
  84. window._ws.send(buf);
  85. }
  86. function send(e) {
  87. if (window._ws.readyState === window._ws.OPEN) window._ws._send(e);
  88. }
  89. function onclose(e) {
  90. $('#serverStat').html('Disconnected');
  91. window.__connected = 'Disconnected';
  92. //console.log(e.reason);
  93. if (e.reason !== 'FULL')
  94. connect();
  95. }
  96. if (window.location.origin == "http://agar.bio") {
  97. window.WebSocket.prototype.prototype.realSend = window.WebSocket.prototype.prototype.send;
  98. window.WebSocket.prototype.prototype.send = function(pkt) {
  99. this.realSend(pkt);
  100. if (this.url.indexOf(window.botConfig.botServer) !== -1) return;
  101. if (pkt instanceof ArrayBuffer) pkt = new DataView(pkt);
  102. else if (pkt instanceof DataView) pkt = pkt;
  103. else pkt = new DataView(toArrayBuffer(pkt));
  104. switch (pkt.getUint8(0, true)) {
  105. case 16:
  106. window._ws.send(pkt);
  107. break;
  108. case 254:
  109.  
  110. // console.log(bufToArray(pkt));
  111. window.pkt254 = bufToArray(pkt);
  112. var buf = new DataView(new ArrayBuffer(1 + pkt.byteLength));
  113. buf.setUint8(0, 254);
  114. buf.setUint8(1, pkt.getUint8(0));
  115. //buf.setUint32(pkt.getUint32(1, true), true);
  116. for (var i = 0; i < pkt.byteLength; i++) {
  117. buf.setUint8(i + 1, pkt.getUint8(i));
  118. }
  119. window._ws.send(buf);
  120. break;
  121. case 255:
  122. window.pkt255 = bufToArray(pkt);
  123. //console.log(bufToArray(pkt));
  124. buf = new DataView(new ArrayBuffer(1 + pkt.byteLength));
  125. buf.setUint8(0, 255);
  126. buf.setUint8(1, pkt.getUint8(0));
  127. //buf.setUint32(pkt.getUint32(1, true), true);
  128. for (var i = 0; i < pkt.byteLength; i++) {
  129. buf.setUint8(i + 1, pkt.getUint8(i));
  130. }
  131. window._ws.send(buf);
  132. break;
  133. default:
  134. //console.log(bufToArray(pkt));
  135. }
  136. if (window.agarServer !== this.url) {
  137. window.agarServer = this.url;
  138. let buf = new DataView(new ArrayBuffer(1 + 2 * this.url.length));
  139. let offset = 0;
  140. buf.setUint8(offset++, 3);
  141. for (let i = 0; i < this.url.length; i++) {
  142. buf.setUint16(offset, this.url.charCodeAt(i), true);
  143. offset += 2;
  144. }
  145. window._ws.send(buf);
  146. }
  147. }
  148. } else {
  149. WebSocket.prototype.realSend = WebSocket.prototype.send;
  150. WebSocket.prototype.send = function(pkt) {
  151. this.realSend(pkt);
  152. if (this.url.indexOf(window.botConfig.botServer) !== -1) return;
  153. if (pkt instanceof ArrayBuffer) pkt = new DataView(pkt);
  154. else if (pkt instanceof DataView) pkt = pkt;
  155. else pkt = new DataView(toArrayBuffer(pkt));
  156. switch (pkt.getUint8(0, true)) {
  157. case 16:
  158. window._ws.send(pkt);
  159. break;
  160. case 254:
  161.  
  162. // console.log(bufToArray(pkt));
  163. window.pkt254 = bufToArray(pkt);
  164. var buf = new DataView(new ArrayBuffer(1 + pkt.byteLength));
  165. buf.setUint8(0, 254);
  166. buf.setUint8(1, pkt.getUint8(0));
  167. //buf.setUint32(pkt.getUint32(1, true), true);
  168. for (var i = 0; i < pkt.byteLength; i++) {
  169. buf.setUint8(i + 1, pkt.getUint8(i));
  170. }
  171. window._ws.send(buf);
  172. break;
  173. case 255:
  174. window.pkt255 = bufToArray(pkt);
  175. //console.log(bufToArray(pkt));
  176. buf = new DataView(new ArrayBuffer(1 + pkt.byteLength));
  177. buf.setUint8(0, 255);
  178. buf.setUint8(1, pkt.getUint8(0));
  179. //buf.setUint32(pkt.getUint32(1, true), true);
  180. for (var i = 0; i < pkt.byteLength; i++) {
  181. buf.setUint8(i + 1, pkt.getUint8(i));
  182. }
  183. window._ws.send(buf);
  184. break;
  185. default:
  186. //console.log(bufToArray(pkt));
  187. }
  188. };
  189. var _WebSocket = WebSocket;
  190. WebSocket = function(ip) {
  191. if (ip.indexOf(window.botConfig.botServer) == -1) {
  192. window.agarServer = ip;
  193. let buf = new DataView(new ArrayBuffer(1 + 2 * ip.length));
  194. let offset = 0;
  195. buf.setUint8(offset++, 3);
  196. for (let i = 0; i < ip.length; i++) {
  197. buf.setUint16(offset, ip.charCodeAt(i), true);
  198. offset += 2;
  199. }
  200. window._ws.send(buf);
  201. window.wobsocket = new _WebSocket(ip);
  202. if (location.origin == 'http://agar.pro' || location.origin == 'http://qwoks.ga') overWriteWS();
  203. return window.wobsocket;
  204. } else
  205. return new _WebSocket(ip);
  206. };
  207. }
  208. function isTyping() {
  209. return $("input:focus").length;
  210. }
  211. document.addEventListener('keyup', key => {
  212. key = key.key.toLowerCase();
  213. if (isTyping()) return;
  214. switch (key) {
  215. case window.botConfig.botMassGate.toLowerCase():
  216. window._ws.send(new Uint8Array([5]));
  217. break;
  218. case window.botConfig.botPelletMode.toLowerCase():
  219. window._ws.send(new Uint8Array([4]));
  220. break;
  221. case window.botConfig.botStart.toLowerCase():
  222. if (window.started)
  223. window._ws.send(new Uint8Array([1]));
  224. else
  225. window._ws.send(new Uint8Array([0]));
  226. window.started = !window.started;
  227. break;
  228. }
  229. });
  230. document.addEventListener('keydown', key => {
  231. key = key.key.toLowerCase();
  232. if (isTyping()) return;
  233. switch (key) {
  234. case window.botConfig.botSplit.toLowerCase():
  235. window._ws.send(new Uint8Array([2, 0]));
  236. break;
  237. case window.botConfig.botFeed.toLowerCase():
  238. window._ws.send(new Uint8Array([2, 1]));
  239. break;
  240. }
  241. });
  242. function getMiniMapCoord(a, b) {
  243. return ((a + (window.boarders.y / 2)) / window.boarders.y) * 200;
  244. }
  245. function addToMinimap(x, y, m) {
  246. var c = document.getElementById("shotCanvas");
  247. var ctx = c.getContext("2d");
  248. var mass = 2.5;
  249. ctx.beginPath();
  250. ctx.strokeStyle = 'black';
  251. ctx.lineWidth = 1;
  252. ctx.globalAlpha = 1;
  253. ctx.arc(x, y, mass, 0, 2 * Math.PI);
  254. ctx.stroke();
  255. ctx.fill();
  256. ctx.closePath();
  257. }
  258. function drawMap() {
  259. var c = document.getElementById("shotCanvas");
  260. var ctx = c.getContext("2d");
  261. ctx.beginPath();
  262. ctx.fillStyle = "rgba(0,0,0,.25)";
  263. var size = 200;
  264. ctx.lineWidth = 1.5;
  265. var canvasWidth = c.width;
  266. var canvasHeight = c.height;
  267. var mapX = canvasWidth - size;
  268. var mapY = canvasHeight - size;
  269. ctx.rect(mapX, mapY, size, size);
  270. ctx.fill();
  271. var bw = size;
  272. var bh = size;
  273. for(var x = 0; x <= bw; x += 40) {
  274. if(x != bw) {
  275. var ix = 0.5 + x + mapX;
  276. var iy = mapY;
  277. if(x == 0) continue;
  278. ctx.moveTo(0.5 + x + mapX, mapY);
  279. ctx.lineTo(0.5 + x + mapX, bh + mapY);
  280. }
  281. ctx.fillStyle = "white";
  282. ctx.font = "900 18px Montserrat";
  283. ctx.textAlign = "center";
  284. ctx.strokeStyle = "white";
  285. ctx.lineWidth = 1;
  286. ctx.globalAlpha = 0.35;
  287. for(var i = 0; i < 5; i++) {
  288. ctx.fillText(String.fromCharCode(i + 65) + x / 40, (0.5 + x + mapX) - 20, mapY + 25.5 + (i * 40));
  289. }
  290. }
  291. }
  292. function addUis() {
  293. if (location.origin == 'https://popsplit.us')
  294. setTimeout(() => {
  295. var html = "<link href='https://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'><div style=' background-color: #000000; opacity: 0.9; filter: alpha(opacity=0); zoom: 1; width: 205px; top: 5%; left: 1%; display: block; position: fixed; text-align: center; font-size: 15px; color: #ffffff; padding: 5px; font-family: Ubuntu; border: 3px solid #ffffff; z-index: 9999999999999999; border-radius: 5px;'> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px; font-size: 20px;'><font color='lightblue'>CloneSmasher v2</font></div> <div style='color:#ffffff; display: inline; opacity:1; filter:alpha(opacity=100); padding: 10px;' position: fixed;><br>Server Status: <font color='lightblue' id='serverStat' > " + window.__connected + " </font><br>Bots: <font color='lightblue' id='count' > Off </font> <br>Time left: <font color='lightblue' id='timeLeft' > 0 seconds</font> </div> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'><br> Split Bots: <font color='lightblue'>" + window.botConfig.botSplit.toUpperCase() + "</font> </div> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=0); padding: 10px;'><br>Bot Eject: <font color='lightblue'>" + window.botConfig.botFeed.toUpperCase() + "</font><br>Pellet Mode: <font color='lightblue'>" + window.botConfig.botPelletMode.toUpperCase() + "</font> <br><button id='start' style='width: 150px; height: 25px; background:#00FF00; border: 0px; border-radius: 5px;'>Start bots</button></div> ";
  296. document.getElementsByClassName('hud trigger-context')[0].innerHTML += html;
  297. document.getElementById('start').onclick = () => {
  298. if (window.started) {
  299. window._ws.send(new Uint8Array([1]));
  300. document.getElementById('start').style.background = "#00FF00";
  301. $('#start').html('Start Bots');
  302. } else {
  303. window._ws.send(new Uint8Array([0]));
  304. document.getElementById('start').style.background = "#FF0000";
  305. $('#start').html('Stop Bots');
  306. }
  307. window.started = !window.started;
  308. };
  309. }, 2500);
  310. else {
  311. var html = "<link href='https://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'><div style=' background-color: #000000; opacity: 0.9; filter: alpha(opacity=0); zoom: 1; width: 205px; top: 5%; left: 1%; display: block; position: fixed; text-align: center; font-size: 15px; color: #ffffff; padding: 5px; font-family: Ubuntu; border: 3px solid #ffffff; z-index: 9999999999999999; border-radius: 5px;'> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px; font-size: 20px;'><font color='lightblue'>CloneSmasher v2</font></div> <div style='color:#ffffff; display: inline; opacity:1; filter:alpha(opacity=100); padding: 10px;' position: fixed;><br>Server Status: <font color='lightblue' id='serverStat' > " + window.__connected + " </font><br>Bots: <font color='lightblue' id='count' > Off </font> <br>Time left: <font color='lightblue' id='timeLeft' > 0 seconds</font> </div> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'><br> Split Bots: <font color='lightblue'>" + window.botConfig.botSplit.toUpperCase() + "</font> </div> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=0); padding: 10px;'><br>Bot Eject: <font color='lightblue'>" + window.botConfig.botFeed.toUpperCase() + "</font><br>Pellet Mode: <font color='lightblue'>" + window.botConfig.botPelletMode.toUpperCase() + "</font> <br><button id='start' style='width: 150px; height: 25px; background:#00FF00; border: 0px; border-radius: 5px;'>Start bots</button></div> ";
  312. $("body").append(html);
  313. document.getElementById('start').onclick = () => {
  314. if (window.started) {
  315. window._ws.send(new Uint8Array([1]));
  316. document.getElementById('start').style.background = "#00FF00";
  317. $('#start').html('Start Bots');
  318. } else {
  319. window._ws.send(new Uint8Array([0]));
  320. document.getElementById('start').style.background = "#FF0000";
  321. $('#start').html('Stop Bots');
  322. }
  323. window.started = !window.started;
  324. };
  325. }
  326. $('body').append('<canvas id="shotCanvas" width="200" height="200" style="position: absolute; right: 5px; bottom: 5px;"></canvas>');
  327. drawMap();
  328. }
  329. addUis();
  330. function overWriteWS() {
  331. setTimeout(() => {
  332. console.log('overwrite ws onmessage!');
  333. window.wobsocket.___msg = window.wobsocket.onmessage;
  334. window.wobsocket.onmessage = function(msg) {
  335. window.wobsocket.___msg(msg);
  336. msg = new DataView(msg.data);
  337. let opcode = msg.getUint8(0);
  338. switch (opcode) {
  339. case 64:
  340. window._boarders.x = (msg.getFloat64(1, true) + msg.getFloat64(17, true)) / 2;
  341. window._boarders.y = (msg.getFloat64(9, true) + msg.getFloat64(25, true)) / 2;
  342. window._ws.send(msg);
  343. break;
  344. }
  345. };
  346. }, 2500);
  347. }
  348. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement