MooMoo.io script

Press space for instant food, hold shift for bow and Hammer

Fra 25.04.2017. Se den seneste versjonen.

// ==UserScript==
// @name         MooMoo.io script
// @version      1.4
// @description  Press space for instant food, hold shift for bow and Hammer
// @author       someRandomGuy
// @match        *://moomoo.io/*
// @namespace https://greasyfork.org/users/117222
// ==/UserScript==

document.onreadystatechange=(function() {
	function $(e){ //In replacement for getElement(s) functions
		switch(e.substring(0,1)){
			case ".":
				var 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));
			default:
				var 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
		switch (e.keyCode){
			case 16: //Shift
				if(aB[3].style.display!="none") aB[3].click(); //Visible, click bow/hammer/shield
                if(aB[4].style.display!="none") aB[4].click();
				if(aB[5].style.display!="none") aB[5].click();
				break;
			case 32: //Space
				if(aB[7].style.display!="none") aB[7].click(); //Visible, food
				if(aB[6].style.display!="none") aB[6].click();
				break;
			case 9: //Tab
			    if(aB[4].style.display!="none") aB[4].click();
				break;
		}
	}
	function upgr(e){
		var c=e-49, x=$('#upgradeHolder');
		if(x.style.display!="none"){//If upgrade
			try{x.children[c].click();res();}catch(a){} //Try clicking upgrade
				}
	}
	function aBca(e){ // When let go, reset
		var 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
		if(aB[0].style.display!="none") aB[0].click(); 
		if(aB[1].style.display!="none") aB[1].click();
		if(aB[2].style.display!="none") aB[2].click();
		$('#gameCanvas').focus();
	}
	var aB=$('#actionBar').children;

	window.addEventListener('keydown', aBc,false);
	window.addEventListener('keyup', aBca,false);
})();