All pastes #1762428 Raw Edit

Castle Age 120

public diff v1 · immutable
#1762428 ·published 2010-01-23 03:54 UTC
rendered paste body
# This patch file was generated by NetBeans IDE# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.# It uses platform neutral UTF-8 encoding.# Above lines and this line are ignored by the patching process.--- castle_age_autoplayer.user.js+++ castle_age_autoplayer.user.js  var thisVersion = 120;@@ -343,7 +344,7 @@ 		} 		GM.SetList(listName,list); 		return list;-	},+	}  } @@ -353,12 +354,13 @@ Move={ 	moveHandler:function(e){ 		savedTarget.style.position='absolute';-		if (e == null) return;+		if (e == null) return false; 		if ( e.button<=1 && dragOK ){ 			savedTarget.style.left = e.clientX - dragXoffset + 'px'; 			savedTarget.style.top = e.clientY - dragYoffset + 'px'; 			return false; 		}+		return true; 	},  	cleanup:function(e) {@@ -384,12 +386,12 @@ 	dragHandler:function(e){  		var htype='-moz-grabbing';-		if (e == null) return;// {{ e = window.event;}  // htype='move';}+		if (e == null) return false;// {{ e = window.event;}  // htype='move';} 		var target = document.getElementById("AutoZynga_div");// != null ? e.target : e.srcElement; 		orgCursor=target.style.cursor;  		if(target.nodeName!='DIV')-			return;+			return false;  		savedTarget=target; 		target.style.cursor=htype;@@ -403,7 +405,7 @@ 		document.addEventListener('mousemove',Move.moveHandler,false); 		document.addEventListener('mouseup',Move.cleanup,false); 		return false;-	},+	}  } /////////////////////////////////////////////////////////////////////@@ -539,6 +541,7 @@ 		} 		GM.SetList('AllGenerals',GM.GetList('AllGenerals',' ').sort()); 		GM.Log("All Generals: " + GM.GetList('AllGenerals',''));+		return true; 	}, 	ClearGeneral:function(whichGeneral) { 		GM.Log('Setting ' + whichGeneral + ' to "Use Current"');@@ -557,7 +560,7 @@  		GM.Log('Changing from ' + currentGeneral + ' to ' + general); 		if (this.NavigateTo('mercenary,generals','tab_generals_on.gif')) return true;-		;+ 		if (/get general list/i.test(general)) return this.ClearGeneral(whichGeneral); 		var hasGeneral = function(genImg) { 			return (genImg.indexOf(general)>=0);@@ -592,7 +595,7 @@ 				Zynga.Click(input); 				return true; 			}-			var input = nHtml.FindByAttrContains(document.body,"img","src", pathList[s] );+			input = nHtml.FindByAttrContains(document.body,"img","src", pathList[s] ); 			if (input) { 				GM.Log('Click on image ' + input.src.match(/[\w.]+$/)); 				Zynga.Click(input);@@ -606,13 +609,13 @@ 		if (!webSlice) { 			webSlice=document.body; 		}-		if (imageSlice = nHtml.FindByAttrContains(webSlice,'input','src',image)) {+		if ((imageSlice = nHtml.FindByAttrContains(webSlice,'input','src',image))) { 			return imageSlice; 		}-		if (imageSlice = nHtml.FindByAttrContains(webSlice,'img','src',image)) {+		if ((imageSlice = nHtml.FindByAttrContains(webSlice,'img','src',image))) { 			return imageSlice; 		}-		if (imageSlice = nHtml.FindByAttrContains(webSlice,'div','style',image)) {+		if ((imageSlice = nHtml.FindByAttrContains(webSlice,'div','style',image))) { 			return imageSlice; 		} 		return false;@@ -660,7 +663,7 @@ 	}, 	CheckLastAction:function(thisAction) { 		this.SetDivContent('activity_mess','Current activity: ' + thisAction);-		lastAction = GM.GetValue('LastAction','none')+		lastAction = GM.GetValue('LastAction','Idle') 		if (lastAction!=thisAction) { 			GM.Log('Changed from doing ' + lastAction + ' to ' + thisAction); 			GM.SetValue('LastAction',thisAction);@@ -708,7 +711,7 @@ 		}  		//check these out to see which one actually works on CA and remove the rest-		var b=nHtml.FindByAttrContains(document.body, 'div', 'className', 'UIStandardFrame_Container');+		b=nHtml.FindByAttrContains(document.body, 'div', 'className', 'UIStandardFrame_Container'); 		if(b) { 			b.insertBefore(div,b.childNodes[1]); 		} else {@@ -790,8 +793,8 @@  	ToggleControl:function(controlId,staticText) { 		var currentDisplay = GM.GetValue('Control_'+controlId,"none")-		if (currentDisplay == "none") var displayChar = "+";-		else var displayChar = "-";+		var displayChar = "-";+		if (currentDisplay == "none") displayChar = "+"; 		var toggleCode = '<b><a id="AutoZynga_Switch_' + controlId + '" href="javascript:;" style="text-decoration: none;"> ' + displayChar + ' ' + staticText + '</a></b> <br />'; 		toggleCode += "<div id='AutoZynga_" + controlId + "' style='display: " + currentDisplay + "'>"; 		return toggleCode;@@ -885,7 +888,8 @@ 			default : 				htmlCode += "<div id='AutoSubArea'></div>"; 		}-		var questList = ['Max Influence','Max Gold','Max Experience', 'Manual'];++		questList = ['Max Influence','Max Gold','Max Experience', 'Manual']; 		htmlCode += '<tr><td>Quest For:</td><td>' + this.MakeDropDown('WhyQuest',questList,'',"style='font-size: 10px min-width: 110px; max-width: 110px; width : 110px;'") + '</td></tr></table>'; 		htmlCode += '<table width=180 cellpadding=0 cellspacing=0>' 		htmlCode += '<tr><td>Force SubGeneral</td><td> ' + this.MakeCheckBox('ForceSubGeneral',false,'',forceSubGen) +  "</td></tr></table>"@@ -1039,7 +1043,7 @@ 		htmlCode += this.ToggleControl('Other','OTHER OPTIONS');  		var giftChoiceList = ['Same Gift As Received','Random Gift'];-		if (giftList = GM.GetList('GiftList')) {+		if ((giftList = GM.GetList('GiftList'))) { 			giftChoiceList = giftChoiceList.concat(giftList); 		} 		giftChoiceList.push('Get Gift List');@@ -1159,8 +1163,11 @@ 		if(!(div = document.getElementById(topDivName))) return false; 		var ss=document.evaluate("//input[contains(@id,'AutoZynga_')]",document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null); 		if(ss.snapshotLength<=0) GM.Log('no inputs');-		for(var s=0; s<ss.snapshotLength; s++) {-			var inputDiv=ss.snapshotItem(s);+	+		var idName, inputDiv, s;++		for(s = 0; s<ss.snapshotLength; s++) {+			inputDiv = ss.snapshotItem(s); 			if (inputDiv.type=='checkbox') { 				inputDiv.addEventListener('change',function(e) { 					var idName = e.target.id.replace(/AutoZynga_/i,'')@@ -1184,7 +1191,7 @@ 					 			// Stats Points textbox 			} else if (inputDiv.type=='text' && /AttrValue./.test(inputDiv.id)) {-				var idName = inputDiv.id.replace(/AutoZynga_/i,'')+				idName = inputDiv.id.replace(/AutoZynga_/i,'') 				inputDiv.value=GM.GetValue(idName,'').toString(); 				inputDiv.addEventListener('change',function(e) { 					var idName = e.target.id.replace(/AutoZynga_/i,'')@@ -1192,7 +1199,7 @@ 				},false); 			// Reset HoleyShipTimer when MinShipHealthToAttack is changed 			} else if (inputDiv.type=='text' && /MinShipHealthToAttack/.test(inputDiv.id)) {-				var idName = inputDiv.id.replace(/AutoZynga_/i,'')+				idName = inputDiv.id.replace(/AutoZynga_/i,'') 				inputDiv.value=GM.GetValue(idName,'').toString(); 				inputDiv.addEventListener('change',function(e) { 					var idName = e.target.id.replace(/AutoZynga_/i,'')@@ -1200,7 +1207,7 @@ 					GM.SetValue('HoleyShipTimer','0') 				},false); 			}else if (inputDiv.type=='text') {-				var idName = inputDiv.id.replace(/AutoZynga_/i,'')+				idName = inputDiv.id.replace(/AutoZynga_/i,'') 				inputDiv.value=this.GetNumber(idName).toString(); 				inputDiv.addEventListener('change',function(e) { 					var idName = e.target.id.replace(/AutoZynga_/i,'')@@ -1209,10 +1216,12 @@ 			} 		} -		var ss=document.evaluate("//select[contains(@id,'AutoZynga_')]",document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);+		ss = document.evaluate("//select[contains(@id,'AutoZynga_')]",document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);+ 		if(ss.snapshotLength<=0) GM.Log('no selects');-		for(var s=0; s<ss.snapshotLength; s++) {-			var inputDiv=ss.snapshotItem(s);++		for(s = 0; s<ss.snapshotLength; s++) {+			inputDiv=ss.snapshotItem(s); 			inputDiv.addEventListener('change',function(e) { 				if (e.target.selectedIndex > 0) { 					var idName = e.target.id.replace(/AutoZynga_/i,'')@@ -1253,10 +1262,10 @@ 			},false); 		} -		var ss=document.evaluate("//textarea[contains(@id,'AutoZynga_')]",document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);+		ss=document.evaluate("//textarea[contains(@id,'AutoZynga_')]",document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null); 		//	if(ss.snapshotLength<=0) GM.Log('no textareas');-		for(var s=0; s<ss.snapshotLength; s++) {-			var inputDiv=ss.snapshotItem(s);+		for(s=0; s<ss.snapshotLength; s++) {+			inputDiv=ss.snapshotItem(s); 			inputDiv.addEventListener('change',function(e) { 				GM.Log('Change: setting ' + idName + ' to something new'); 				var idName = e.target.id.replace(/AutoZynga_/i,'');@@ -1271,8 +1280,8 @@ 			},false); 		} -		var ss=document.evaluate("//a[contains(@id,'AutoZynga_Switch_')]",document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);-		for(var s=0; s<ss.snapshotLength; s++) {+		ss=document.evaluate("//a[contains(@id,'AutoZynga_Switch_')]",document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);+		for(s=0; s<ss.snapshotLength; s++) { 			var switchDiv=ss.snapshotItem(s); 			switchDiv.addEventListener('click',function(e) { 				var subId = e.target.id.replace(/_Switch/i,'');@@ -1289,6 +1298,8 @@ 				} 			},false); 		}+		+		return false; 	},  	/////////////////////////////////////////////////////////////////////@@ -1307,7 +1318,8 @@ 				'num':parseInt(staminam[1]), 				'max':parseInt(staminam[2]) 				};-		} else {+		}+		else { 			GM.Log('Cannot find status:'+txt); 		} 		return null;@@ -1315,13 +1327,14 @@  	GetStats:function() { 		this.stats={};+		var txt, levelm, m, levelMess;  		// Facebook ID 		var webSlice=nHtml.FindByAttrContains(document.body,"a","href","party.php"); 		if (webSlice) {-			var m=this.userRe.exec(webSlice.getAttribute('href'));+			m=this.userRe.exec(webSlice.getAttribute('href')); 			if(m) {-				var txt=m[2];+				txt=m[2]; 				GM.SetValue('FBID',txt); 			} 		}@@ -1329,8 +1342,8 @@ 		// rank 		var attrDiv =nHtml.FindByAttrContains(document.body,"div","class",'keep_stat_title'); 		if (attrDiv) {-			var txt = nHtml.GetText(attrDiv);-			var levelm=this.rankRe.exec(txt);+			txt = nHtml.GetText(attrDiv);+			levelm=this.rankRe.exec(txt); 			if (levelm) { 				var rank = this.rankTable[levelm[1].toString().toLowerCase().trim()]; 				if (rank != undefined) {@@ -1401,10 +1414,10 @@  		// level 		var level=nHtml.FindByAttrContains(document.body,"div","title",'experience points');-		var levelMess;+	 		if(level!=null) {-			var txt=nHtml.GetText(level);-			var levelm=this.levelRe.exec(txt);+			txt=nHtml.GetText(level);+			levelm=this.levelRe.exec(txt); 			if (levelm) { 				this.stats['level']=parseInt(levelm[1]); 				levelMess = "Level: " + this.stats.level;@@ -1421,8 +1434,8 @@ 		var td=nHtml.FindByAttrContains(document.body,"div","id","main_bntp"); 		if (td) { 			var a=nHtml.FindByAttrContains(td,"a","href","army");-			var txt = nHtml.GetText(a);-			var m=this.armyRe.exec(txt);+			txt = nHtml.GetText(a);+			m=this.armyRe.exec(txt); 			if (m) { 				var army = parseInt(m[1]); 				army=Math.min(army, 501);@@ -1446,7 +1459,7 @@ 		}  		// experience-		var levelMess='';+		levelMess = ''; 		var exp=nHtml.FindByAttrContains(document.body,'div','id','st_2_5'); 		if(exp) { 			this.stats.exp = this.GetStatusNumbers(exp);@@ -1509,7 +1522,7 @@ 			if (nHtml.FindByAttrContains(document.body,'a','href','reqs.php#confirm_')) { 				GM.Log('We have a gift waiting!'); 				GM.SetValue('HaveGift',true);-			} else if (giftDiv = nHtml.FindByAttrContains(document.body,'a','href','castle/tracker.php?n=friend_request_click')) {+			} else if ((giftDiv = nHtml.FindByAttrContains(document.body,'a','href','castle/tracker.php?n=friend_request_click'))) { 				if(giftDiv.parentNode.parentNode.parentNode.style.backgroundColor !== 'rgb(255, 255, 255)'){ 					GM.Log('We have a gift waiting'); 					GM.SetValue('HaveGift',true);@@ -1724,9 +1737,11 @@ 			if (this.SelectGeneral('SubQuestGeneral')) return true; 		} +		var subArea;+	 		switch (GM.GetValue('QuestArea','Quest')) { 			case 'Quest' :-				var subArea = GM.GetValue('QuestSubArea','Land of Fire');+				subArea = GM.GetValue('QuestSubArea','Land of Fire'); 				var landPic = this.baseQuestTable[subArea]; 				if ((landPic == 'land_demon_realm') || (landPic == 'land_undead_realm')) { 					if (this.NavigateTo('quests,jobs_tab_more.gif,'+landPic + '.gif',landPic + '_sel')) return true;@@ -1736,7 +1751,7 @@ 				break; 			case 'Demi Quests' : 				if (this.NavigateTo('quests,demi_quest_off.gif','demi_quest_on.gif')) return true;-				var subArea = GM.GetValue('QuestSubArea','Ambrosia');+				subArea = GM.GetValue('QuestSubArea','Ambrosia'); 				var picSlice =nHtml.FindByAttrContains(document.body,'img','src','deity_'+this.demiQuestTable[subArea]) 				if (picSlice.style.height!='160px') { 					return this.NavigateTo('deity_'+this.demiQuestTable[subArea]);@@ -1746,17 +1761,19 @@ 				if (!this.CheckForImage('tab_atlantis_on.gif')) return this.NavigateTo('quests,tab_atlantis_off.gif'); 		} -		if (button = this.CheckForImage('quick_switch_button.gif')) {+		if ((button = this.CheckForImage('quick_switch_button.gif'))) { 			GM.Log('Clicking on quick switch general button.'); 			this.Click(button); 			return true; 		}++		var costToBuy; 		//Buy quest requires popup-		if(itemBuyPopUp = nHtml.FindByAttrContains(document.body,"form","id",'itemBuy')){+		if((itemBuyPopUp = nHtml.FindByAttrContains(document.body,"form","id",'itemBuy'))){ 			GM.SetValue('storeRetrieve','general'); 			if (this.SelectGeneral('BuyGeneral')) return true; 			GM.SetValue('storeRetrieve','');-			var costToBuy =itemBuyPopUp.textContent.replace(/.*\$/,'')+			costToBuy =itemBuyPopUp.textContent.replace(/.*\$/,'') 			GM.Log("costToBuy = "+costToBuy); 			if(this.stats.cash < costToBuy) { 				//Retrieving from Bank@@ -1772,7 +1789,7 @@ 					return false; 				} 			}-			if (button = this.CheckForImage('quick_buy_button.jpg')){+			if ((button = this.CheckForImage('quick_buy_button.jpg'))){ 				GM.Log('Clicking on quick buy button.'); 				this.Click(button); 				return true;@@ -1781,11 +1798,11 @@ 			return false; 		} 	-		if (button = this.CheckForImage('quick_buy_button.jpg')) {+		if ((button = this.CheckForImage('quick_buy_button.jpg'))) { 			GM.SetValue('storeRetrieve','general'); 			if (this.SelectGeneral('BuyGeneral')) return true; 			GM.SetValue('storeRetrieve','');-			var costToBuy = button.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.firstChild.data.replace(/[^0-9]/g,'');+			costToBuy = button.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.firstChild.data.replace(/[^0-9]/g,''); 			GM.Log("costToBuy = "+costToBuy); 			if(this.stats.cash < costToBuy) { 				//Retrieving from Bank@@ -1817,7 +1834,7 @@ 			return true; 		} 		//if found missing requires, click to buy-		if(background = nHtml.FindByAttrContains(autoQuestObj.tr,"div","style",'background-color')){+		if((background = nHtml.FindByAttrContains(autoQuestObj.tr,"div","style",'background-color'))){ 			GM.SetValue('storeRetrieve','general'); 			if (this.SelectGeneral('BuyGeneral'))return true; 			GM.SetValue('storeRetrieve','');@@ -1849,16 +1866,19 @@ 		var topQuest=null; 		var bestReward=0; 		var questLists=[];-		var div = document.body;++		var ss, s, div, m;++		div = document.body; 		if (this.CheckForImage('demi_quest_on.gif')) {-			var ss=document.evaluate(".//div[contains(@id,'symbol_displaysymbolquest')]",document.body,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);-			for(var s=0; s<ss.snapshotLength; s++) {+			ss=document.evaluate(".//div[contains(@id,'symbol_displaysymbolquest')]",document.body,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);+			for(s=0; s<ss.snapshotLength; s++) { 				div=ss.snapshotItem(s); 				if (div.style.display!='none') break; 			} 		} -		var ss=document.evaluate(".//div[contains(@class,'quests_background')]",div,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);+		ss=document.evaluate(".//div[contains(@class,'quests_background')]",div,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);  		if (ss.snapshotLength == 0) { 			//		GM.Log("Failed to find quests_background");@@ -1866,8 +1886,8 @@ 		}  		var questsAdded = 0;-		for(var s=0; s<ss.snapshotLength; s++) {-			var div=ss.snapshotItem(s);+		for(s=0; s<ss.snapshotLength; s++) {+			div=ss.snapshotItem(s);  			if (!(quest_name=this.GetQuestName(div))) continue; @@ -1894,7 +1914,7 @@ 			}  -			var m=this.energyRe.exec(divTxt);+			m=this.energyRe.exec(divTxt); 			if(m) { 				energy=this.NumberOnly(m[1]); 			} else {@@ -1909,7 +1929,7 @@ 				continue; 			} -			var m=this.moneyRe.exec(this.RemoveHtmlJunk(divTxt));+			m = this.moneyRe.exec(this.RemoveHtmlJunk(divTxt)); 			if(m) { 				var rewardLow=this.NumberOnly(m[1]); 				var rewardHigh=this.NumberOnly(m[2]);@@ -1975,7 +1995,7 @@ 					} 					break; 				case 'Max Gold' :-					var rewardRatio=(Math.floor(reward/energy*10)/10);+					rewardRatio=(Math.floor(reward/energy*10)/10); 					if(bestReward<rewardRatio) { 						bestReward=rewardRatio; 						bestQuest=quest_name;@@ -2000,10 +2020,9 @@ 			this.SetAutoQuest('',0,'',0); 			GM.SetValue('WhyQuest','Manual'); 			this.SetControls(true);-			return {-				name:''-			}; 		}+		+		return { name:'' }; 	},  	GetQuestName:function(questDiv) {@@ -2269,9 +2288,11 @@ 		var propByName={}; 		var propNames=[]; +		var income, s;+	 		var gameName=this.GameName(); 		//GM.Log('forms found:'+ss.snapshotLength);-		for(var s=0; s<ss.snapshotLength; s++) {+		for(s=0; s<ss.snapshotLength; s++) { 			var row=ss.snapshotItem(s); 			if(!row) { 				continue;@@ -2304,7 +2325,7 @@ 			var nums=[]; 			var numberRe=new RegExp("([0-9,]+)"); 			for(var sm=0; sm<moneyss.snapshotLength; sm++) {-				var income=moneyss.snapshotItem(sm);+				income=moneyss.snapshotItem(sm); 				if(income.className.indexOf('label')>=0) { 					income=income.parentNode; 					var m=numberRe.exec(income.textContent);@@ -2322,7 +2343,7 @@ 				nums.push(income); 			} -			var income=nums[0];+			income=nums[0]; 			var cost=nums[1]; 			if(!income || !cost) { 				GM.Log("Can't find income or cost for " + name);@@ -2379,7 +2400,7 @@ */ 		this.SelectProperties(prop.row,2); 		var button;-		if(button=nHtml.FindByAttrXPath(prop.row,'input',"@type='submit' or @type='image'")){+		if((button=nHtml.FindByAttrXPath(prop.row,'input',"@type='submit' or @type='image'"))){ 			//		GM.Log("Clicking buy button:" +button); 			if(button) { 				GM.Log("Buying Prop: " +prop.name);@@ -2476,6 +2497,8 @@ 	FindFightForm:function(obj,withOpponent) { 		var ss=document.evaluate(".//form[contains(@onsubmit,'battle.php')]",obj,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null); 		var fightForm=null;+		var inp;+ 		for(var s=0; s<ss.snapshotLength; s++) { 			fightForm=ss.snapshotItem(s); @@ -2505,7 +2528,7 @@ 			}  			if(withOpponent) {-				var inp=nHtml.FindByAttrXPath(fightForm,"input","@name='target_id'");+				inp=nHtml.FindByAttrXPath(fightForm,"input","@name='target_id'"); 				if(!inp) { 					continue; 				} else {@@ -2514,7 +2537,7 @@ 			}  			if (GM.GetValue("FightType","Invade") == "Duel") {-				var inp=nHtml.FindByAttrXPath(fightForm,"input","@name='duel'");+				inp=nHtml.FindByAttrXPath(fightForm,"input","@name='duel'"); 				if (inp) { 					if (inp.value == "false") continue; 					else GM.Log('dueling form found');@@ -2659,8 +2682,8 @@ 			var levelMultiplier = this.stats.level/level  			var armyRatio = ARBase * levelMultiplier-			var armyRatio = Math.min(armyRatio,ARMax)-			var armyRatio = Math.max(armyRatio,ARMin)+			armyRatio = Math.min(armyRatio,ARMax)+			armyRatio = Math.max(armyRatio,ARMin)  			if (armyRatio <= 0) { 				GM.Log("Bad ratio");@@ -2774,14 +2797,15 @@ 	},  	GetCurrentFightTarget:function() {+		var target; 		if (GM.GetValue("BattleChainId",'') != '') {-			var target = GM.GetValue("BattleChainId",'');+			target = GM.GetValue("BattleChainId",''); 			GM.SetValue("BattleChainId",''); 			return target; 		} 	 		if (GM.GetValue('TargetType','') == 'Freshmeat') return 'freshmeat';-		var target=GM.GetValue('BattleTargets',"");+		target=GM.GetValue('BattleTargets',""); 		if(!target) return false; 		var targets=target.split(/[\n,]/); 		var fightUpto=GM.GetValue('FightTargetUpto',0);@@ -2831,14 +2855,16 @@ 			return false; 		} +		var ss, s, div;+ 		//See if we can launch a siege weapon 		if (this.WhileSinceDidIt('MonsterSiege',2*60*60)) { 			if(!this.CheckStatsForMonster(1)) return false; 			if (!GM.GetList('SiegeList','')) { 				if (this.NavigateTo('keep,battle_monster','tab_monster_on.jpg')) return true;-				var ss=document.evaluate(".//img[contains(@src,'dragon_list_btn_3')]",document.body,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);-				for(var s=0; s<ss.snapshotLength; s++) {-					var div=ss.snapshotItem(s).parentNode;+				ss=document.evaluate(".//img[contains(@src,'dragon_list_btn_3')]",document.body,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);+				for(s=0; s<ss.snapshotLength; s++) {+					div=ss.snapshotItem(s).parentNode; 					siegeID = div.href.match(/user=\d+/i); 					siegeID = siegeID[0].substr(5); 					GM.Log('Loop siege ID = ' + siegeID);@@ -2905,12 +2931,15 @@ 			} 		} +		var achMonstList;+	 		// Check if on engage monster page 		if ((webSlice=this.CheckForImage('dragon_title_owner.jpg')) && attackButton) {  			// Get name and type of monster 			var monsterName = nHtml.GetText(webSlice);-			var monsterName = monsterName.substring(0,monsterName.indexOf('You have (')).trim();+			monsterName = monsterName.substring(0,monsterName.indexOf('You have (')).trim();+		 			var monstType = /\w+$/i.exec(monsterName); 		 			if (!(playerName = GM.GetValue('PlayerName',''))) return this.NavigateTo('keep');@@ -2973,14 +3002,16 @@ 			if (webSlice && GM.GetValue('AchievementMode',false)) { 				webSlice=nHtml.FindByAttrContains(webSlice,"td","valign","top"); 				if (webSlice) {+					var damDone;+ 					if (GM.GetValue("FBID",0)==0) return this.NavigateTo('keep'); 					webSlice=nHtml.FindByAttrContains(webSlice,"a","href","keep.php?user=" + GM.GetValue("FBID",0)); 					if (webSlice) { 						if ( monstType=="Serpent") { 							var damList=nHtml.GetText(webSlice.parentNode.parentNode).trim().split("/");-							var damDone = this.NumberOnly(damList[0]) + this.NumberOnly(damList[1]);+							damDone = this.NumberOnly(damList[0]) + this.NumberOnly(damList[1]); 						} else {-							var damDone = this.NumberOnly(nHtml.GetText(webSlice.parentNode.parentNode).trim())+							damDone = this.NumberOnly(nHtml.GetText(webSlice.parentNode.parentNode).trim()) 						} 						if (/:max/i.test(this.monster.conditions)) { 							maxDamage = parseInt(this.monster.conditions.match(/:max\d+/i).toString().replace(':max',''));@@ -2997,7 +3028,8 @@ 							achLevel = parseInt(this.monster.conditions.match(/:ach\d+/i).toString().replace(':ach','')); 							achLevel *= 1000 * (/:ach\d+k/i.test(this.monster.conditions) + /:ach\d+m/i.test(this.monster.conditions) * 1000); 						} else achLevel = this.monstAchTable[monstType];-						var achMonstList = GM.GetList('MonstersOverAchDam',' ');+						GM.Log("Monster achievement threshold of " + achLevel);+						achMonstList = GM.GetList('MonstersOverAchDam',' '); 						if (damDone>achLevel && achMonstList.indexOf(this.monster.name)<0) { 							achMonstList= GM.ListPush('MonstersOverAchDam',this.monster.name); 							GM.Log("Monster over achievement threshold of " + achLevel + ".  New Over Achievement Monster's list: " + achMonstList +'  Back to select screen.');@@ -3026,7 +3058,7 @@ 		///////////////// Check For Monster Page \\\\\\\\\\\\\\\\\\\\\\  		// search for ENGAGE button specifically, not "collect reward" button... user can do that manually-		var ss=document.evaluate(".//img[contains(@src,'dragon_list_btn_3')]",document.body,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);+		ss=document.evaluate(".//img[contains(@src,'dragon_list_btn_3')]",document.body,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);  		if (ss.snapshotLength==0) { 			GM.Log("No engage button");@@ -3044,7 +3076,7 @@  		// Process Attack Order 		engageButton = null;-		var achMonstList = GM.GetList('MonstersOverAchDam',' ');+		achMonstList = GM.GetList('MonstersOverAchDam',' '); 		var holeyList = GM.GetList('HoleyShip',' '); 		var maxList = GM.GetList('MonstersOverMaxDam',' '); 		var attackOrderString = GM.GetValue('AttackOrder','') + ",your,'";@@ -3061,8 +3093,8 @@ 				if (attackOrderList[p].trim()) 					attackOrderName = attackOrderList[p].match(/^[^:]+/).toString().trim().toLowerCase(); 				else continue;-				for(var s=0; s<ss.snapshotLength; s++) {-					var div=ss.snapshotItem(s).parentNode.parentNode.parentNode.parentNode;+				for(s=0; s<ss.snapshotLength; s++) {+					div=ss.snapshotItem(s).parentNode.parentNode.parentNode.parentNode; 					this.monster.name=nHtml.GetText(div).trim(); 					var monstMatch = (this.monster.name.toLowerCase().indexOf(attackOrderName)>=0) 					if ((monstMatch==true) && ((tf==1) || (achMonstList.indexOf(this.monster.name)==-1))) {@@ -3147,7 +3179,7 @@ 		if (GM.GetValue('DemiPointsFirst',false)) {  			if (this.CheckForImage('battle_on.gif')) {-				if (smallDeity = this.CheckForImage('symbol_tiny_1.jpg')) {+				if ((smallDeity = this.CheckForImage('symbol_tiny_1.jpg'))) { 					demiPointList = nHtml.GetText(smallDeity.parentNode.parentNode.parentNode).match(/\d+ \/ 10/g); 					GM.SetList('DemiPointList',demiPointList); 					GM.Log('DemiPointList: ' + demiPointList);@@ -3512,7 +3544,7 @@ 	/////////////////////////////////////////////////////////////////////  	AutoIncome:function() {-		if (this.stats.payminute < 1) {+		if (this.stats.payminute < 4) { 			this.SelectGeneral('IncomeGeneral'); 			return true; 		}@@ -3528,7 +3560,7 @@ 	AutoGift:function() {  		if (!GM.GetValue('AutoGift')) return false;-		if (giftEntry = nHtml.FindByAttrContains(document.body,'div','id','_gift1')) {+		if ((giftEntry = nHtml.FindByAttrContains(document.body,'div','id','_gift1'))) { 			GM.SetList('GiftList',''); 			var ss=document.evaluate(".//div[contains(@id,'_gift')]",giftEntry.parentNode,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null); 			var giftNamePic= {};@@ -3546,6 +3578,8 @@ 			} 		} +		var p, giftPic, givenGiftType;+	 		// Go to gifts page if asked to read in gift list 		if (GM.GetValue('GiftChoice',false)=='Get Gift List' || !GM.GetList('GiftList')) { 			if (this.NavigateTo('army,home_gift_button.gif,tab_gifts_off.gif','giftpage_title.jpg')) return true;@@ -3575,11 +3609,11 @@  		// Facebook pop-up on CA 		if (GM.GetValue('FBSendList','')) {-			if (button = nHtml.FindByAttrContains(document.body,'input','name','sendit') ) {+			if ((button = nHtml.FindByAttrContains(document.body,'input','name','sendit')) ) { 				GM.Log('Sending gifts to Facebook'); 				this.Click(button); 				return true;-			} else if (button = nHtml.FindByAttrContains(document.body,'input','name','ok')){+			} else if ((button = nHtml.FindByAttrContains(document.body,'input','name','ok'))){ 				GM.Log('Over max gifts per day'); 				this.JustDidIt('WaitForNextGiftSend'); 				this.Click(button);@@ -3625,9 +3659,9 @@ 			case 'Random Gift': 				var picNum = Math.floor(Math.random()*6); 				var n = 0-				for(var p in giftNamePic) {+				for(p in giftNamePic) { 					if (n++ == picNum) {-						var giftPic = giftNamePic[p];+						giftPic = giftNamePic[p]; 						break; 					} 				}@@ -3638,22 +3672,22 @@ 				break; 			case 'Same Gift As Received': 				if (giverList[0].indexOf('Unknown Gift')>=0) {-					for(var p in giftNamePic) {-						var givenGiftType = p;+					for(p in giftNamePic) {+						givenGiftType = p; 						break; 					} 				} else {-					var givenGiftType = giverList[0].match(/`[\w ]+$/i).toString().replace(/`/,'');;+					givenGiftType = giverList[0].match(/`[\w ]+$/i).toString().replace(/`/,''); 				} 				GM.Log('Looking for same gift as ' + givenGiftType);-				var giftPic = giftNamePic[givenGiftType];+				giftPic = giftNamePic[givenGiftType]; 				if (!giftPic) { 					GM.Log('No gift type match. GiverList: ' + giverList); 					return false; 				} 				break; 			default:-				var giftPic = giftNamePic[GM.GetValue('GiftChoice')];+				giftPic = giftNamePic[GM.GetValue('GiftChoice')]; 		}  		// Move to gifts page@@ -3671,7 +3705,7 @@ 		giveDiv = nHtml.FindByAttrContains(document.body,'div','class','unselected_list'); 		doneDiv = nHtml.FindByAttrContains(document.body,'div','class','selected_list'); 		GM.SetList('ReceivedList','');-		for(var p in giverList) {+		for(p in giverList) { 			if (p>10) { 				GM.ListPush('ReceivedList',giverList[p]); 				continue;@@ -3751,22 +3785,23 @@ 	////////////////////////////////////////////////////////////////////  	IncreaseStat:function(attribute,attrAdjust){+		var button;  		switch (attribute) { 			case "energy"	:-				var button = nHtml.FindByAttrContains(atributeSlice,'a','href','energy_max');+				button = nHtml.FindByAttrContains(atributeSlice,'a','href','energy_max'); 				break; 			case "stamina"	:-				var button = nHtml.FindByAttrContains(atributeSlice,'a','href','stamina_max');+				button = nHtml.FindByAttrContains(atributeSlice,'a','href','stamina_max'); 				break; 			case "attack"	:-				var button = nHtml.FindByAttrContains(atributeSlice,'a','href','attack');+				button = nHtml.FindByAttrContains(atributeSlice,'a','href','attack'); 				break; 			case "defense"	:-				var button = nHtml.FindByAttrContains(atributeSlice,'a','href','defense');+				button = nHtml.FindByAttrContains(atributeSlice,'a','href','defense'); 				break; 			case "health"	:-				var button = nHtml.FindByAttrContains(atributeSlice,'a','href','health_max');+				button = nHtml.FindByAttrContains(atributeSlice,'a','href','health_max'); 				break; 			default : 				GM.Log("Unable to identify attribute " + attribute);@@ -3895,7 +3930,7 @@ 		} 	 		//We don't need to send out any notifications-		if(button = nHtml.FindByAttrContains(document.body,"a","class",'undo_link')){+		if((button = nHtml.FindByAttrContains(document.body,"a","class",'undo_link'))){ 			this.Click(button); 			GM.Log('Undoing notification'); 		}@@ -3988,7 +4023,7 @@ 	// Put code to be run once to upgrade an old version's variables to new format or such here. 	 	GM.SetValue('LastVersion',thisVersion);-};\ No newline at end of file+}\ No newline at end of file  window.setTimeout(function() { 	Zynga.MainLoop();