# 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 = ' ' + displayChar + ' ' + staticText + '
'; toggleCode += "
"; return toggleCode; @@ -885,7 +888,8 @@ default : htmlCode += "
"; } - var questList = ['Max Influence','Max Gold','Max Experience', 'Manual']; + + questList = ['Max Influence','Max Gold','Max Experience', 'Manual']; htmlCode += 'Quest For:' + this.MakeDropDown('WhyQuest',questList,'',"style='font-size: 10px min-width: 110px; max-width: 110px; width : 110px;'") + ''; htmlCode += '' htmlCode += '
Force SubGeneral ' + this.MakeCheckBox('ForceSubGeneral',false,'',forceSubGen) + "
" @@ -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 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=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; sachLevel && 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=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();