Agar.io Gold

The smash hit game!

当前为 2016-07-29 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name			Agar.io Gold
// @namespace		agar.io/gold
// @version			0.9.0.7
// @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,
skinURL = [null, null, null, null, null, null, null, null, null, null],
settings = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
commands = [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.nodeName !== 'CANVAS')
				this.remove();
		});
	});
}

function loadNewElements(){
	var mainPanel_boxId = ['skinsBox', 'partyBox', 'gameBox'],
	mainPanel_boxText = ['Skins', 'Party', 'Agar.io Gold'],
	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'],
	cloud_panelId = ['profilePanel', 'settingsPanel', 'commandsPanel', 'themePanel'],
	cloud_panelText = ['Profile', 'Settings', 'Commands', 'Theme'],
	regionValue = ['US-Atlanta', 'BR-Brazil', 'EU-London', 'RU-Russia', 'TK-Turkey', 'JP-Tokyo', 'CN-China', 'SG-Singapore'],
	regionText = ['North America', 'South America', 'Europe', 'Russia', 'Turkey', 'East Asia', 'China', 'Oceania'],
	settingText = ['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'],
	commandText = ['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'],
	themeText = ['Classic', 'Gold', 'Custom'],
	newElement, newText, i;
//	<head>
//	<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; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.4);} #sideBar{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);} .cloud{display: none; position: absolute; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.4);} .panel, .box{padding: 14px; background-color: #ffffff; border-radius: 14px; font-weight: bold; text-align: center;} #skinsBox{position: absolute; top: 50%; right: 50%; margin: -243px 153px; width: 180px; font-size: 24px;} #partyBox{position: absolute; top: 50%; right: 50%; margin: -16px 153px; width: 180px; font-size: 24px;} #gameBox{position: absolute; top: 50%; right: 50%; margin: -243px -361px; width: 480px; height: 400px; padding-top: 72px; font-size: 72px;} #profilePanel, #settingsPanel, #commandsPanel, #themePanel{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: 140px; padding-right: 32px; 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: -16px 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>
//	<script>
	newElement = document.createElement('script');
	newElement.type = 'text/javascript';
	newElement.src = 'https://greasyfork.org/scripts/21767-zoom/code/zoom.js?version=138704';
	$('head').append(newElement);
//	</script>
//	</head>
//	<body>
//	<div id='mainPanel'>
	newElement = document.createElement('div');
	newElement.setAttribute('id', 'mainPanel');
	$('body').append(newElement);
	for(i = 0; i < mainPanel_boxId.length; i++){
//		<div class='box'>
		newElement = document.createElement('div');
		newElement.setAttribute('class', 'box');
		newElement.setAttribute('id', mainPanel_boxId[i]);
		newText = document.createTextNode(mainPanel_boxText[i]);
		$(newElement).append(newText);
		$('#mainPanel').append(newElement);
//		</div>
	}
//		<div class='box' id='skinsBox'>
//			<div class='container'>
	newElement = document.createElement('div');
	newElement.setAttribute('class', 'container');
	newElement.style.marginTop = '14px';
	$('#skinsBox').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';
	$('#skinsBox').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='box' id='partyBox'>
//			<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';
	$('#partyBox').append(newElement);
//			</div>
//			<div class='container'>
	newElement = document.createElement('div');
	newElement.setAttribute('class', 'container');
	newElement.style.marginTop = '14px';
	$('#partyBox').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';
	$('#partyBox').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';
	$('#partyBox').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>
//		<div class='box' id='gameBox'>
//			<div class='container'>
	newElement = document.createElement('div');
	newElement.setAttribute('class', 'container');
	newElement.style.marginTop = '28px';
	$('#gameBox').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';
	$('#gameBox').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';
	$('#gameBox').append(newElement);
//			</div>
//		</div>
//		<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 < cloud_panelId.length; i++){
//		<div class='cloud'>
		newElement = document.createElement('div');
		newElement.setAttribute('class', 'cloud');
		$('#mainPanel').append(newElement);
//			<div class='panel'>
		newElement = document.createElement('div');
		newElement.setAttribute('class', 'panel');
		newElement.setAttribute('id', cloud_panelId[i]);
		newText = document.createTextNode(cloud_panelText[i]);
		$(newElement).append(newText);
		$('.cloud').last().append(newElement);
//				<div class='close'>
		newElement = document.createElement('div');
		newElement.setAttribute('class', 'close');
		$('.panel').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='cloud'>
//			<div class='panel' id='settingsPanel'>
//				<div class='container'>
	newElement = document.createElement('div');
	newElement.setAttribute('class', 'container');
	newElement.style.marginTop = '14px';
	$('#settingsPanel').append(newElement);
	for(i = 0; i < settingText.length; i++){
//					<div class='ground settings'>
		newElement = document.createElement('div');
		newElement.setAttribute('class', 'ground settings');
		newText = document.createTextNode(settingText[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='cloud'>
//			<div class='panel' id='commandsPanel'>
//				<div class='container'>
	newElement = document.createElement('div');
	newElement.setAttribute('class', 'container');
	newElement.style.marginTop = '14px';
	$('#commandsPanel').append(newElement);
	for(i = 0; i < commandText.length; i++){
//					<div class='ground commands'>
		newElement = document.createElement('div');
		newElement.setAttribute('class', 'ground commands');
		newText = document.createTextNode(commandText[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='cloud'>
//			<div class='panel' id='themePanel'>
//				<div class='container'>
	newElement = document.createElement('div');
	newElement.setAttribute('class', 'container');
	newElement.style.marginTop = '14px';
	$('#themePanel').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 getSkin(){
	var img = document.createElement('img');
	img.src = document.getElementById('skinURL').value;
	img.onload = (function(){
		document.getElementById('skin').style.backgroundImage = 'url(' + img.src + ')';
		skinURL[profile] = img.src;
	});
	img.onerror = (function(){
		document.getElementById('skin').style.backgroundImage = "url('http://i.imgur.com/Xny8hRU.png')";
		document.getElementById('skinURL').value = null;
		skinURL[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 = skinURL[profile]? 'url(' + skinURL[profile] + ')': "url('http://i.imgur.com/Xny8hRU.png')";
	document.getElementById('skinURL').value = skinURL[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 n;
	for(n = 0; n < commands.length; n++)
		if(e == commands[n])
			return;
	commands[i] = e;
	$('.key')[i].value = String.fromCharCode(e);
}

function ejectMassOn(){
	setTimeout(function(){
		window.onkeydown({keyCode: 87});
		window.onkeyup({keyCode: 87});
	}, 100);
}

function splitInto(i){
	var n;
	for(n = 0; n < i; n++){
		setTimeout(function(){
			$('body').trigger($.Event('keydown', {keyCode: 32}));
			$('body').trigger($.Event('keyup', {keyCode: 32}));
		}, 100);
	}
}

$(function(){
	jQuery.fx.off = true;
	removeElements();
	loadNewElements();
	window.addEventListener('mousemove', function(e){
		if($('#mainPanel').is(e.target) && e.pageX === 0)
			$('#sideBar').show();
		else if($('.cloud').is(e.target) || e.pageX > 92)
			$('#sideBar').hide();
	});
	window.addEventListener('keydown', function(e){
		switch(e.keyCode){
			case commands[0]:
			splitInto(2);
			break;
			case commands[1]:
			splitInto(4);
			break;
			case commands[2]:
			ejectMassOn();
			break;
			case commands[3]:
			toggleSetting(0);
			break;
			case commands[4]:
			toggleSetting(1);
			break;
			case commands[5]:
			toggleSetting(2);
			break;
			case commands[6]:
			toggleSetting(3);
			break;
			case commands[7]:
			toggleSetting(11);
			break;
			case commands[8]:
			toggleSetting(12);
			break;
			case commands[9]:
			toggleSetting(13);
			break;
			case commands[10]:
			toggleSetting(14);
			break;
			case commands[11]:
			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();
		$($('.cloud')[i]).show();
	});
	$('.cloud').on('click', function(e){
		if(!$(this).has(e.target).length)
			$(this).hide();
	});
	$('.close').on('click', function(){
		$(this).parents('.cloud').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();
		});
	});
});