Advertisement
Guest User

Untitled

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