Advertisement
Guest User

Just a test

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