// ==UserScript==
// @name Agar.io Gold
// @namespace agar.io/gold
// @version 0.9.2.9
// @description The smash hit game!
// @match http://agar.io/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js
// @connect agar.io
// @run-at document-start
// @grant none
// ==/UserScript==
var profile = 0;
var skins = [null, null, null, null, null, null, null, null, null, null];
var settings = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false];
var commands = [null, null, null, null, null, null, null, null, null, null, null, null, null, null];
function loadContent(){
var mainPanel_blockId = ['mainBlock', 'skinsBlock', 'partyBlock'];
var mainPanel_blockName = ['Agar.io Gold', 'Skins', 'Party'];
var iconSrc = ['http://i.imgur.com/7eiGkwT.png', 'http://i.imgur.com/0QZpM5k.png', 'http://i.imgur.com/ny1SwTc.png', 'http://i.imgur.com/NTiAjWl.png'];
var tab_blockId = ['profileBlock', 'settingsBlock', 'commandsBlock', 'themeBlock'];
var tab_blockName = ['Profile', 'Settings', 'Commands', 'Theme'];
var regionValue = ['US-Atlanta', 'BR-Brazil', 'EU-London', 'RU-Russia', 'TK-Turkey', 'JP-Tokyo', 'CN-China', 'SG-Singapore'];
var regionName = ['North America', 'South America', 'Europe', 'Russia', 'Turkey', 'East Asia', 'China', 'Oceania'];
var settingsName = ['No skins', 'No colors', 'No names', 'Show mass', 'Custom skins', 'Transparent skins', 'Transparent cells', 'Hide my name', 'Auto hide names and mass', 'Auto hide food', 'Game stats', 'Show indicators', 'Show background selectors', 'Show map borders', 'Show minimap', 'Enable chat', 'Enable Mouse controls', 'Invert mouse controls', 'Disable commands'];
var commandsName = ['New game', 'Stop movement', 'Split into 16', 'Eject mass', 'Toggle skins', 'Toggle colors', 'Toggle names', 'Toggle mass', 'Toggle indicators', 'Toggle background selectors', 'Toggle map borders', 'Toggle minimap', 'Toggle chat'];
var themesName = ['Classic', 'Gold', 'Custom'];
var newElement, newText, i;
jQuery.fx.off = true;
$(document.documentElement.childNodes).each(function(){
$(this.childNodes).each(function(){
if(this.nodeName == 'SCRIPT'){
if(this.src == 'http://agar.io/agario.core.js')
this.remove();
}
else
this.remove();
});
});
// <title>
document.title = 'Agar.io Gold';
// </title>
// <style>
newElement = document.createElement('style');
newElement.type = 'text/css';
$(newElement).append("*{margin: 0; padding: 0; font-family: Calibri; font-size: 18px; color: #646464; text-align: left;}body{overflow: hidden;}canvas{background-color: #111111;}#mainPanel{position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.4);}.block{padding: 14px; background-color: #ffffff; border-radius: 14px; font-weight: bold; text-align: center;}.container{position: relative; overflow: hidden; font-weight: normal; text-align: center;}.form-control{padding: 6px;}.btn{cursor: pointer; padding: 6px; font-weight: bold; text-align: center;}#mainBlock{position: absolute; top: 50%; right: 50%; margin-top: -242px; margin-right: -361px; width: 480px; height: 398px; padding-top: 72px; font-size: 72px;}#nick{position: relative; width: 240px; border: 2px solid rgba(0, 0, 0, 0.4); border-radius: 8px; font-size: 24px;}#play-btn{position: relative; width: 120px; background-color: #ff7400; border: 2px solid rgba(0, 0, 0, 0.1); border-radius: 8px; font-size: 24px; color: #ffffff;}#play-btn:hover{background-color: #f46f00;}#skinsBlock{position: absolute; top: 50%; left: 50%; margin-top: -242px; margin-left: -361px; width: 180px; font-size: 24px;}#skin{position: relative; width: 166px; border: 1px solid rgba(0, 0, 0, 0.4); border-radius: 4px;}#skinPreview{position: relative; left: 50%; margin-left: -50px; width: 100px; height: 100px; background-image: url('http://i.imgur.com/Xny8hRU.png'); background-position: center; background-size: cover; border-radius: 100px;}#previous{position: absolute; left: 0; bottom: 0; opacity: 0.2;}#previous:hover{opacity: 0.4;}#next{position: absolute; bottom: 0; right: 0; opacity: 0.2;}#next:hover{opacity: 0.4;}#partyBlock{position: absolute; left: 50%; bottom: 50%; margin-left: -361px; margin-bottom: -242px; width: 180px; font-size: 24px;}#region{position: relative; width: 180px; height: 36px; padding: 2px; border: 1px solid rgba(0, 0, 0, 0.4); border-radius: 4px;}#joinPartyToken{position: relative; width: 138px; padding-right: 34px; border: 1px solid rgba(0, 0, 0, 0.4); border-radius: 4px;}#join-party-btn{position: relative; width: 96px; background-color: #0074ff; border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 4px; color: #ffffff;}#join-party-btn:hover{background-color: #006ff4;}#create-party-btn{position: absolute; top: 50%; right: 0; margin-top: -17px; margin-right: 1px; padding: 1px; opacity: 0.2;}#create-party-btn:hover{opacity: 0.4;}#sideBar{z-index: 1; display: none; position: absolute; top: 0; left: 0; height: 100%; background-color: rgba(0, 0, 0, 0.8); text-align: center;}#menu{position: relative; top: 50%; margin-top: -254px; text-align: center;}.icon{position: relative; margin-top: 24px; padding: 14px;}.icon:hover{background-color: rgba(255, 255, 255, 0.2);}.tab{z-index: 2; display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.4);}#profileBlock, #settingsBlock, #commandsBlock, #themeBlock{position: absolute; top: 50%; left: 50%; margin: -254px -314px; width: 600px; height: 480px; font-size: 36px;}.close{position: absolute; top: 0; right: 0; margin: 6px; opacity: 0.2;}.close:hover{opacity: 0.4;}.container-scroll{height: 422px; overflow: auto;}::-webkit-scrollbar{width: 6px; background-color: #eeeeee; border-radius: 6px;}::-webkit-scrollbar-thumb{background-color: #cccccc; border-radius: 6px;}.ground{position: relative; margin: 2px 4px; padding: 14px; font-weight: normal;}.ground:hover{background-color: rgba(0, 0, 0, 0.1);}.switchOff{position: absolute; top: 50%; right: 14px; margin-top: -12px; width: 46px; height: 24px; background-color: #c4c4c4; border-radius: 24px;}.switchOff:after{content: ''; position: relative; float: left; margin: 1px; width: 22px; height: 22px; background-color: #ffffff; border-radius: 22px;}.switchOn{position: absolute; top: 50%; right: 14px; margin-top: -12px; width: 46px; height: 24px; background-color: #94cc40; border-radius: 24px;}.switchOn:after{content: ''; position: relative; float: right; margin: 1px; width: 22px; height: 22px; background-color: #ffffff; border-radius: 22px;}.key{position: absolute; top: 0; right: 0; width: 50px; height: 50px; background: none; border: none; color: #a4a4a4; text-align: center;}");
$('head').append(newElement);
// </style>
// <canvas id='canvas'>
newElement = document.createElement('canvas');
newElement.setAttribute('id', 'canvas');
$('body').append(newElement);
// </canvas>
// <div id='mainPanel'>
newElement = document.createElement('div');
newElement.setAttribute('id', 'mainPanel');
$('body').append(newElement);
// <div id='sideBar'>
newElement = document.createElement('div');
newElement.setAttribute('id', 'sideBar');
$('#mainPanel').append(newElement);
// <div id='menu'>
newElement = document.createElement('div');
newElement.setAttribute('id', 'menu');
$('#sideBar').append(newElement);
for(i = 0; i < iconSrc.length; i++){
// <div class='icon'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'icon');
$('#menu').append(newElement);
// <img />
newElement = document.createElement('img');
newElement.src = iconSrc[i];
$('.icon').last().append(newElement);
// </div>
}
// </div>
// </div>
for(i = 0; i < mainPanel_blockId.length; i++){
// <div class='block'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'block');
newElement.setAttribute('id', mainPanel_blockId[i]);
newText = document.createTextNode(mainPanel_blockName[i]);
$(newElement).append(newText);
$('#mainPanel').append(newElement);
// </div>
}
// <div class='block' id='mainBlock'>
// <div class='container'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container');
newElement.style.marginTop = '28px';
$('#mainBlock').append(newElement);
// <input type='text' class='form-control' id='nick'/>
newElement = document.createElement('input');
newElement.setAttribute('type', 'text');
newElement.setAttribute('class', 'form-control');
newElement.setAttribute('id', 'nick');
newElement.placeholder = 'Nickname';
newElement.maxLength = 15;
$('.container').last().append(newElement);
// </div>
// <div class='container'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container');
newElement.style.marginTop = '28px';
$('#mainBlock').append(newElement);
// <button class='btn btn-needs-server' id='play-btn'>
newElement = document.createElement('button');
newElement.type = 'submit';
newElement.setAttribute('class', 'btn btn-needs-server');
newElement.setAttribute('id', 'play-btn');
newElement.disabled = true;
newText = document.createTextNode('PLAY');
$(newElement).append(newText);
$('.container').last().append(newElement);
// </button>
// </div>
// <div class='container'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container');
newElement.style.marginTop = '28px';
newElement.innerHTML = 'Move your mouse to control your cell<br/>Press <b>Space</b> to split<br/>Press <b>W</b> to eject some mass';
$('#mainBlock').append(newElement);
// </div>
// <div class='block' id='skinsBlock'>
// <div class='container'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container');
newElement.style.marginTop = '14px';
$('#skinsBlock').append(newElement);
// <div id='skinPreview'>
newElement = document.createElement('div');
newElement.setAttribute('id', 'skinPreview');
$('.container').last().append(newElement);
// </div>
// <div id='previous'>
newElement = document.createElement('div');
newElement.setAttribute('id', 'previous');
$('.container').last().append(newElement);
// <img />
newElement = document.createElement('img');
newElement.src = 'http://i.imgur.com/yMOpYxj.png';
$('#previous').append(newElement);
// </div>
// <div id='next'>
newElement = document.createElement('div');
newElement.setAttribute('id', 'next');
$('.container').last().append(newElement);
// <img />
newElement = document.createElement('img');
newElement.src = 'http://i.imgur.com/NuIdOb3.png';
$('#next').append(newElement);
// </div>
// </div>
// <div class='container'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container');
newElement.style.marginTop = '14px';
$('#skinsBlock').append(newElement);
// <input type='text' class='form-control' id='skin'/>
newElement = document.createElement('input');
newElement.setAttribute('type', 'text');
newElement.setAttribute('class', 'form-control');
newElement.setAttribute('id', 'skin');
newElement.placeholder = 'Skin URL';
$('.container').last().append(newElement);
// </div>
// </div>
// <div class='block' id='partyBlock'>
// <div class='container'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container');
newElement.style.marginTop = '14px';
newElement.innerHTML = 'Play with your friends in the same map';
$('#partyBlock').append(newElement);
// </div>
// <div class='container'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container');
newElement.style.marginTop = '14px';
$('#partyBlock').append(newElement);
// <select id='region'>
newElement = document.createElement('select');
newElement.setAttribute('id', 'region');
newElement.required = true;
$('.container').last().append(newElement);
for(i = 0; i < regionValue.length; i++){
// <option>
newElement = document.createElement('option');
newElement.value = regionValue[i];
newText = document.createTextNode(regionName[i]);
$(newElement).append(newText);
$('#region').append(newElement);
// </option>
}
// </select>
// </div>
// <div class='container'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container');
newElement.style.marginTop = '6px';
$('#partyBlock').append(newElement);
// <input type='text' class='form-control partyToken' id='joinPartyToken'/>
newElement = document.createElement('input');
newElement.setAttribute('type', 'text');
newElement.setAttribute('class', 'form-control partyToken');
newElement.setAttribute('id', 'joinPartyToken');
newElement.placeholder = 'Party Token';
$('.container').last().append(newElement);
// <div id='create-party-btn'>
newElement = document.createElement('div');
newElement.setAttribute('id', 'create-party-btn');
$('.container').last().append(newElement);
// <img />
newElement = document.createElement('img');
newElement.src = 'http://i.imgur.com/Vb1cSKP.png';
$('#create-party-btn').append(newElement);
// </div>
// </div>
// <div class='container'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container');
newElement.style.marginTop = '14px';
$('#partyBlock').append(newElement);
// <button class='btn' id='join-party-btn'>
newElement = document.createElement('button');
newElement.setAttribute('class', 'btn');
newElement.setAttribute('id', 'join-party-btn');
newText = document.createTextNode('JOIN');
$(newElement).append(newText);
$('.container').last().append(newElement);
// </button>
// </div>
// </div>
for(i = 0; i < tab_blockId.length; i++){
// <div class='tab'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'tab');
$('#mainPanel').append(newElement);
// <div class='block'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'block');
newElement.setAttribute('id', tab_blockId[i]);
newText = document.createTextNode(tab_blockName[i]);
$(newElement).append(newText);
$('.tab').last().append(newElement);
// <div class='close'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'close');
$('.block').last().append(newElement);
// <img />
newElement = document.createElement('img');
newElement.src = 'http://i.imgur.com/qiFAg2E.png';
$('.close').last().append(newElement);
// </div>
// </div>
// </div>
}
// <div class='tab'>
// <div class='block' id='settingsBlock'>
// <div class='container container-scroll'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container container-scroll');
newElement.style.marginTop = '14px';
$('#settingsBlock').append(newElement);
for(i = 0; i < settingsName.length; i++){
// <div class='ground settings'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'ground settings');
newText = document.createTextNode(settingsName[i]);
$(newElement).append(newText);
$('.container').last().append(newElement);
// <div class='switchOff'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'switchOff');
$('.ground').last().append(newElement);
// </div>
// </div>
}
// </div>
// </div>
// </div>
// <div class='tab'>
// <div class='block' id='commandsBlock'>
// <div class='container container-scroll'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container container-scroll');
newElement.style.marginTop = '14px';
$('#commandsBlock').append(newElement);
for(i = 0; i < commandsName.length; i++){
// <div class='ground commands'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'ground commands');
newText = document.createTextNode(commandsName[i]);
$(newElement).append(newText);
$('.container').last().append(newElement);
// <input type='button' class='key'/>
newElement = document.createElement('input');
newElement.setAttribute('type', 'button');
newElement.setAttribute('class', 'key');
$('.ground').last().append(newElement);
// </div>
}
// </div>
// </div>
// </div>
// <div class='tab'>
// <div class='block' id='themeBlock'>
// <div class='container container-scroll'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container container-scroll');
newElement.style.marginTop = '14px';
$('#themeBlock').append(newElement);
for(i = 0; i < themesName.length; i++){
// <div class='ground settings'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'ground theme');
newText = document.createTextNode(themesName[i]);
$(newElement).append(newText);
$('.container').last().append(newElement);
// </div>
}
// </div>
// </div>
// </div>
// </div>
// </body>
}
window.game = {
play: false,
playerNick: '',
playerX: 0,
playerY: 0,
playerCells: [],
playerCellsSize: [],
playerSmallestCell: 0,
playerLargestCell: 0,
playerMass: 0,
playerScore: 0,
playerSTE: null,
mapSize: 14142,
mapOffset: 7071,
mapOffsetX: 0,
mapOffsetY: 0,
mapOffsetFixed: false,
zoomValue: 0,
viewScale: 1,
canvasScale: 1,
nameMemOffset: null,
cellMemOffset: null,
idOffset: null,
idMemOffset: null,
food: true,
foodCache: [],
foodColor: '#aaaaaa',
virusColor: '#aaaaaa',
virusStrokeColor: '#aaaaaa',
globalAlpha: 1,
virusAlpha: 0.4,
showSkins: true,
hideMass: true,
customSkins: true,
hideMyName: true,
hideMyMass: true,
autoHideFood: true,
autoHideCellsStats: true,
getString: null,
getSkin: null,
setMapCoordinates: function(a, b, c, d, e, f){
if(f - e == 24 && c - a > 14e3 && d - b > 14e3){
this.mapOffsetX = this.mapOffset - c;
this.mapOffsetY = this.mapOffset - d;
this.mapOffsetFixed = true;
}
},
calculateMass: function(){
if(this.playerCellsSize.length !== 0){
this.playerSmallestCell = this.playerCellsSize[0];
this.playerLargestCell = this.playerCellsSize[0];
for(var i = 1; i < this.playerCellsSize.length; i++){
if(this.playerCellsSize[i] < this.playerSmallestCell)
this.playerSmallestCell = this.playerCellsSize[i];
else if(this.playerCellsSize[i] > this.playerLargestCell)
this.playerLargestCell = this.playerCellsSize[i];
}
if(this.playerMass > this.playerScore || !this.playerScore)
this.playerScore = this.playerMass;
var e = this.playerLargestCell;
this.playerSTE = e > 36? Math.floor(e * (e > 1e3? 0.35: 0.38)): null;
}
},
setAutoHideCellsStats: function(e){
return e < 36 || this.viewScale < 0.5;
}
};
function setGameContext(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4){
var e = xmlhttp.responseText;
e = e.replace(/(\(function\(([\w$]+)\){)/i, '$1 var agario = $2.game, gameContext = null;');
e = e.replace(/[\w$]+\(\w,\w\);[\w$]+\(\w,\w\);[\w$]+\(\w,\w\);[\w$]+\(\w,\w\);(\w\[\w\+\d+>>0\]=1;\w=\w;return})/i, '$1');
e = e.replace(/[\w$]+\(\w,\d+,15\);else/i, '{}');
e = e.replace(/(\d\.\d;return}function\s*)([\w$]+\(.,.\)){/i, '$1 $2{return;');
e = e.replace(/(([\w$]+)=[\w$]+\.getContext\(\"2d\"\);)/i, "if($2.id == 'canvas'){$1 gameContext = $2;}else{$1}");
e = e.replace(/(function\s*([\w$]+)\(\w\){return\s*[\w$]+\(\w,\w\)})/i, '$1 agario.getString = $2;');
e = e.replace(/(\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);)/i, '$1 if(agario.setMapCoordinates){agario.setMapCoordinates($3, $5, $7, $9, $2, $8);}');
e = e.replace(/([\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 agario.viewScale = $2; agario.playerX = $4; agario.playerY = $5;');
e = e.replace(/if\((\+\w\[\w>>3\])<1\.0\)/i, 'if($1 < agario.zoomValue)');
e = e.replace(/(if\(\(\w\[\d+\]\|0\)!=0\?\(\w\[\d+\]\|\w\[\w\+\d+>>0\]\)<<24>>24==0:0\))(\w)=\w\[\w\+\d+>>2\]\|0;/i, '$1 $2 = 0;');
e = e.replace(/(do{\w=\+\w\[\(\w\[\w>>2\]\|0\)\+\d+>>2];\w=\w\+\s*)(\+\(~~\+\w\(\+\(\w\*\w\/100\.0\)\)\|0\))(;\w=\w\+4\|0}while\(\(\w\|0\)!=\(\w\|0\)\);(\w)=(\w);)/i, 'agario.playerCellsSize = []; $1 $2; agario.playerCellsSize.push($2) $3 agario.playerMass = $5; if(agario.calculateMass){agario.calculateMass();}');
e = e.replace(/(if\(\(\w\[\d+\]\|0\)!=0\?\(\w\[\d+\]\|\w\[(\w)\+\d+>>0\]\)<<24>>24==0:0\))((\w)=\w\[(\w)\+\d+>>2\]\|0;)/i, 'agario.cellMemOffset = $2; $1 if(agario.customSkins){$4 = 0;} else{$3}');
e = e.replace(/do\s*if\((\w)\){((\w)=!\((\+\w\[\w>>2\])<=20\.0\);)([\w$]+\(\d+,\w\[\w>>2]\|0\)\|0;[\w$]+\(\d+,\w\[\w>>2]\|0,(\+\(\+\w\[\w>>2\]\)),(\+\(\+\w\[\w>>2\]\)),\+\(\+\w\[\w>>2\])\+5\.0(\),0\.0,6\.283185307179586,0\)\|0;[\w$]+\(\d+,\w\[\w>>2]\|0\)\|0;\w=\w\[\w>>2\]\|0;)if\(\w\){([\w$]+\(\d+,\w\|0,(\w&255\|0),(\w&255\|0),(\w&255\|0)\)\|0;)([\w$]+\(\d+,\w\[\w>>2]\|0\)\|0;)/i, "var nick = null, skin = null, cellSize = null, isFood = false, isVirus = false, isPlayerCell = false, skipCell = false; do if($1 = 1, $1){cellSize = $4; $2 if(!$3){isFood = true; if(agario.autoHideFood && agario.playerMass > 1000){agario.food = false;}agario.foodCache.push({x: $6, y: $7, size: cellSize});}$5 $8 if($3){if(gameContext){agario.globalApha = gameContext.globalAlpha; if(gameContext.lineJoin == 'miter'){isVirus = true; gameContext.fillStyle = agario.virusColor; gameContext.strokeStyle = agario.virusStrokeColor; gameContext.stroke(); gameContext.globalAlpha = agario.virusAlpha;}else{if(agario.nameMemOffset && agario.cellMemOffset && agario.getString){if((a[agario.cellMemOffset + agario.nameMemOffset + 4 >> 0] & 1) == 0 | 0){nick = agario.getString(agario.cellMemOffset + agario.nameMemOffset + 5);}else{nick = agario.getString(c[agario.cellMemOffset + agario.nameMemOffset + 12 >> 2] | 0);}}if(nick && nick.length > 0){if(agario.showSkins && agario.customSkins && agario.getSkin){skin = agario.getSkin(nick);}}if(agario.play){if(agario.cellMemOffset && agario.idOffset && agario.idMemOffset){var idA = c[agario.cellMemOffset + agario.idOffset >> 2] | 0; var idB = c[agario.idMemOffset] | 0; var idC = c[agario.idMemOffset + 1] | 0; loop: do{if((idB | 0) != (idC | 0)){while(true){if((c[idB >> 2] | 0) == (idA | 0)){break loop;}idB = idB + 4 | 0; if((idB | 0) == (idC | 0)){idB = idC; break;}}}}while(false); isPlayerCell = (idB | 0) != (idC | 0);}if(isPlayerCell && agario.playerCells){agario.playerCells.push({x: $6, y: $7, size: cellSize});}}else{$9}}$13 gameContext.globalAlpha = agario.globalApha; if(skin){gameContext.save(); gameContext.clip(); gameContext.drawImage(skin, $6 - cellSize, $7 - cellSize, 2 * cellSize, 2 * cellSize); gameContext.restore();}}else{$9 $13}break;");
e = e.replace(/(if\(\(\w\[\w\+\d+>>0\]\|0\)==0\?\(\(\(\(\w\[\w\+\d+>>2\]\|0\)\+\(\w\[\d+\]\|0\)\|0\)>>>0\)%10\|0\|0\)!=0:0\){\w=\w\[\w>>2\]\|0;[\w$]+\(\d+,\w\|0\)\|0;\w=\w;return})([\w$]+\(\w,\w\);)/i, 'if(gameContext && agario){gameContext.globalAlpha = agario.globalApha;}$1 if(!(skipCell || (agario.autoHideCellsStats && agario.setAutoHideCellsStats && cellSize && !isFood && !isVirus && !isPlayerCell && agario.setAutoHideCellsStats(cellSize)))){$2}');
e = e.replace(/(\w=0;\w=\w\[\w\+(\d+)>>2\]\|0;\w=\w\[(\d+)\]\|0;\w=\w\[\d+\]\|0;)(\w:do)/i, '$1 agario.idOffset = $2; agario.idMemOffset = $3; $4');
e = e.replace(/(\w=\w\+5\+\(\(\w\|0\)\/)2(\|0\)\|0)/i, '$1 1.5 $2');
e = e.replace(/((\w)=\+[\w$]+\(\+\(\+[\w$]+\(\d+\)\*10.0\)\)\/10.0;)/i, '$1 if($2 < 0.3){$2 = 0.3}');
e = e.replace(/((\w)=\(\w\|0\)<20\?20.0:\+\(\w\|0\);)/i, '$1 $2 *= 2;');
e = e.replace(/do\s+if\((\w)\|(\(\w\[\d+\]\|0\)\!=0)\){/i, 'do if(($2 && !($1 && agario.hideMyName)) || !agario.nameMemOffset){');
e = e.replace(/(\w=\w\+(\d+)\|0;\w=~~\(\+\w\[\w\+\d+>>2\]\*\.3\);)/i, '$1 agario.nameMemOffset = $2;');
e = e.replace(/(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}})((\w\[\w>>2\])=~~\+[\w$]+\(\+\((\w)\*\w\/100\.0\)\);)/i, '$140.0 || $5 && agario.hideMyMass || !$5 && agario.hideMass $3 $6');
eval(e);
}
};
xmlhttp.open('GET', 'http://agar.io/agario.core.js', true);
xmlhttp.send(null);
}
function getSkin(){
var img = document.createElement('img');
img.src = document.getElementById('skin').value;
img.onload = (function(){
document.getElementById('skinPreview').style.backgroundImage = 'url(' + img.src + ')';
skins[profile] = img.src;
});
img.onerror = (function(){
document.getElementById('skinPreview').style.backgroundImage = "url('http://i.imgur.com/Xny8hRU.png')";
document.getElementById('skin').value = null;
skins[profile] = null;
});
}
function changeProfile(i){
if(i == 'previous'){
if(profile > 0)
profile--;
else
profile = 9;
}
else if(i == 'next'){
if(profile < 9)
profile++;
else
profile = 0;
}
document.getElementById('skinPreview').style.backgroundImage = skins[profile]? 'url(' + skins[profile] + ')': "url('http://i.imgur.com/Xny8hRU.png')";
document.getElementById('skin').value = skins[profile];
}
function toggleSetting(i){
settings[i] = !settings[i];
if(settings[i])
$('.settings')[i].children[0].className = 'switchOn';
else
$('.settings')[i].children[0].className = 'switchOff';
}
function changeKey(i, e){
for(var j = 0; j < commands.length; j++)
if(e == commands[j])
return;
commands[i] = e;
$('.key')[i].value = String.fromCharCode(e);
}
function stopMovement(){
$('canvas').trigger($.Event('mousemove', {clientX: window.innerWidth / 2, clientY: window.innerHeight / 2}));
}
function splitInto(n){
for(var i = 0; i < n; i++){
$('body').trigger($.Event('keydown', {keyCode: 32}));
$('body').trigger($.Event('keyup', {keyCode: 32}));
}
}
function ejectMass(){
var n = setInterval(function(){
window.onkeydown({keyCode: 87});
window.onkeyup({keyCode: 87});
}, null);
$(document).on('keyup', function(){
clearInterval(n);
});
}
function newGame(){
$('#play-btn').click();
}
$(function(){
loadContent();
setGameContext();
$(document).on('mousemove', function(e){
if($('#mainPanel').is(e.target) && e.pageX === 0)
$('#sideBar').show();
else if($('.tab').is(e.target) || e.pageX > 92)
$('#sideBar').hide();
});
$(document).on('keydown', function(e){
if(!$('input').is(e.target)){
switch(e.keyCode){
case commands[0]:
newGame();
break;
case commands[1]:
stopMovement();
break;
case commands[2]:
splitInto(4);
break;
case commands[3]:
ejectMass();
break;
case commands[4]:
toggleSetting(0);
break;
case commands[5]:
toggleSetting(1);
break;
case commands[6]:
toggleSetting(2);
break;
case commands[7]:
toggleSetting(3);
break;
case commands[8]:
toggleSetting(11);
break;
case commands[9]:
toggleSetting(12);
break;
case commands[10]:
toggleSetting(13);
break;
case commands[11]:
toggleSetting(14);
break;
case commands[12]:
toggleSetting(15);
break;
}
}
});
$('#skin').on('change', function(){
getSkin();
});
$('#skinPreview').on('click', function(){
$('#skin').select();
});
$('#previous').on('click', function(){
changeProfile('previous');
});
$('#next').on('click', function(){
changeProfile('next');
});
$('#region').on('change', function(){
MC.setRegion($('#region').val());
});
$('#play-btn').on('click', function(){
FB.getLoginStatus(function(e){
if(e.status !== 'connected')
facebookLogin();
});
MC.setNick(document.getElementById('nick').value);
});
$('.icon').on('click', function(){
var i = $(this).index();
$($('.tab')[i]).show();
});
$('.tab').on('click', function(e){
if(!$(this).has(e.target).length)
$(this).hide();
});
$('.close').on('click', function(){
$(this).parents('.tab').hide();
});
$('.settings').on('click', function(){
var i = $(this).index();
toggleSetting(i);
});
$('.commands').on('click', function(){
var i = $(this).index();
$($('.key')[i]).focus();
$(this).on('keydown', function(e){
changeKey(i, e.keyCode);
$($('.key')[i]).blur();
});
});
});