// ==UserScript==
// @name Agar.io Gold
// @namespace agar.io/gold
// @version 0.9.4.3
// @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 = [];
var settings = [];
var commands = [];
function loadContent(){
var mainPanelBlockId = ['mainBlock', 'skinsBlock', 'partyBlock'];
var mainPanelBlockName = ['Agar.io Gold', 'Skins', 'Party'];
var tabBlockId = ['profileBlock', 'settingsBlock', 'commandsBlock', 'themeBlock'];
var tabBlockName = ['Profile', 'Settings', 'Commands', 'Theme'];
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 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 settingsId = ['noSkins', 'noColors', 'noNames', 'showMass', 'hideFood', 'customSkins', 'transparentSkins', 'transparentCells', 'hideMyName', 'hideMyMass', 'autoHideNamesAndMass', 'autoHideFood', 'gameStats', 'showIndicators', 'showBackgroundSelectors', 'showMapBorders', 'showMinimap', 'enableChat', 'enableMouseControls', 'invertMouseControls', 'disableCommands'];
var settingsName = ['No skins', 'No colors', 'No names', 'Show mass', 'Hide food', 'Custom skins', 'Transparent skins', 'Transparent cells', 'Hide my name', 'Hide my mass', '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 food', '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;} span{padding: 6px; color: #eeeeee;} #stats{display: none; position: absolute; left: 0; bottom: 0; margin: 14px; padding: 6px; background-color: rgba(0, 0, 0, 0.2);} #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;} #skinURL{position: relative; width: 166px; border: 1px solid rgba(0, 0, 0, 0.4); border-radius: 4px;} #skinsPreview{position: relative; left: 50%; margin-left: -50px; width: 100px; height: 100px; 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='stats'>
newElement = document.createElement('div');
newElement.setAttribute('id', 'stats');
$('body').append(newElement);
// </div>
// <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 < mainPanelBlockId.length; i++){
// <div class='block'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'block');
newElement.setAttribute('id', mainPanelBlockId[i]);
newText = document.createTextNode(mainPanelBlockName[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='skinsPreview'>
newElement = document.createElement('div');
newElement.setAttribute('id', 'skinsPreview');
$('.container').last().append(newElement);
// </div>
// <div class='change' id='previous'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'change');
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 class='change' id='next'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'change');
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='skinURL'/>
newElement = document.createElement('input');
newElement.setAttribute('type', 'text');
newElement.setAttribute('class', 'form-control');
newElement.setAttribute('id', 'skinURL');
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 < tabBlockId.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', tabBlockId[i]);
newText = document.createTextNode(tabBlockName[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 < settingsId.length; i++){
// <div class='ground settings'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'ground settings');
newElement.setAttribute('id', settingsId[i]);
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.agario = {
play: false,
viewScale: 1,
canvasScale: 1,
mapSize: 14142,
mapOffset: 7071,
mapOffsetX: 0,
mapOffsetY: 0,
mapOffsetFixed: false,
zoomValue: 0,
playerNick: '',
playerSkin: null,
playerX: 0,
playerY: 0,
playerCells: [],
playerCellsSize: [],
playerSmallestCell: 0,
playerLargestCell: 0,
playerMass: 0,
playerScore: 0,
playerSTE: 0,
foodCache: [],
foodColor: '#aaaaaa',
virusColor: '#aaaaaa',
virusStrokeColor: '#aaaaaa',
virusAlpha: 0.4,
globalAlpha: 1,
noSkins: false,
noColors: false,
noNames: false,
showMass: false,
hideFood: false,
customSkins: false,
transparentSkins: false,
transparentCells: false,
hideMyName: false,
hideMyMass: false,
autoHideNamesAndMass: false,
autoHideFood: false,
gameStats: false,
showIndicators: false,
showBackgroundSelectors: false,
showMapBorders: false,
showMinimap: false,
enableChat: false,
enableMouseControls: false,
invertMouseControls: false,
disableCommands: false,
getString: null,
idOffset: null,
idMemOffset: null,
nameMemOffset: null,
cellMemOffset: null,
mapCoordinates: 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;
}
},
setCustomSkins: function(e){
return e == this.playerNick? this.playerSkin: null;
},
setAutoHideNamesAndMass: function(e){
return e < 36 || this.viewScale < 0.5 && e < 18 / this.viewScale;
},
setGameStats: function(){
if(this.playerCellsSize.length){
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 s = this.playerLargestCell;
this.playerSTE = s > 34? Math.floor(s * (s > 1e3? 0.35: 0.38)): null;
}
}
};
function setGameContext(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4){
var a = xmlhttp.responseText;
a = a.replace(/(\(function\(([\w$]+)\){)/i, '$1 var agario = $2.agario, gameContext = null;');
a = a.replace(/[\w$]+\(\w,\w\);[\w$]+\(\w,\w\);[\w$]+\(\w,\w\);[\w$]+\(\w,\w\);(\w\[\w\+\d+>>0\]=1;\w=\w;return})/i, '$1');
a = a.replace(/[\w$]+\(\w,\d+,15\);else/i, '{}');
a = a.replace(/(\d\.\d;return}function\s*)([\w$]+\(.,.\)){/i, '$1 $2{return;');
a = a.replace(/(([\w$]+)=[\w$]+\.getContext\(\"2d\"\);)/i, "if($2.id == 'canvas'){$1 gameContext = $2;} else{$1}");
a = a.replace(/(function\s*([\w$]+)\(\w\){return\s*[\w$]+\(\w,\w\)})/i, '$1 agario.getString = $2;');
a = a.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.mapCoordinates){agario.mapCoordinates($3, $5, $7, $9, $2, $8);}');
a = a.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;');
a = a.replace(/if\((\+\w\[\w>>3\])<1\.0\)/i, 'if($1 < agario.zoomValue)');
a = a.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.setGameStats){agario.setGameStats();}');
a = a.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.noSkins || agario.customSkins){$4 = 0;} else{$3}');
a = a.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.hideFood || agario.autoHideFood && agario.playerMass > 999){break;} agario.foodCache.push({x: $6, y: $7, size: cellSize});} $5 $8 if($3){if(gameContext){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){if(!agario.noSkins && agario.customSkins && agario.setCustomSkins){skin = agario.setCustomSkins(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;");
a = a.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.autoHideNamesAndMass && agario.setAutoHideNamesAndMass && cellSize && !isFood && !isVirus && !isPlayerCell && agario.setAutoHideNamesAndMass(cellSize)))){$2}');
a = a.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');
a = a.replace(/(\w=\w\+5\+\(\(\w\|0\)\/)2(\|0\)\|0)/i, '$1 1.5 $2');
a = a.replace(/((\w)=\+[\w$]+\(\+\(\+[\w$]+\(\d+\)\*10.0\)\)\/10.0;)/i, '$1 if($2 < 0.3){$2 = 0.3}');
a = a.replace(/((\w)=\(\w\|0\)<20\?20.0:\+\(\w\|0\);)/i, '$1 $2 *= 2;');
a = a.replace(/do\s+if\((\w)\|(\(\w\[\d+\]\|0\)\!=0)\){/i, 'do if(($2 && !($1 && agario.hideMyName)) || !agario.nameMemOffset){');
a = a.replace(/(\w=\w\+(\d+)\|0;\w=~~\(\+\w\[\w\+\d+>>2\]\*\.3\);)/i, '$1 agario.nameMemOffset = $2;');
a = a.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.showMass $3 $6');
eval(a);
}
};
xmlhttp.open('GET', 'http://agar.io/agario.core.js', true);
xmlhttp.send(null);
}
function gameStats(){
document.getElementById('stats').innerHTML = '<span>Mass: ' + window.agario.playerMass + '</span><span>Score: ' + window.agario.playerScore + '</span>';
if(window.agario.gameStats && $('#mainPanel').is(':hidden'))
$('#stats').show();
else
$('#stats').hide();
window.requestAnimationFrame(gameStats);
}
function getPlayerNick(){
window.agario.playerNick = document.getElementById('nick').value;
}
function getPlayerSkin(){
var img = new Image();
img.src = document.getElementById('skinURL').value;
img.onload = (function(){
window.agario.playerSkin = img;
document.getElementById('skinsPreview').style.backgroundImage = 'url(' + img.src + ')';
skins[profile] = img.src;
});
img.onerror = (function(){
window.agario.playerSkin = null;
document.getElementById('skinsPreview').style.backgroundImage = null;
document.getElementById('skinURL').value = null;
skins[profile] = null;
});
}
function changeProfile(){
if(this.id == 'previous'){
if(profile > 0)
profile--;
else
profile = 9;
}
else if(this.id == 'next'){
if(profile < 9)
profile++;
else
profile = 0;
}
document.getElementById('skinURL').value = skins[profile]? skins[profile]: null;
getPlayerSkin();
}
function toggleSettings(id){
window.agario[id] = !window.agario[id];
document.getElementById(id).children[0].className = window.agario[id]? 'switchOn': 'switchOff';
}
function setCommands(n, k){
for(var i = 0; i < commands.length; i++){
if(k == commands[i]){
commands[i] = null;
$('.key')[i].value = null;
break;
}
}
if(k == 46){
commands[n] = null;
$('.key')[n].value = null;
}
else{
commands[n] = k;
$('.key')[n].value = String.fromCharCode(k);
}
}
function newGame(){
$('#play-btn').click();
}
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(){
loadContent();
setGameContext();
gameStats();
$(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(!window.agario.disableCommands && !$('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]:
toggleSettings('noSkins');
break;
case commands[5]:
toggleSettings('noColors');
break;
case commands[6]:
toggleSettings('noNames');
break;
case commands[7]:
toggleSettings('showMass');
break;
case commands[8]:
toggleSettings('hideFood');
break;
case commands[9]:
toggleSettings('showIndicators');
break;
case commands[10]:
toggleSettings('showBackgroundSelectors');
break;
case commands[11]:
toggleSettings('showMapBorders');
break;
case commands[12]:
toggleSettings('showMinimap');
break;
case commands[13]:
toggleSettings('enableChat');
break;
}
}
});
$('#region').on('change', function(){
MC.setRegion($('#region').val());
});
$('#play-btn').on('click', function(){
getPlayerNick();
MC.setNick(document.getElementById('nick').value);
FB.getLoginStatus(function(e){
if(e.status !== 'connected')
facebookLogin();
});
});
$('#skinURL').on('change', getPlayerSkin);
$('#skinsPreview').on('click', function(){
$('#skinURL').select();
});
$('.change').on('click', changeProfile);
$('.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 id = this.id;
toggleSettings(id);
});
$('.commands').on('click', function(){
var i = $(this).index();
$($('.key')[i]).focus();
$(this).on('keydown', function(e){
setCommands(i, e.keyCode);
$($('.key')[i]).blur();
});
});
});