Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.agarServer = 'none';
- window.started = false;
- window.__connected = 'Disconnected';
- window.pelletMode = false;
- window._ws = null;
- window.wobsocket = null;
- window._boarders = {};
- window.boarders = {};
- var mapWidth = 200;
- (function() {
- 'use strict';
- function bufToArray(buf) {
- var ab = [];
- for (var i = 0; i < buf.byteLength; i++) {
- ab.push(buf.getUint8(i, true));
- }
- return ab;
- }
- function toArrayBuffer(buf) {
- var ab = new ArrayBuffer(buf.length);
- var view = new Uint8Array(ab);
- for (var i = 0; i < buf.length; ++i) {
- view[i] = buf[i];
- }
- return ab;
- }
- connect();
- function connect() {
- window._ws = new WebSocket('wss://' + window.botConfig.botServer + ':8888?origin=' + location.origin + '&token=' + Math.floor(Math.random() * 100000));
- window._ws.onclose = onclose;
- window._ws.onopen = onopen;
- window._ws._send = window._ws.send;
- window._ws.send = send;
- window._ws.onmessage = onmessage;
- //console.log('Connecting!');
- }
- function onmessage(msg) {
- // console.log(msg.data);
- try {
- msg = JSON.parse(msg.data);
- if (msg.count)
- $('#count').html(msg.count);
- else if (msg.y)
- window.boarders = msg;
- else if (msg.timeLeft)
- timeLeft(msg.timeLeft);
- } catch(e) {
- try {
- msg = msg.data.split(',');
- var c = document.getElementById("shotCanvas");
- var ctx = c.getContext("2d");
- ctx.clearRect(0, 0, c.width, c.height);
- drawMap();
- for (var i of msg) {
- var split = i.split('|'); //x|y|mass
- var x = split[0];
- var y = split[1];
- var size = split[2];
- //console.log(`x: ${x}, y: ${y}, x on map: ${getMiniMapCoord(parseInt(x), 200)}, y on map: ${getMiniMapCoord(parseInt(y), 200)}`);
- addToMinimap(getMiniMapCoord(parseInt(x), 200), getMiniMapCoord(parseInt(y), 200), size / 50);
- }
- } catch(e) {}
- }
- }
- function timeLeft(timeleft) {
- if (timeleft == 'unlimited')
- $('#timeLeft').html('Unlimited');
- else
- setInterval(() => {
- $('#timeLeft').html(timeleft-- + ' seconds');
- }, 1000);
- }
- function onopen() {
- // console.log('Connected!');
- $('#serverStat').html('Connected');
- window.__connected = 'Connected';
- let buf = new DataView(new ArrayBuffer(1 + 2 * window.agarServer.length));
- let offset = 0;
- buf.setUint8(offset++, 3);
- for (let i = 0; i < window.agarServer.length; i++) {
- buf.setUint16(offset, window.agarServer.charCodeAt(i), true);
- offset += 2;
- }
- window._ws.send(buf);
- }
- function send(e) {
- if (window._ws.readyState === window._ws.OPEN) window._ws._send(e);
- }
- function onclose(e) {
- $('#serverStat').html('Disconnected');
- window.__connected = 'Disconnected';
- //console.log(e.reason);
- if (e.reason !== 'FULL')
- connect();
- }
- if (window.location.origin == "http://agar.bio") {
- window.WebSocket.prototype.prototype.realSend = window.WebSocket.prototype.prototype.send;
- window.WebSocket.prototype.prototype.send = function(pkt) {
- this.realSend(pkt);
- if (this.url.indexOf(window.botConfig.botServer) !== -1) return;
- if (pkt instanceof ArrayBuffer) pkt = new DataView(pkt);
- else if (pkt instanceof DataView) pkt = pkt;
- else pkt = new DataView(toArrayBuffer(pkt));
- switch (pkt.getUint8(0, true)) {
- case 16:
- window._ws.send(pkt);
- break;
- case 254:
- // console.log(bufToArray(pkt));
- window.pkt254 = bufToArray(pkt);
- var buf = new DataView(new ArrayBuffer(1 + pkt.byteLength));
- buf.setUint8(0, 254);
- buf.setUint8(1, pkt.getUint8(0));
- //buf.setUint32(pkt.getUint32(1, true), true);
- for (var i = 0; i < pkt.byteLength; i++) {
- buf.setUint8(i + 1, pkt.getUint8(i));
- }
- window._ws.send(buf);
- break;
- case 255:
- window.pkt255 = bufToArray(pkt);
- //console.log(bufToArray(pkt));
- buf = new DataView(new ArrayBuffer(1 + pkt.byteLength));
- buf.setUint8(0, 255);
- buf.setUint8(1, pkt.getUint8(0));
- //buf.setUint32(pkt.getUint32(1, true), true);
- for (var i = 0; i < pkt.byteLength; i++) {
- buf.setUint8(i + 1, pkt.getUint8(i));
- }
- window._ws.send(buf);
- break;
- default:
- //console.log(bufToArray(pkt));
- }
- if (window.agarServer !== this.url) {
- window.agarServer = this.url;
- let buf = new DataView(new ArrayBuffer(1 + 2 * this.url.length));
- let offset = 0;
- buf.setUint8(offset++, 3);
- for (let i = 0; i < this.url.length; i++) {
- buf.setUint16(offset, this.url.charCodeAt(i), true);
- offset += 2;
- }
- window._ws.send(buf);
- }
- }
- } else {
- WebSocket.prototype.realSend = WebSocket.prototype.send;
- WebSocket.prototype.send = function(pkt) {
- this.realSend(pkt);
- if (this.url.indexOf(window.botConfig.botServer) !== -1) return;
- if (pkt instanceof ArrayBuffer) pkt = new DataView(pkt);
- else if (pkt instanceof DataView) pkt = pkt;
- else pkt = new DataView(toArrayBuffer(pkt));
- switch (pkt.getUint8(0, true)) {
- case 16:
- window._ws.send(pkt);
- break;
- case 254:
- // console.log(bufToArray(pkt));
- window.pkt254 = bufToArray(pkt);
- var buf = new DataView(new ArrayBuffer(1 + pkt.byteLength));
- buf.setUint8(0, 254);
- buf.setUint8(1, pkt.getUint8(0));
- //buf.setUint32(pkt.getUint32(1, true), true);
- for (var i = 0; i < pkt.byteLength; i++) {
- buf.setUint8(i + 1, pkt.getUint8(i));
- }
- window._ws.send(buf);
- break;
- case 255:
- window.pkt255 = bufToArray(pkt);
- //console.log(bufToArray(pkt));
- buf = new DataView(new ArrayBuffer(1 + pkt.byteLength));
- buf.setUint8(0, 255);
- buf.setUint8(1, pkt.getUint8(0));
- //buf.setUint32(pkt.getUint32(1, true), true);
- for (var i = 0; i < pkt.byteLength; i++) {
- buf.setUint8(i + 1, pkt.getUint8(i));
- }
- window._ws.send(buf);
- break;
- default:
- //console.log(bufToArray(pkt));
- }
- };
- var _WebSocket = WebSocket;
- WebSocket = function(ip) {
- if (ip.indexOf(window.botConfig.botServer) == -1) {
- window.agarServer = ip;
- let buf = new DataView(new ArrayBuffer(1 + 2 * ip.length));
- let offset = 0;
- buf.setUint8(offset++, 3);
- for (let i = 0; i < ip.length; i++) {
- buf.setUint16(offset, ip.charCodeAt(i), true);
- offset += 2;
- }
- window._ws.send(buf);
- window.wobsocket = new _WebSocket(ip);
- if (location.origin == 'http://agar.pro' || location.origin == 'http://qwoks.ga') overWriteWS();
- return window.wobsocket;
- } else
- return new _WebSocket(ip);
- };
- }
- function isTyping() {
- return $("input:focus").length;
- }
- document.addEventListener('keyup', key => {
- key = key.key.toLowerCase();
- if (isTyping()) return;
- switch (key) {
- case window.botConfig.botMassGate.toLowerCase():
- window._ws.send(new Uint8Array([5]));
- break;
- case window.botConfig.botPelletMode.toLowerCase():
- window._ws.send(new Uint8Array([4]));
- break;
- case window.botConfig.botStart.toLowerCase():
- if (window.started)
- window._ws.send(new Uint8Array([1]));
- else
- window._ws.send(new Uint8Array([0]));
- window.started = !window.started;
- break;
- }
- });
- document.addEventListener('keydown', key => {
- key = key.key.toLowerCase();
- if (isTyping()) return;
- switch (key) {
- case window.botConfig.botSplit.toLowerCase():
- window._ws.send(new Uint8Array([2, 0]));
- break;
- case window.botConfig.botFeed.toLowerCase():
- window._ws.send(new Uint8Array([2, 1]));
- break;
- }
- });
- function getMiniMapCoord(a, b) {
- return ((a + (window.boarders.y / 2)) / window.boarders.y) * 200;
- }
- function addToMinimap(x, y, m) {
- var c = document.getElementById("shotCanvas");
- var ctx = c.getContext("2d");
- var mass = 2.5;
- ctx.beginPath();
- ctx.strokeStyle = 'black';
- ctx.lineWidth = 1;
- ctx.globalAlpha = 1;
- ctx.arc(x, y, mass, 0, 2 * Math.PI);
- ctx.stroke();
- ctx.fill();
- ctx.closePath();
- }
- function drawMap() {
- var c = document.getElementById("shotCanvas");
- var ctx = c.getContext("2d");
- ctx.beginPath();
- ctx.fillStyle = "rgba(0,0,0,.25)";
- var size = 200;
- ctx.lineWidth = 1.5;
- var canvasWidth = c.width;
- var canvasHeight = c.height;
- var mapX = canvasWidth - size;
- var mapY = canvasHeight - size;
- ctx.rect(mapX, mapY, size, size);
- ctx.fill();
- var bw = size;
- var bh = size;
- for(var x = 0; x <= bw; x += 40) {
- if(x != bw) {
- var ix = 0.5 + x + mapX;
- var iy = mapY;
- if(x == 0) continue;
- ctx.moveTo(0.5 + x + mapX, mapY);
- ctx.lineTo(0.5 + x + mapX, bh + mapY);
- }
- ctx.fillStyle = "white";
- ctx.font = "900 18px Montserrat";
- ctx.textAlign = "center";
- ctx.strokeStyle = "white";
- ctx.lineWidth = 1;
- ctx.globalAlpha = 0.35;
- for(var i = 0; i < 5; i++) {
- ctx.fillText(String.fromCharCode(i + 65) + x / 40, (0.5 + x + mapX) - 20, mapY + 25.5 + (i * 40));
- }
- }
- }
- function addUis() {
- if (location.origin == 'https://popsplit.us')
- setTimeout(() => {
- 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> ";
- document.getElementsByClassName('hud trigger-context')[0].innerHTML += html;
- document.getElementById('start').onclick = () => {
- if (window.started) {
- window._ws.send(new Uint8Array([1]));
- document.getElementById('start').style.background = "#00FF00";
- $('#start').html('Start Bots');
- } else {
- window._ws.send(new Uint8Array([0]));
- document.getElementById('start').style.background = "#FF0000";
- $('#start').html('Stop Bots');
- }
- window.started = !window.started;
- };
- }, 2500);
- else {
- 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> ";
- $("body").append(html);
- document.getElementById('start').onclick = () => {
- if (window.started) {
- window._ws.send(new Uint8Array([1]));
- document.getElementById('start').style.background = "#00FF00";
- $('#start').html('Start Bots');
- } else {
- window._ws.send(new Uint8Array([0]));
- document.getElementById('start').style.background = "#FF0000";
- $('#start').html('Stop Bots');
- }
- window.started = !window.started;
- };
- }
- $('body').append('<canvas id="shotCanvas" width="200" height="200" style="position: absolute; right: 5px; bottom: 5px;"></canvas>');
- drawMap();
- }
- addUis();
- function overWriteWS() {
- setTimeout(() => {
- console.log('overwrite ws onmessage!');
- window.wobsocket.___msg = window.wobsocket.onmessage;
- window.wobsocket.onmessage = function(msg) {
- window.wobsocket.___msg(msg);
- msg = new DataView(msg.data);
- let opcode = msg.getUint8(0);
- switch (opcode) {
- case 64:
- window._boarders.x = (msg.getFloat64(1, true) + msg.getFloat64(17, true)) / 2;
- window._boarders.y = (msg.getFloat64(9, true) + msg.getFloat64(25, true)) / 2;
- window._ws.send(msg);
- break;
- }
- };
- }, 2500);
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement