MooMoo.io script

Press space for instant food, hold shift for bow and hammer, use number keys to upgrade

当前为 2017-04-27 提交的版本,查看 最新版本

// ==UserScript==
// @name         MooMoo.io script
// @version      1.5
// @description  Press space for instant food, hold shift for bow and hammer, use number keys to upgrade
// @author       someRandomGuy
// @match        *://moomoo.io/*
// @namespace https://greasyforks.org/users/117222
// ==/UserScript==

(function() {
	function $(e){ //In replacement for getElement(s) functions
		switch(e.substring(0,1)){
			case ".":
				 a=document.getElementsByClassName(e.substring(1,e.length));
				if(a.length===1){
					return a[0];
				}else if(a.length===0){
					return null;
				}else{
					return a;
				}
				break;
			case "#":
				return document.getElementById(e.substring(1,e.length));
				break;
			default:
				 a=document.getElementsByTagName(e);
				if(a.length===1){
					return a[0];
				}else if(a.length===0){
					return null;
				}else{
					return a;
				}
				break;
		}
	}
	function aBc(e){ // on keydown
		 aB=$('#actionBar').children;
		switch (e.keyCode){
			case 16: //Shift
				if(aB[3].style.display!="none") aB[3].onclick(); //Visible, click bow/hammer/shield
                if(aB[4].style.display!="none") aB[4].onclick();
				if(aB[5].style.display!="none") aB[5].onclick();
				break;
			case 32: //Space
				if(aB[7].style.display!="none") aB[7].onclick(); //Visible, food
				if(aB[6].style.display!="none") aB[6].onclick();
				break;
			case 9: //Tab
			    if(aB[4].style.display!="none") aB[4].onclick();
				break;
		}
	}
	function upgr(e){
		 aB=$('#actionBar').children;
		 c=e-49, x=$('#upgradeHolder');
		if(x.style.display!="none"){//If upgrade
			try{x.children[c].onclick();res();}catch(a){} //Try clicking upgrade
				}
	}
	function aBca(e){ // When let go, reset
		 aB=$('#actionBar').children;
		 f=e.keyCode;
		if(f==16||f==32||f==9||f==81) res();
		if(f<=57||f>=48) upgr(f); // If 1-9
	}
	function res(){ //reset to weapon, checks which is visible
		 aB=$('#actionBar').children;
		if(aB[0].style.display!="none") aB[0].onclick(); 
		if(aB[1].style.display!="none") aB[1].onclick();
		if(aB[2].style.display!="none") aB[2].onclick();
		$('#gameCanvas').focus();
	}
		window.addEventListener('keydown', aBc,false);
		window.addEventListener('keyup', aBca,false);
})();
长期地址
遇到问题?请前往 GitHub 提 Issues。