// ==UserScript==
// @name Agar.io Gold
// @namespace agar.io/gold
// @version 0.9.1.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 = [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];
function removeElements(){
$(document.documentElement.childNodes).each(function(){
$(this.childNodes).each(function(){
if(this.nodeName !== 'SCRIPT')
this.remove();
});
});
}
function loadContent(){
var mainPanel_blockId = ['mainBlock', 'skinsBlock', 'partyBlock'];
var mainPanel_blockText = ['Agar.io Gold', 'Skins', 'Party'];
var menu_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_blockText = ['Profile', 'Settings', 'Commands', 'Theme'];
var regionValue = ['US-Atlanta', 'BR-Brazil', 'EU-London', 'RU-Russia', 'TK-Turkey', 'JP-Tokyo', 'CN-China', 'SG-Singapore'];
var regionText = ['North America', 'South America', 'Europe', 'Russia', 'Turkey', 'East Asia', 'China', 'Oceania'];
var settingsText = ['No skins', 'No colors', 'No names', 'Show mass', 'Custom skins', 'Transparent skins', 'Transparent cells', 'Hide own 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 commandsText = ['Stop movement', 'Double split', '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 themeText = ['Classic', 'Gold', 'Custom'];
var newElement, newText, i;
// <title>
document.title = 'Agar.io Gold';
// </title>
// <style>
newElement = document.createElement('style');
newElement.type = 'text/css';
$(newElement).append("@charset 'UTF-8'; *{margin: 0; padding: 0; font-family: Calibri; font-size: 18px; color: #646464; text-align: left;} ::-webkit-scrollbar{display: none;} #mainPanel{position: absolute; top: 0; left: 0; bottom: 0; right: 0; background-color: rgba(0, 0, 0, 0.4);} #sideBar{z-index: 1; display: none; position: absolute; height: 100%; background-color: #000000; 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; 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;} #mainBlock{position: absolute; top: 50%; right: 50%; margin-top: -243px; margin-right: -361px; width: 480px; height: 400px; padding-top: 72px; font-size: 72px;} #skinsBlock{position: absolute; top: 50%; left: 50%; margin-top: -243px; margin-left: -361px; width: 180px; font-size: 24px;} #partyBlock{position: absolute; left: 50%; bottom: 50%; margin-left: -361px; margin-bottom: -243px; width: 180px; font-size: 24px;} #profileBlock, #settingsBlock, #commandsBlock, #themeBlock{position: absolute; top: 50%; left: 50%; margin: -254px -314px; width: 600px; height: 480px; overflow: auto; font-size: 36px;} .close{position: absolute; top: 0; right: 0; margin: 6px; opacity: 0.2;} .close:hover{opacity: 0.4;} .container{position: relative; overflow: hidden; font-weight: normal; text-align: center;} .ground{position: relative; margin: 1px; padding: 14px; font-weight: normal;} .ground:hover{background-color: rgba(0, 0, 0, 0.1);} #skin{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;} .form-control{padding: 6px; font-weight: normal;} #nick{position: relative; width: 240px; border: 2px solid rgba(0, 0, 0, 0.4); border-radius: 8px; font-size: 24px;} #skinURL{position: relative; width: 166px; border: 1px solid rgba(0, 0, 0, 0.4); border-radius: 4px;} #region{position: relative; width: 100%; 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;} .btn{cursor: pointer; padding: 6px; font-weight: bold; text-align: center;} #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;} #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;} .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; font-weight: normal; 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 < menu_iconSrc.length; i++){
// <div class='icon'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'icon');
$('#menu').append(newElement);
// <img />
newElement = document.createElement('img');
newElement.src = menu_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_blockText[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='skin'>
newElement = document.createElement('div');
newElement.setAttribute('id', 'skin');
$('.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='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 class='form-control' id='region'>
newElement = document.createElement('select');
newElement.setAttribute('class', 'form-control');
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(regionText[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_blockText[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'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container');
newElement.style.marginTop = '14px';
$('#settingsBlock').append(newElement);
for(i = 0; i < settingsText.length; i++){
// <div class='ground settings'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'ground settings');
newText = document.createTextNode(settingsText[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'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container');
newElement.style.marginTop = '14px';
$('#commandsBlock').append(newElement);
for(i = 0; i < commandsText.length; i++){
// <div class='ground commands'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'ground commands');
newText = document.createTextNode(commandsText[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'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'container');
newElement.style.marginTop = '14px';
$('#themeBlock').append(newElement);
for(i = 0; i < themeText.length; i++){
// <div class='ground settings'>
newElement = document.createElement('div');
newElement.setAttribute('class', 'ground theme');
newText = document.createTextNode(themeText[i]);
$(newElement).append(newText);
$('.container').last().append(newElement);
// </div>
}
// </div>
// </div>
// </div>
// </div>
// </body>
}
function setGameProperties(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4){
var s = xmlhttp.responseText;
// Set zoom
s = s.replace(/if\((\+\w\[\w>>3\])<1\.0\)/i, 'if($1 < 0)');
// Set custom skins
s = s.replace(/(if\(\(\w\[\d+\]\|0\)!=0\?\(\w\[\d+\]\|\w\[\w\+\d+>>0\]\)<<24>>24==0:0\))(\w)=\w\[\w\+\d+>>2\]\|0;else/i, '$1 $2 = 0; else');
eval(s);
}
};
xmlhttp.open('GET', 'http://agar.io/agario.core.js', true);
xmlhttp.send(null);
}
function getSkin(){
var img = document.createElement('img');
img.src = document.getElementById('skinURL').value;
img.onload = (function(){
document.getElementById('skin').style.backgroundImage = 'url(' + img.src + ')';
skins[profile] = img.src;
});
img.onerror = (function(){
document.getElementById('skin').style.backgroundImage = "url('http://i.imgur.com/Xny8hRU.png')";
document.getElementById('skinURL').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('skin').style.backgroundImage = skins[profile]? 'url(' + skins[profile] + ')': "url('http://i.imgur.com/Xny8hRU.png')";
document.getElementById('skinURL').value = skins[profile];
}
function toggleSetting(i){
if(settings[i] === false){
settings[i] = true;
$('.settings')[i].children[0].className = 'switchOn';
}
else if(settings[i] === true){
settings[i] = false;
$('.settings')[i].children[0].className = 'switchOff';
}
}
function changeKey(i, e){
var j;
for(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){
var i;
for(i = 0; i < n; i++){
$('body').trigger($.Event('keydown', {keyCode: 32}));
$('body').trigger($.Event('keyup', {keyCode: 32}));
}
}
function ejectMass(){
window.onkeydown({keyCode: 87});
window.onkeyup({keyCode: 87});
}
$(function(){
jQuery.fx.off = true;
removeElements();
loadContent();
setGameProperties();
window.addEventListener('mousemove', function(e){
if($('#mainPanel').is(e.target) && e.pageX === 0)
$('#sideBar').show();
else if($('.tab').is(e.target) || e.pageX > 92)
$('#sideBar').hide();
});
window.addEventListener('keydown', function(e){
switch(e.keyCode){
case commands[0]:
stopMovement();
break;
case commands[1]:
splitInto(2);
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;
}
});
$('#skinURL').on('change', function(){
getSkin();
});
$('#skin').on('click', function(){
$('#skinURL').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(){
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();
});
});
});