Advertisement
Guest User

JS

a guest
Sep 25th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // COMING SOON ;)
  2. // btw why are u looking here?
  3. var fbBot = "";
  4.  
  5. function escapeHtml(a) {
  6.   return String(a).replace(/[&<>"'\/]/g, function(a) {
  7.     return entityMap[a];
  8.   });
  9. }
  10.  
  11. function updateBotCount(a, b) {
  12.   BotMega.localBotsAlive[a] = b;
  13.   var c = BotMega.serverBots;
  14.   var d = 200 + BotMega.serverBots;
  15.   var e = 0;
  16.   for (;e < 2;e++) {
  17.     if (BotMega.localBotsAlive[e]) {
  18.       c++;
  19.     }
  20.   }
  21.   if (0 == c) {
  22.     $("#botCount").html('<font color="red">0 / ' + d + "</font>");
  23.   } else {
  24.     $("#botCount").html('<font color="#7FFF00">' + c + " / " + d + "</font>");
  25.   }
  26. }
  27. function startLocalBots() {
  28.   var a$$0 = 0;
  29.   for (;a$$0 < BotMega.startBotAmount;a$$0++) {
  30.     BotMega.localBotsAlive[a$$0] = false;
  31.     BotMega.localBots[a$$0] = new Worker(URL.createObjectURL(new Blob(["(" + generateBotFunction() + ")()"], {
  32.       type : "text/javascript"
  33.     })));
  34.     BotMega.localBots[a$$0].onmessage = function(a) {
  35.       var b = a.data;
  36.       switch(b.name) {
  37.         case "add":
  38.           updateBotCount(b.botID, true);
  39.           addBallToMinimap(true, "bot" + b.botID, b.botName, b.x, b.y, "#FF00FF", true);
  40.           break;
  41.         case "remove":
  42.           updateBotCount(b.botID, false);
  43.           removeBallFromMinimap("bot" + b.botID);
  44.           break;
  45.         case "position":
  46.           moveBallOnMinimap("bot" + b.botID, b.x, b.y);
  47.           break;
  48.         default:
  49.           console.log("Unknown command received from bot");
  50.       }
  51.     };
  52.     BotMega.localBots[a$$0].postMessage({
  53.       name : "botID",
  54.       botID : a$$0
  55.     });
  56.   }
  57.   updateBotNames();
  58. }
  59. function startRemoteBots() {
  60.   var a = 0;
  61.   for (;a < 3;a++) {
  62.     BotMega.remoteBots[a] = new Worker(URL.createObjectURL(new Blob(["(" + generateBotFunction() + ")()"], {
  63.       type : "text/javascript"
  64.     })));
  65.   }
  66. }
  67. function sendLocalBotsMessage(a) {
  68.   for (i in BotMega.localBots) {
  69.     BotMega.localBots[i].postMessage(a);
  70.   }
  71. }
  72. function sendRemoteBotsMessage(a) {
  73.   for (i in BotMega.remoteBots) {
  74.     BotMega.remoteBots[i].postMessage(a);
  75.   }
  76. }
  77. function insertCore() {
  78.   var f = new XMLHttpRequest;
  79.   f.open("GET", "/agario.core.js", true);
  80.   f.onload = function() {
  81.     var script = f.responseText;
  82.     script = replaceNormalFile(script, "if(h.MC&&h.MC.onPlayerSpawn)", "BotMega.playerSpawned();if(h.MC&&h.MC.onPlayerSpawn)");
  83.     script = replaceNormalFile(script, "if(h.MC&&h.MC.onPlayerDeath)", "BotMega.playerDied();if(h.MC&&h.MC.onPlayerDeath)");
  84.     script = replaceNormalFile(script, "if(h.MC&&h.MC.onAgarioCoreLoaded)", "BotMega.onAgarioCoreLoaded();if(h.MC&&h.MC.onAgarioCoreLoaded)");
  85.     script = replaceNormalFile(script, "if(h.MC&&h.MC.onDisconnect)", "BotMega.playerDisconnected();if(h.MC&&h.MC.onDisconnect)");
  86.     script = replaceNormalFile(script, "connect:function(a){", "connect:function(a){BotMega.playerConnected(a);");
  87.     script = replaceNormalFile(script, "sendSpectate:function(){", "sendSpectate:function(){BotMega.playerSpectated();");
  88.     script = replaceNormalFile(script, "sendNick:function(a){", "sendNick:function(a){BotMega.updateNickname(a);");
  89.     script = replaceNormalFile(script, "setTarget:function(a,b){", "setTarget:function(a,b){if(BotMega.stopMovement){a = $('#canvas').width() / 2; b = $('#canvas').height() / 2;}");
  90.     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(BotMega.setMapCoords){BotMega.setMapCoords($3,$5,$7,$9,$2,$8);}");
  91.     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 BotMega.playerX=$4; BotMega.playerY=$5;");
  92.     script = replaceRegexFile(script, /if\((\+\w\[\w>>3\])<1\.0\){/i, "if($1 < BotMega.zoomResetValue){");
  93.     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");
  94.     script = replaceRegexFile(script, /(\w)(=\+\w\[\w>>3\]\*\+\w\()(.\d)(,\+\w\);)/i, "$1$2 (BotMega.zoomSpeedValue||0.9) $4 BotMega.zoomValue=$1;");
  95.     script = replaceRegexFile(script, /(\w=\w\[\w>>2\]\|0;)((\w\[\w>>3\])=(\w);)(\w\[\w>>0\]=a\[\w>>0\];)/i, "$1 if(!BotMega.autoZoom){$3 = BotMega.zoomValue;}else{$2}$5");
  96.     script = replaceRegexFile(script, /((\w)=(\+\(\(\w\[\w\+\d+>>\d.*;)(\w)=(\+\(\(\w\[.*\/2\|\d\)\|0\)\/\w\+\s\+\w\[\w\+\d+>>3\];).*\4=\4<\w\?\w:\w;)/, "BotMega.mouseX = $3 BotMega.mouseY = $5 $1");
  97.     eval(script);
  98.   };
  99.   f.send();
  100. }
  101. function MinimapBall(a, b, c, d, e, f) {
  102.   this.isDefault = a;
  103.   this.name = b;
  104.   this.x = c;
  105.   this.y = d;
  106.   this.lastX = c;
  107.   this.lastY = d;
  108.   this.color = e;
  109.   this.visible = f;
  110. }
  111. function drawMinimap() {
  112.   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)), BotMega.mapOffsetFixed && BotMega.drawMinimap) {
  113.     minimapCtx.globalAlpha = 0.4;
  114.     minimapCtx.fillStyle = "#000000";
  115.     minimapCtx.fillRect(0, 0, miniMap.width, miniMap.height);
  116.     var a = 200 / BotMega.mapSize;
  117.     var b = 200 / BotMega.mapSize;
  118.     minimapCtx.globalAlpha = 1;
  119.     for (ball in minimapBalls) {
  120.       minimapBalls[ball].draw(minimapCtx, a, b);
  121.     }
  122.   }
  123. }
  124. function resetMinimap() {
  125.   for (ball in minimapBalls) {
  126.     if (!minimapBalls[ball].isDefault) {
  127.       delete minimapBalls[ball];
  128.     }
  129.   }
  130. }
  131. function addBallToMinimap(a, b, c, d, e, f, g) {
  132.   minimapBalls[b] = new MinimapBall(a, c, d, e, f, g);
  133. }
  134. function removeBallFromMinimap(a) {
  135.   if (minimapBalls[a]) {
  136.     delete minimapBalls[a];
  137.   }
  138. }
  139. function moveBallOnMinimap(a, b, c) {
  140.   if (minimapBalls[a]) {
  141.     minimapBalls[a].x = b;
  142.     minimapBalls[a].y = c;
  143.   }
  144. }
  145. function setBallVisible(a, b) {
  146.   if (minimapBalls[a]) {
  147.     minimapBalls[a].visible = b;
  148.   }
  149. }
  150. function changeNicknameOnBall(a, b) {
  151.   if (minimapBalls[a]) {
  152.     minimapBalls[a].name = b;
  153.   }
  154. }
  155. function replaceRegexFile(a, b, c) {
  156.   var d = new RegExp(b);
  157.   return d.test(a) ? a = a.replace(b, c) : console.log("[Failed] to replace: " + b), a;
  158. }
  159. function replaceNormalFile(a, b, c) {
  160.   return a.indexOf(b) != -1 ? a = a.replace(b, c) : console.log("[Failed] to replace: " + b), a;
  161. }
  162. function sendCommand(a) {
  163.   if (null != socket) {
  164.     if (socket.connected) {
  165.       socket.emit("command", a);
  166.     }
  167.   }
  168. }
  169. function connectToBotMegaServer() {
  170.   socket = io.connect("ws://158.69.212.39:8003", {
  171.     reconnection : true,
  172.     query : "key=" + client_uuid
  173.   });
  174.  
  175. socket.on("message", function(msg) {
  176.     alert(msg);
  177. });
  178.  
  179. socket.on("force-uuid", function(data) {
  180.     socket.emit("uuid", client_uuid)
  181. });
  182.  
  183.   socket.on("command", function(a) {
  184.     if (void 0 === a.name) {
  185.       return void console.log("Recieved a command with no name.");
  186.     }
  187.     switch(a.name) {
  188.       case "force-update":
  189.         resetMinimap();
  190.         transmit_current_server(true);
  191.         if (BotMega.isAlive) {
  192.           sendCommand({
  193.             name : "alive",
  194.             playerName : BotMega.playerName
  195.           });
  196.         }
  197.         break;
  198.       case "add":
  199.         addBallToMinimap(false, a.socketID, a.playerName, a.x, a.y, "#FFFFFF", true);
  200.         break;
  201.       case "remove":
  202.         removeBallFromMinimap(a.socketID);
  203.         break;
  204.       case "position":
  205.         moveBallOnMinimap(a.socketID, a.x, a.y);
  206.         break;
  207.       case "count":
  208.         BotMega.serverBots = a.count;
  209.         break;
  210.       case "auth":
  211.         BotMega.isAuthorized = true;
  212.         console.log("Your client is authorized for use of more bots.");
  213.         break;
  214.       default:
  215.         return void console.log("Received a command with an unknown name: " + a.name);
  216.     }
  217.   });
  218.   socket.on("bots", function(a) {
  219.     if ("server" == a.name) {
  220.  
  221.       BotMega.remoteBotsServer = a.server;
  222.     }
  223.     sendRemoteBotsMessage(a);
  224.   });
  225.   socket.on("disconnect", function() {
  226.     resetMinimap();
  227.     sendRemoteBotsMessage({
  228.       name : "disconnect"
  229.     });
  230.   });
  231. }
  232. function updateBotNames() {
  233.   sendLocalBotsMessage({
  234.     name : "names",
  235.     botNames : BotMega.botNames
  236.   });
  237.   if (BotMega.isAuthorized) {
  238.     sendCommand({
  239.       name : "names",
  240.       botNames : BotMega.botNames
  241.     });
  242.   }
  243. }
  244. function validateNames(a) {
  245.   if (void 0 === a) {
  246.     return null;
  247.   }
  248.   if (a.indexOf(",") > -1) {
  249.     var b = a.split(",");
  250.     for (name in b) {
  251.       if (b[name].length <= 0 || b[name].length > 15) {
  252.         return null;
  253.       }
  254.     }
  255.     return b;
  256.   }
  257.   return a.length > 0 && a.length <= 15 ? [a] : null;
  258. }
  259. function emitSplit() {
  260.   if (BotMega.isAuthorized) {
  261.     sendCommand({
  262.       name : "split"
  263.     });
  264.   }
  265.   sendLocalBotsMessage({
  266.     name : "split"
  267.   });
  268. }
  269. function emitMassEject() {
  270.   if (BotMega.isAuthorized) {
  271.     sendCommand({
  272.       name : "eject"
  273.     });
  274.   }
  275.   sendLocalBotsMessage({
  276.     name : "eject"
  277.   });
  278. }
  279. function sendToken() {
  280.   sendLocalBotsMessage({
  281.     name : "useToken",
  282.     token : fbBot
  283.   });
  284. }
  285. function emitLocalPosition() {
  286.   var a = BotMega.mouseX;
  287.   var b = BotMega.mouseY;
  288.   if (!BotMega.moveToMouse) {
  289.     a = BotMega.playerX;
  290.     b = BotMega.playerY;
  291.   }
  292.   sendLocalBotsMessage({
  293.     name : "position",
  294.     x : a + BotMega.mapOffsetX,
  295.     y : b + BotMega.mapOffsetY
  296.   });
  297. }
  298. function emitPosition() {
  299.   var a = BotMega.mouseX;
  300.   var b = BotMega.mouseY;
  301.   if (!BotMega.moveToMouse) {
  302.     a = BotMega.playerX;
  303.     b = BotMega.playerY;
  304.   }
  305.   sendCommand({
  306.     name : "position",
  307.     x : BotMega.realPlayerX,
  308.     y : BotMega.realPlayerY,
  309.     botX : a + BotMega.mapOffsetX,
  310.     botY : b + BotMega.mapOffsetY
  311.   });
  312. }
  313. function transmit_current_server(a) {
  314.   if (a || last_transmited_game_server != BotMega.server) {
  315.     last_transmited_game_server = BotMega.server;
  316.     sendCommand({
  317.       name : "servers",
  318.       server : last_transmited_game_server
  319.     });
  320.   }
  321. }
  322. function generateBotFunction() {
  323.   return function() {
  324.     function replaceRegexFile(a, b, c) {
  325.       var d = new RegExp(b);
  326.       return d.test(a) ? a = a.replace(b, c) : console.log("[Failed] to replace: " + b), a;
  327.     }
  328.     function replaceNormalFile(a, b, c) {
  329.       return a.indexOf(b) != -1 ? a = a.replace(b, c) : console.log("[Failed] to replace: " + b), a;
  330.     }
  331.     function getRandomInt(a, b) {
  332.       return Math.floor(Math.random() * (b - a + 1)) + a;
  333.     }
  334.     function getBotCore() {
  335.       var e = new XMLHttpRequest;
  336.       e.open("GET", "http://agar.io/agario.core.js", true);
  337.       e.onload = function() {
  338.         var script = e.responseText;
  339.         script = replaceRegexFile(script, /\w+\.location\.hostname/g, '"agar.io"');
  340.         script = replaceNormalFile(script, "window", "self");
  341.         script = replaceNormalFile(script, "c.setStatus=function(a){console.log(a)};", "c.setStatus=function(a){};");
  342.         script = replaceNormalFile(script, 'console.log("postRun");', "");
  343.         script = replaceRegexFile(script, /(\w)=\+\(\(\w\[\w\+\d+>>\d.*;(\w)=\+\(\(\w\[.*\/2\|\d\)\|0\)\/\w\+\s\+\w\[\w\+\d+>>3\];/, "$1 = BotMega.newX; $2 = BotMega.newY;");
  344.         script = replaceNormalFile(script, "if(h.MC&&h.MC.onPlayerSpawn)", "BotMega.playerSpawned();if(h.MC&&h.MC.onPlayerSpawn)");
  345.         script = replaceNormalFile(script, "if(h.MC&&h.MC.onPlayerDeath)", "BotMega.playerDied();if(h.MC&&h.MC.onPlayerDeath)");
  346.         script = replaceNormalFile(script, "if(h.MC&&h.MC.onAgarioCoreLoaded)", "BotMega.onAgarioCoreLoaded();if(h.MC&&h.MC.onAgarioCoreLoaded)");
  347.         script = replaceNormalFile(script, "if(h.MC&&h.MC.onDisconnect)", "BotMega.playerDisconnected();if(h.MC&&h.MC.onDisconnect)");
  348.         script = replaceNormalFile(script, "h.MC&&h.MC.corePendingReload", "BotMega.reloadCore();h.MC&&h.MC.corePendingReload");
  349.         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(BotMega.setMapCoords){BotMega.setMapCoords($3,$5,$7,$9,$2,$8);}");
  350.         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 BotMega.playerX=$4; BotMega.playerY=$5; BotMega.setPath();");
  351.         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){BotMega.recordPellet($5,$6,cellSize);}$4");
  352.         eval(script);
  353.       };
  354.       e.send(null);
  355.     }
  356.     self.innerWidth = 1;
  357.     self.innerHeight = 1;
  358.     const window = {};
  359.     elementMock = {
  360.       getContext : function() {
  361.         return{
  362.           canvas : {
  363.             width : 1,
  364.             height : 1
  365.           },
  366.           clearRect : function() {
  367.           },
  368.           save : function() {
  369.           },
  370.           translate : function() {
  371.           },
  372.           scale : function() {
  373.           },
  374.           stroke : function() {
  375.           },
  376.           arc : function() {
  377.           },
  378.           fill : function() {
  379.           },
  380.           moveTo : function() {
  381.           },
  382.           lineTo : function() {
  383.           },
  384.           closePath : function() {
  385.           },
  386.           beginPath : function() {
  387.           },
  388.           restore : function() {
  389.           },
  390.           fillRect : function() {
  391.           },
  392.           measureText : function() {
  393.             return{};
  394.           },
  395.           strokeText : function() {
  396.           },
  397.           fillText : function() {
  398.           },
  399.           drawImage : function() {
  400.           }
  401.         };
  402.       },
  403.       innerText : "",
  404.       div : {
  405.         appendChild : function() {
  406.         }
  407.       },
  408.       appendChild : function() {
  409.       },
  410.       style : {}
  411.     };
  412.     document = {
  413.       getElementById : function() {
  414.         return elementMock;
  415.       },
  416.       createElement : function(a) {
  417.         return elementMock;
  418.       },
  419.       body : {
  420.         firstChild : {},
  421.         insertBefore : function() {
  422.         }
  423.       }
  424.     };
  425.     Image = function() {
  426.     };
  427.     self.BotMega = {
  428.       server : null,
  429.       botID : 0,
  430.       botName : "BotMe.ga",
  431.       playerX : 0,
  432.       playerY : 0,
  433.       newX : 0,
  434.       newY : 0,
  435.       realPlayerX : null,
  436.       realPlayerY : null,
  437.       mapOffset : 7071,
  438.       mapOffsetX : 0,
  439.       mapOffsetY : 0,
  440.       mapOffsetFixed : false,
  441.       collectPellets : false,
  442.       pelletTargetX : 99999,
  443.       pelletTargetY : 99999,
  444.       pellets : [],
  445.       recordPellet : function(a, b, c) {
  446.         this.pellets.push({
  447.           x : a,
  448.           y : b,
  449.           size : c
  450.         });
  451.       },
  452.       setMapCoords : function(a, b, c, d, e, f) {
  453.         if (f - e == 24) {
  454.           if (c - a > 14E3) {
  455.             if (d - b > 14E3) {
  456.               this.mapOffsetX = this.mapOffset - c;
  457.               this.mapOffsetY = this.mapOffset - d;
  458.               this.mapOffsetFixed = true;
  459.             }
  460.           }
  461.         }
  462.       },
  463.       playerDied : function() {
  464.         postMessage({
  465.           name : "remove",
  466.           botID : BotMega.botID
  467.         });
  468.       },
  469.       playerSpawned : function() {
  470.         postMessage({
  471.           name : "add",
  472.           botID : BotMega.botID,
  473.           botName : BotMega.botName,
  474.           x : BotMega.realPlayerX,
  475.           y : BotMega.realPlayerY
  476.         });
  477.       },
  478.       playerDisconnected : function() {
  479.         postMessage({
  480.           name : "remove",
  481.           botID : BotMega.botID
  482.         });
  483.         if (self.core) {
  484.           if (null != BotMega.server) {
  485.             core.connect(BotMega.server);
  486.           }
  487.         }
  488.       },
  489.       reloadCore : function() {
  490.         if (self.core) {
  491.           self.core.destroy();
  492.         }
  493.         getBotCore();
  494.       },
  495.       onAgarioCoreLoaded : function() {
  496.         if (self.core) {
  497.           if (null != BotMega.server) {
  498.             core.connect(BotMega.server);
  499.           }
  500.         }
  501.       },
  502.       setPath : function() {
  503.         var a = -1;
  504.         var b = 0;
  505.         var c = 0;
  506.         for (;c < this.pellets.length;c++) {
  507.           var d = this.getDistanceBetweenPositions(this.pellets[c].x, this.pellets[c].y, this.playerX, this.playerY);
  508.           if (!(a != -1 && d > b)) {
  509.             a = c;
  510.             b = d;
  511.           }
  512.         }
  513.         if (a == -1) {
  514.           this.pelletTargetX = 99999;
  515.           this.pelletTargetY = 99999;
  516.         } else {
  517.           this.pelletTargetX = this.pellets[a].x;
  518.           this.pelletTargetY = this.pellets[a].y;
  519.         }
  520.         this.pellets = [];
  521.       },
  522.       getDistanceBetweenPositions : function(a, b, c, d) {
  523.         return Math.sqrt(Math.pow(c - a, 2) + Math.pow(b - d, 2));
  524.       }
  525.     };
  526.     onmessage = function(a) {
  527.       var b = a.data;
  528.       switch(b.name) {
  529.         case "botID":
  530.           BotMega.botID = b.botID;
  531.           break;
  532.         case "server":
  533.           BotMega.server = b.server;
  534.           if (self.core) {
  535.             if (null != b.server) {
  536.               core.connect(b.server);
  537.             }
  538.           }
  539.           break;
  540.         case "position":
  541.           if (BotMega.collectPellets && (99999 != BotMega.pelletTargetX && 99999 != BotMega.pelletTargetY)) {
  542.             BotMega.newX = BotMega.pelletTargetX;
  543.             BotMega.newY = BotMega.pelletTargetY;
  544.           } else {
  545.             BotMega.newX = b.x - BotMega.mapOffsetX;
  546.             BotMega.newY = b.y - BotMega.mapOffsetY;
  547.           }
  548.           break;
  549.         case "split":
  550.           if (self.core) {
  551.             core.split();
  552.           }
  553.           break;
  554.         case "eject":
  555.           if (self.core) {
  556.             core.eject();
  557.           }
  558.           break;
  559.         case "names":
  560.           if (null == b.botNames) {
  561.             BotMega.botName = "BotMe.ga";
  562.             break;
  563.           }
  564.           BotMega.botName = b.botNames[getRandomInt(0, b.botNames.length - 1)];
  565.           break;
  566.         case "disconnect":
  567.           BotMega.server = null;
  568.           if (self.core) {
  569.             core.disconnect();
  570.           }
  571.           break;
  572.         case "collectPellets":
  573.           BotMega.collectPellets = b.collectPellets;
  574.           break;
  575.         case "useToken":
  576.           var bytes = [8, 1, 18, b.token.length + 25, 1, 8, 10, 82, b.token.length + 20, 1, 8, 2, 18, 13, 8, 5, 18, 5, 50, 46, 50, 46, 49, 24, 0, 32, 0, 26, b.token.length, 1];
  577.           console.log(bytes);
  578.           for (var i = 0; i < b.token.length; i++) bytes.push(b.token.charCodeAt(i));
  579.           setTimeout(function() {
  580.             core.proxyMobileData(new Uint8Array(bytes));
  581.           }, 1000);
  582.  
  583.         default:
  584.           console.log("Unknown message received." + b);
  585.       }
  586.     };
  587.     setInterval(function() {
  588.       BotMega.realPlayerX = BotMega.mapOffsetX + BotMega.playerX;
  589.       BotMega.realPlayerY = BotMega.mapOffsetY + BotMega.playerY;
  590.       postMessage({
  591.         botID : BotMega.botID,
  592.         name : "position",
  593.         x : BotMega.realPlayerX,
  594.         y : BotMega.realPlayerY
  595.       });
  596.       if (self.core) {
  597.         core.sendNick(BotMega.botName);
  598.       }
  599.     }, 100);
  600.     getBotCore();
  601.   }.toString();
  602. }
  603. window.history.replaceState("", "", "/" + location.hash), window.getTextWidth = function(a, b) {
  604.   var c = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
  605.   var d = c.getContext("2d");
  606.   d.font = b;
  607.   var e = d.measureText(a);
  608.   return e.width;
  609. };
  610. var entityMap = {
  611.   "&" : "&amp;",
  612.   "<" : "&lt;",
  613.   ">" : "&gt;",
  614.   '"' : "&quot;",
  615.   "'" : "&#39;",
  616.   "/" : "&#x2F;"
  617. };
  618. var client_uuid = escapeHtml(localStorage.getItem("BotMega_uuid"));
  619. if (null === client_uuid || 15 != client_uuid.length) {
  620.   client_uuid = "";
  621.   var ranStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  622.   var ii = 0;
  623.   for (;ii < 15;ii++) {
  624.     client_uuid += ranStr.charAt(Math.floor(Math.random() * ranStr.length));
  625.   }
  626.   localStorage.setItem("BotMega_uuid", client_uuid);
  627. }
  628. window.BotMega = {
  629.   server : null,
  630.   playerName : "",
  631.   startBotAmount: 2,
  632.   playerX : 0,
  633.   playerY : 0,
  634.   mouseX : 0,
  635.   mouseY : 0,
  636.   realPlayerX : null,
  637.   realPlayerY : null,
  638.   mapSize : 14142,
  639.   mapOffset : 7071,
  640.   mapOffsetX : 0,
  641.   mapOffsetY : 0,
  642.   mapOffsetFixed : false,
  643.   zoomValue : 1,
  644.   zoomResetValue : 0,
  645.   zoomSpeedValue : 0.9,
  646.   autoZoom : true,
  647.   stopMovement : false,
  648.   isAlive : false,
  649.   moveToMouse : true,
  650.   localBots : {},
  651.   localBotsAlive : {},
  652.   remoteBotsServer : null,
  653.   remoteBots : {},
  654.   remoteBotsAlive : {},
  655.   leaderboardData : "",
  656.   serverBots : 0,
  657.   isAuthorized : !1,
  658.   drawMinimap : true,
  659.   setMapCoords : function(a, b, c, d, e, f) {
  660.     if (f - e == 24) {
  661.       if (c - a > 14E3) {
  662.         if (d - b > 14E3) {
  663.           this.mapOffsetX = this.mapOffset - c;
  664.           this.mapOffsetY = this.mapOffset - d;
  665.           this.mapOffsetFixed = true;
  666.         }
  667.       }
  668.     }
  669.   },
  670.   playerDied : function() {
  671.     BotMega.isAlive = false;
  672.     moveBallOnMinimap("player_death", this.realPlayerX, this.realPlayerY);
  673.     setBallVisible("player_pointer", false);
  674.     setBallVisible("player_death", true);
  675.     sendCommand({
  676.       name : "dead"
  677.     });
  678.   },
  679.   playerSpawned : function() {
  680.     BotMega.isAlive = true;
  681.     changeNicknameOnBall("player_pointer", BotMega.playerName);
  682.     setBallVisible("player_spectate", false);
  683.     setBallVisible("player_pointer", true);
  684.     sendCommand({
  685.       name : "alive",
  686.       playerName : BotMega.playerName
  687.     });
  688.   },
  689.   playerConnected : function(a) {
  690.     resetMinimap();
  691.     if (null != this.remoteBotsServer) {
  692.       if (this.remoteBotsServer == a) {
  693.         sendRemoteBotsMessage({
  694.           name : "disconnect"
  695.         });
  696.       }
  697.     }
  698.     BotMega.server = a;
  699.     console.log("Connecting to: " + a);
  700.     setBallVisible("player_pointer", false);
  701.     setBallVisible("player_death", false);
  702.     setBallVisible("player_spectate", false);
  703.     sendLocalBotsMessage({
  704.       name : "server",
  705.       server : a
  706.     });
  707.   },
  708.   playerDisconnected : function() {
  709.     resetMinimap();
  710.     sendCommand({
  711.       name : "dead"
  712.     });
  713.     setBallVisible("player_pointer", false);
  714.     setBallVisible("player_death", false);
  715.     setBallVisible("player_spectate", false);
  716.     BotMega.server = null;
  717.     BotMega.isAlive = false;
  718.   },
  719.   playerSpectated : function() {
  720.     setBallVisible("player_pointer", false);
  721.     setBallVisible("player_spectate", true);
  722.     sendCommand({
  723.       name : "dead"
  724.     });
  725.   },
  726.   updateNickname : function(a) {
  727.     this.playerName = a;
  728.   },
  729.   loadCore : function() {
  730.     setTimeout(function() {
  731.       startLocalBots();
  732.       startRemoteBots();
  733.     }, 2E3);
  734.     console.log("Loading core.");
  735.     var b$$0 = (document.getElementById("canvas"), localStorage.getItem("botnames"));
  736.     if (null !== b$$0) {
  737.       BotMega.botNames = validateNames(b$$0);
  738.       if (null !== BotMega.botNames) {
  739.         $("#botnames").val(b$$0);
  740.       }
  741.       updateBotNames();
  742.     }
  743.     $("#botnames").on("input", function() {
  744.       var a = $("#botnames").val();
  745.       var b = validateNames(a);
  746.       BotMega.botNames = b;
  747.       updateBotNames();
  748.       if (null !== b) {
  749.         localStorage.setItem("botnames", a);
  750.       }
  751.     });
  752.     $("#leaderboardcopy").click(function(a) {
  753.       var b = $("#leaderboard")[0];
  754.       b.setSelectionRange(0, b.value.length);
  755.       b.select();
  756.       try {
  757.         document.execCommand("copy");
  758.       } catch (a$$0) {
  759.         console.log("Failed to copy leaderboard.");
  760.       }
  761.     });
  762.     $("#uuidcopy").click(function(a) {
  763.       var b = $("#uuid")[0];
  764.       b.setSelectionRange(0, b.value.length);
  765.       b.select();
  766.       try {
  767.         document.execCommand("copy");
  768.       } catch (a$$0) {
  769.         console.log("Failed to copy uuid.");
  770.       }
  771.     });
  772.     var c;
  773.     var d = false;
  774.     var f$$0 = false;
  775.     $(document).keydown(function(a) {
  776.       switch(a.which) {
  777.         case 65:
  778.           BotMega.moveToMouse = !BotMega.moveToMouse;
  779.           if (BotMega.moveToMouse) {
  780.             $("#ismoveToMouse").html("<font color='#7FFF00'>On</font>");
  781.           } else {
  782.             $("#ismoveToMouse").html("<font color='red'>Off</font>");
  783.           }
  784.           break;
  785.         case 68:
  786.           BotMega.stopMovement = !BotMega.stopMovement;
  787.           if (BotMega.stopMovement) {
  788.             $("#isStopMove").html("<font color='#7FFF00'>On</font>");
  789.           } else {
  790.             $("#isStopMove").html("<font color='red'>Off</font>");
  791.           }
  792.           break;
  793.         case 69:
  794.           emitSplit();
  795.           break;
  796.         case 82:
  797.           emitMassEject();
  798.           break;
  799.         case 77:
  800.           BotMega.drawMinimap = !BotMega.drawMinimap;
  801.           if (BotMega.drawMinimap) {
  802.             $("#botcanvas").show();
  803.           } else {
  804.             $("#botcanvas").hide();
  805.           }
  806.           break;
  807.         case 80:
  808.           f$$0 = !f$$0;
  809.           if (f$$0) {
  810.             $("#collectPellets").html("<font color='#7FFF00'>On</font>");
  811.           } else {
  812.             $("#collectPellets").html("<font color='red'>Off</font>");
  813.           }
  814.           sendLocalBotsMessage({
  815.             name : "collectPellets",
  816.             collectPellets : f$$0
  817.           });
  818.           if (BotMega.isAuthorized) {
  819.             sendCommand({
  820.               name : "collectPellets",
  821.               collectPellets : f$$0
  822.             });
  823.           }
  824.           break;
  825.         case 87:
  826.           if (d) {
  827.             return;
  828.           }
  829.           d = true;
  830.           c = setInterval(function() {
  831.             core.eject();
  832.           }, 50);
  833.       }
  834.     });
  835.     $(document).keyup(function(a) {
  836.       switch(a.which) {
  837.         case 87:
  838.           d = false;
  839.           clearInterval(c);
  840.           break;
  841.         case 84:
  842.           var b = 0;
  843.           var e = setInterval(function() {
  844.             return b > 7 ? void clearInterval(e) : (b++, void core.split());
  845.           }, 50);
  846.           break;
  847.         case 81:
  848.           var f = 0;
  849.           var g = setInterval(function() {
  850.             return f > 1 ? void clearInterval(g) : (f++, void core.split());
  851.           }, 50);
  852.       }
  853.     });
  854.     addBallToMinimap(true, "player_pointer", BotMega.playerName, BotMega.realPlayerX, BotMega.realPlayerY, "#00FF00", false);
  855.     addBallToMinimap(true, "player_death", "Last Death", BotMega.realPlayerX, BotMega.realPlayerY, "#FF2400", false);
  856.     addBallToMinimap(true, "player_spectate", "Spectate", BotMega.realPlayerX, BotMega.realPlayerY, "#0000FF", false);
  857.     connectToBotMegaServer();
  858.     insertCore();
  859.     setInterval(function() {
  860.       MC.BotMegaFreeCoins();
  861.     }, 5E3);
  862.     setInterval(function() {
  863.       drawMinimap();
  864.     }, 33);
  865.   },
  866.   reloadCore : function() {
  867.     console.log("Reloading Core.");
  868.     insertCore();
  869.   },
  870.   onAgarioCoreLoaded : function() {
  871.     window.skinHack = new skinHack();
  872.     console.log("Loading settings into agario core.");
  873.     core.setSkins(!$("#noSkins").is(":checked"));
  874.     core.setNames(!$("#noNames").is(":checked"));
  875.     core.setColors(!$("#noColors").is(":checked"));
  876.     core.setShowMass($("#showMass").is(":checked"));
  877.     core.setDarkTheme($("#darkTheme").is(":checked"));
  878.   }
  879. };
  880. var tempLeaderBoard = "";
  881. var tempLeaderBoardIndex = 1;
  882. CanvasRenderingContext2D.prototype._fillText = CanvasRenderingContext2D.prototype.fillText, CanvasRenderingContext2D.prototype.fillText = function() {
  883.   this._fillText.apply(this, arguments);
  884.   if ("Leaderboard" === arguments[0]) {
  885.     if ("" != tempLeaderBoard) {
  886.       BotMega.leaderboardData = tempLeaderBoard;
  887.       $("#leaderboard").val(BotMega.leaderboardData);
  888.     }
  889.     tempLeaderBoardIndex = 1;
  890.     tempLeaderBoard = "";
  891.   } else {
  892.     if (":teams" != $("#gamemode").val() && (0 == arguments[0].indexOf(tempLeaderBoardIndex + ".") && tempLeaderBoardIndex < 11)) {
  893.       tempLeaderBoard += arguments[0] + (tempLeaderBoardIndex <= 9 ? ", " : "");
  894.       tempLeaderBoardIndex++;
  895.     } else {
  896.       this._fillText.apply(this, arguments);
  897.     }
  898.   }
  899. }, CanvasRenderingContext2D.prototype._drawImage = CanvasRenderingContext2D.prototype.drawImage, CanvasRenderingContext2D.prototype.drawImage = function() {
  900.   if (arguments[0].src) {
  901.     if ("http://agar.io/img/background.png" == arguments[0].src) {
  902.       arguments[0].src = "";
  903.     }
  904.   }
  905.   this._drawImage.apply(this, arguments);
  906. };
  907. var miniMap = null;
  908. var minimapCtx = null;
  909. minimapBalls = {}, MinimapBall.prototype = {
  910.   draw : function(a, b, c) {
  911.     if (this.visible) {
  912.       this.lastX = (29 * this.lastX + this.x) / 30;
  913.       this.lastY = (29 * this.lastY + this.y) / 30;
  914.       var d = ((this.isDefault ? this.x : this.lastX) + BotMega.mapOffset) * b;
  915.       var e = ((this.isDefault ? this.y : this.lastY) + BotMega.mapOffset) * c;
  916.       a.fillStyle = this.color;
  917.       a.font = "10px Ubuntu";
  918.       a.textAlign = "center";
  919.       a.fillText("" == this.name ? "An unnamed cell" : this.name, d, e - 10);
  920.       a.beginPath();
  921.       a.arc(d, e, 4.5, 0, 2 * Math.PI, false);
  922.       a.closePath();
  923.       a.fillStyle = this.color;
  924.       a.fill();
  925.     }
  926.   }
  927. };
  928. var b = new XMLHttpRequest;
  929. b.open("GET", "/mc/agario.js", true), b.onload = function() {
  930.   var script = b.responseText;
  931.   script = replaceNormalFile(script, 'if(js.keyCode==32&&i1!="nick"){js.preventDefault()}', "");
  932.   script = replaceNormalFile(script, "showAds:function(i){if", "showAds:function(i){},showFuck:function(i){if");
  933.   script = replaceNormalFile(script, "showPromoBadge:function(", "showPromoBadge:function(i){},fuckbacks: function(");
  934.   script = replaceRegexFile(script, /(return\s\w+.tab.toUpperCase\(\)).indexOf\(\w+.toUpperCase\(\)\)!=-1/, "$1 != 'VETERAN'");
  935.   script = replaceRegexFile(script, /if\(\w+.shouldSkipConfigEntry\(\w+.productIdToQuantify.*visibility\)\)\{continue\}/, "");
  936.   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")');
  937.   script = replaceRegexFile(script, /var\si2=window.document.createElement..script..+head.appendChild.i2../i, "BotMega.reloadCore();");
  938.   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 BotMegaFreeCoins: function(){if($2){return;}$3;},");
  939.   script = replaceNormalFile(script, "onPlayerBanned:function(i)", "onPlayerBanned: function(i){},shitfacefuck:function(i)");
  940.   script = replaceNormalFile(script, "setPopupActiveState:function(i){", "setPopupActiveState:function(i){console.log('stopped annoying ad');return;");
  941.   eval(script);
  942.   var e = new XMLHttpRequest;
  943.   e.open("GET", "/", true);
  944.   e.onload = function() {
  945.     var a = e.responseText;
  946.     a = replaceNormalFile(a, "UCC6hurPo_LxL7C0YFYgYnIw", "UC_8Z8vnGJz_9jiTZXIs6izQ");
  947.     a = replaceRegexFile(a, /<footer[\S\s]*\/footer>/i, "");
  948.     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: Ubuntu;'> <font color='#7FFF00'>BotMe.ga</font><br>Bots: <a id='botCount'><font color='red'>0 / 5</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>");
  949.     a = replaceNormalFile(a, "<body>", '<body onload="BotMega.loadCore()">');
  950.     a = replaceRegexFile(a, /<script type="text\/javascript" src="mc\/agario\.js.*"><\/script>/i, "");
  951.     a = replaceRegexFile(a, /<div id="adsBottom".*display:block;">/i, '<div id="adsBottom" style="display:none">');
  952.     a = replaceNormalFile(a, '<div class="diep-cross" style="', '<div class="diep-cross" style="display:none;');
  953.     a = replaceNormalFile(a, '<div id="promo-badge-container">', '<div id="promo-badge-container" style="display:none;">');
  954.     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>');
  955.     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="' +
  956.     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">');
  957.     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>');
  958.     document.open();
  959.     document.write(a);
  960.     document.close();
  961.   };
  962.   e.send();
  963. }, b.send(), setInterval(function() {
  964.   BotMega.realPlayerX = BotMega.mapOffsetX + BotMega.playerX;
  965.   BotMega.realPlayerY = BotMega.mapOffsetY + BotMega.playerY;
  966.   moveBallOnMinimap("player_pointer", BotMega.realPlayerX, BotMega.realPlayerY);
  967.   moveBallOnMinimap("player_spectate", BotMega.realPlayerX, BotMega.realPlayerY);
  968. }, 50);
  969. var last_transmited_game_server = null;
  970. var socket = null;
  971. setInterval(function() {
  972.   if (!BotMega.isAuthorized) {
  973.     emitPosition();
  974.   }
  975. }, 10), setInterval(function() {
  976.   if (BotMega.isAuthorized) {
  977.     emitPosition();
  978.   }
  979.   emitLocalPosition();
  980.   transmit_current_server(false);
  981. }, 10);
  982. window.interval = setInterval(function() {
  983.   if (MC.coreWasLoaded == true && $("#nick")[0]) {
  984.     clearInterval(interval);
  985.     $("#agarTwitter").remove();
  986.     $("h2").replaceWith("<h2>BotMega</h2>");
  987.   }
  988. }, 100);
  989.  
  990.  
  991.  
  992. function skinHack() {
  993.     this.currentSkin = "";
  994.     this.configUrlBase = window.EnvConfig.config_url + '/' + localStorage.getItem('last_config_id') + '/';
  995.     this.configUrl = this.configUrlBase + 'GameConfiguration.json';
  996.     this.skinObj = {};
  997.     this.rotateInterval = 1000;
  998.     this.playerName = '';
  999.     this.canUseScript = false;
  1000.     this.downloadConfig();
  1001. }
  1002. skinHack.prototype = {
  1003.     downloadConfig: function() {
  1004.         var onDownload = this.onDownload.bind(this);
  1005.         $.ajax({
  1006.             type: "GET",
  1007.             url: this.configUrl,
  1008.             success: function(data) {
  1009.                 onDownload(data);
  1010.             },
  1011.             error: function(jqXHR, textStatus, errorThrown) {}
  1012.         });
  1013.     },
  1014.     onDownload: function(data) {
  1015.         this.handleSkinData(data);
  1016.         this.injectHtml();
  1017.         this.overrideSetNick();
  1018.         this.initSkinRotation();
  1019.         this.updateSkin();
  1020.     },
  1021.     handleSkinData: function(data) {
  1022.         var shopSkins = data.gameConfig['Shop - Skins'];
  1023.         var equippableSkins = data.gameConfig['Gameplay - Equippable Skins'];
  1024.         for (var i = 0; i < equippableSkins.length; i++) {
  1025.             var skin = equippableSkins[i];
  1026.             this.skinObj[skin.productId] = {
  1027.                 image: skin.image,
  1028.                 color: skin.cellColor
  1029.             };
  1030.         }
  1031.         for (var i = 0; i < shopSkins.length; i++) {
  1032.             var skin = shopSkins[i];
  1033.             this.skinObj[skin.productIdToQuantify].title = skin.title;
  1034.         }
  1035.     },
  1036.     injectHtml: function() {
  1037.         $('#advertisement').hide();
  1038.         $('.agario-promo').remove();
  1039.         $('.diep-cross').remove();
  1040.         $('#agario-web-incentive').remove();
  1041.         //$('<select id="skinsList" class="form-control" onchange="window.skinHack.updateSkin()" required=""></select><input type="checkbox" id="rotateSkinCheckBox">Rotate Skins</input>').insertBefore('#locationUnknown');
  1042.         // NOT STEALING FROM RAZOR...  90% OF THIS IS FROM SINGA/A. INFINITY ALREADY...
  1043.         //$('<div class="agario-panel agario-side-panel"><img id="skinPreview" class="circle bordered"src=""width="96"height="96"style="height: 96px; border: 3px solid rgb(0, 44, 108);margin: 0 auto;"><br><select id="skinsList"class="form-control"onchange="window.skinHack.updateSkin()"required=""></select><br><div id="skinRotator"style="margin: auto"><label>Skin Rotator: </label><div style="left: 13px" class="btn-group btn-toggle"><button class="btn btn-sm active btn-default">ON</button><button class="btn btn-sm active btn-primary">OFF</button></div></div></div>').insertAfter('.agario-party');
  1044.  
  1045.         this.addSkinOption({
  1046.             image: '',
  1047.             color: '0x00000000',
  1048.             title: 'Default Skin'
  1049.         });
  1050.         for (var idStr in this.skinObj) {
  1051.             if (this.skinObj.hasOwnProperty(idStr) && this.skinObj[idStr].title) {
  1052.                 this.addSkinOption(this.skinObj[idStr]);
  1053.             }
  1054.         }
  1055.  
  1056.         $('.btn-toggle').click(function() {
  1057.             $(this).find('.btn').toggleClass('active');
  1058.  
  1059.             if ($(this).find('.btn-primary').size() > 0) {
  1060.                 $(this).find('.btn').toggleClass('btn-primary');
  1061.             }
  1062.             if ($(this).find('.btn-info').size() > 0) {
  1063.                 $(this).find('.btn').toggleClass('btn-info');
  1064.             }
  1065.  
  1066.             $(this).find('.btn').toggleClass('btn-default');
  1067.         });
  1068.         this.preLoadSkins();
  1069.         $('#openfl-content').click(this.updateSkin.bind(this));
  1070.     },
  1071.     preLoadSkins: function() {
  1072.         for (var key in this.skinObj) {
  1073.             if (this.skinObj.hasOwnProperty(key)) {
  1074.                 (new Image()).src = this.configUrlBase + this.skinObj[key].image;
  1075.             }
  1076.         }
  1077.     },
  1078.     addSkinOption: function(skin) {
  1079.         skin.title = skin.title.split("product_name_skin_")[1];
  1080.         $('#skinsList').append('<option value="' + skin.image + ':' + skin.color + '">' + skin.title + '</option>');
  1081.     },
  1082.     overrideSetNick: function() {
  1083.         window.MC._setNick = window.MC.setNick;
  1084.         window.MC.setNick = function() {
  1085.             var name = arguments[0];
  1086.             if(name === "") {
  1087.               this.playerName = "BotMe.ga"
  1088.               name = "BotMe.ga";
  1089.               console.log('Overriding');
  1090.             } else {
  1091.               this.playerName = name;
  1092.             }
  1093.             window.MC._setNick(name);
  1094.            
  1095.             this.updateSkin();
  1096.         }.bind(this);
  1097.     },
  1098.     checkSubscription: function() {
  1099.         try {
  1100.             if (localStorage.getItem('canUseScript')) {
  1101.                 this.canUseScript = JSON.parse(localStorage.getItem('canUseScript').toLowerCase());
  1102.             } else {
  1103.                 localStorage.setItem('canUseScript', 'false');
  1104.                 return this.promptSubscription();
  1105.             }
  1106.             if (!this.canUseScript) {
  1107.                 return this.promptSubscription();
  1108.             }
  1109.             return this.canUseScript;
  1110.         } catch (err) {
  1111.             console.log(err);
  1112.         }
  1113.     },
  1114.     promptSubscription: function() {
  1115.         var ask = window.confirm("You must subscribe to Dosk to Use The Script");
  1116.         if (ask) {
  1117.             var win = window.open('https://www.youtube.com/channel/UCo8dhNSfZhKnhGx_awfMutw?sub_confirmation=1', '_blank');
  1118.             if (win) {
  1119.                 localStorage.setItem('canUseScript', 'true');
  1120.                 this.canUseScript = true;
  1121.                 this.updateSkin();
  1122.             } else {
  1123.                 alert('Please allow popups and refresh the page first!');
  1124.             }
  1125.         }
  1126.         return this.canUseScript();
  1127.     },
  1128.     updateSkin: function() {
  1129.      
  1130.             var skinArg = $('#skinsList').val().split(':');
  1131.             var usingHackSkin = skinArg[0].length > 0;
  1132.             var image = usingHackSkin ? this.configUrlBase + skinArg[0] : document.getElementsByClassName('circle bordered')[0].src;
  1133.             var color = usingHackSkin ?
  1134.                 parseInt(skinArg[1].slice(0, skinArg[1].length - 2)) :
  1135.             parseInt(this.rgbToHex(document.getElementsByClassName('circle bordered')[0].style.borderColor).slice(1, 7), 16);
  1136.             var name = this.playerName;
  1137.             window.core.registerSkin(name, null, image, image ? 2 : 0, image ? color : null);
  1138.             $('#skinPreview').attr('src', image)
  1139.             var arr = ['top', 'right', 'bottom', 'left'];
  1140.             for (var i = 0; i < array.length; i++) {
  1141.                 $('#skinPreview').css('border-' + array[i] + '-color', '#' + color.toString(16));
  1142.             }
  1143.    
  1144.     },
  1145.     rgbToHex: function(color) {
  1146.         if (color.substr(0, 1) === '#') {
  1147.             return color;
  1148.         }
  1149.         var digits = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(color);
  1150.  
  1151.         var red = parseInt(digits[2]);
  1152.         var green = parseInt(digits[3]);
  1153.         var blue = parseInt(digits[4]);
  1154.  
  1155.         var rgb = blue | (green << 8) | (red << 16);
  1156.         return digits[1] + '#' + rgb.toString(16);
  1157.     },
  1158.     initSkinRotation: function() {
  1159.         setInterval(function() {
  1160.             if ($('.btn-toggle').find('.btn-primary').html() === "ON") {
  1161.                 $('#skinsList')[0].selectedIndex = ($('#skinsList')[0].selectedIndex + 1) % $('#skinsList')[0].length;
  1162.                 this.updateSkin();
  1163.             }
  1164.         }.bind(this), this.rotateInterval);
  1165.     }
  1166. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement