Advertisement
NexuzP

Botmega Edited!

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