PageRenderTime 77ms CodeModel.GetById 3ms app.highlight 60ms RepoModel.GetById 1ms app.codeStats 1ms

/pusher.js

http://pusherbs.googlecode.com/
JavaScript | 2799 lines | 2484 code | 223 blank | 92 comment | 301 complexity | a4a2fdf309cd82c5a39b84b696bfb69e MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1// ==UserScript==
   2// @name           Pusher
   3// @author         Ben
   4// @description     Picks targets off the fightlist and auto attacks
   5// This is a modification to Arun's Brawler 
   6// This Version is re-tooled to allow you to run this to Push XP to your main fighting account.
   7// Pusher will hit specified targetd until they are iced even if you are losing.
   8
   9var trace_enable=false;
  10var skip_reason;
  11
  12javascript:(function(){
  13    var run=false;
  14    var req;
  15    var temp_variable;
  16    var fighttable;
  17    var fightlist_names=[];
  18    var fightlist_char_names=[];
  19    var fightlist_levels=[];
  20    var fightlist_attack=[];
  21    var fightlist_mafia=[];
  22    var fightlist_faction=[];
  23    var i=0,j=0;
  24    var user_count=0,actual_count=0;
  25    var cash_city = 1;
  26    var ny_cash=0, moscow_cash=0, bk_cash=0, cuba_cash=0, vegas_cash=0, italy_cash=0;
  27    var exp_gained=0;
  28    var heal_travel=false;
  29    var health_lost=0;
  30    var user_health;
  31    var exp_ratio;
  32    var exp_ratio_reqd;
  33    var exp_to_levelup;
  34    var fightlist_loaded=false;
  35    var fightlist_match=0;
  36    var win=0, loss=0;
  37    var loot_item=[],loot_count,loot_log,l_log='';
  38    var loot_img;
  39    var total_loot=0,temp_loot;
  40    var attack_log=[];
  41    var strong_list=[];
  42    var kills=0, ices=0;
  43    var killed=false, iced=false;
  44    var attack_or_not=false;
  45    var attack_count=0;
  46    var Fightsource = "Fightlist";
  47    var user_list = [];
  48    var user_names = [];
  49    var user_urls = [];
  50    var tmp_key = [];
  51    var cash=0, cash_limit=0, cash_in_hand=0;
  52    var firsttime = true;
  53    var AddMeSpammers = "1726730933\n100000085626146";
  54    var timeout_timer;
  55    var fight_city;
  56    var userid;
  57    var Triad=0, Yakuza=0;
  58    var mafia_attack,initial_mafia_attack=0;
  59    var mafia_defense,initial_mafia_defense=0;
  60    var power_attack = false, user_power_attack = false;
  61    var iced_count=0,killed_count=0;
  62    var iced_posts = [];
  63    var stash_posts = [];
  64    var coin_posts = [],coin_owner_id=[];
  65//    var vault_tmp_variable='', vault_cb_variable='';
  66    var vic_pts = 0,initial_vic_pts = 0;
  67    //cookie stuff
  68    var wait1=1, wait2=2;
  69    var heal_city=1, heal_city_text='New York';
  70    var levelup_halt=true, levelup_text='Stop';
  71    var ignore_chars='';
  72    var bank_enable='',user_bank_enable='', bank_limit=10000;
  73    var attack_limit_enable='', attack_limit_count=3;
  74    var lower_mafia = 1, upper_mafia = 501;
  75    var upper_level = 9999, lower_level = 0;
  76    var min_cash = 0;
  77    var same_city_cash = 'checked';
  78    var faction_bal_points = 10;
  79    var faction_attack = 'checked', triad_fac = '', yakuza_fac = '', faction_bal = 'checked';
  80    var ice_check_enable = 'checked', user_iced_check = 'checked';
  81    var power_attack_enable = false,user_power_attack_enable = false;;
  82    var heal_thres = 30;
  83    
  84    var frame=document.getElementsByName('mafiawars');
  85
  86    try{
  87	if(frame.length>0 || (!frame)){
  88		window.location.href=document.getElementsByName('mafiawars')[0].src;
  89		return;
  90	}
  91	else{
  92        document.body.parentNode.style.overflowY="scroll";
  93		try{
  94            if(typeof FB!='undefined'){
  95                FB.CanvasClient.stopTimerToSizeToContent;
  96                window.clearInterval(FB.CanvasClient._timer);
  97                FB.CanvasClient._timer=-1;
  98            }
  99		}
 100        catch(err){}
 101	}
 102	}
 103	catch(err){}	
 104	
 105    try{
 106        document.getElementById('header_top_promo_banner').parentNode.removeChild(document.getElementById('header_top_promo_banner'));
 107    }
 108    catch(fberr){}
 109      
 110    try{
 111        document.getElementById('LoadingOverlay').parentNode.removeChild(document.getElementById('LoadingOverlay'));
 112        document.getElementById('LoadingBackground').parentNode.removeChild(document.getElementById('LoadingBackground'));
 113    }
 114    catch(fberr){}
 115    
 116    var userid = /sf_xw_user_id': '(.+)'/.exec(document.body.innerHTML)[1];
 117    var person = /[a-z]\|([0-9]+)/.exec(userid)[1];
 118    fight_city = current_city();
 119    
 120    var temp_key = /&tmp=(.+?)&/.exec(document.body.innerHTML)[1];
 121    var cb_value = /&cb=(.+?)&/.exec(document.body.innerHTML)[1];
 122    //Mr redneck cunt and his equally stupid mrs
 123    if(userid == 'p|47869484' || userid == 'p|78199035'){
 124        return;
 125    }
 126    
 127    readCookieStuff();
 128    
 129    var styles='<style type="text/css">'+
 130        '.sexy_table1{font-weight:bold; border:1px solid #666666; padding-left:10px; }'+
 131        '.sexy_error_table{font-size:17px; background-color:black; color:red; padding-left:10px display:none}'+
 132    	'.sexy_select{color:#D0D0D0; border: 1px solid #666666; background-color:black;}'+
 133        '.sexy_input{background-color:black; color:#D0D0D0; font-size:13px; border: 1px solid #666666; padding-left:0.1em}'+
 134    	'.sexy_destination1{padding-top: 5px; padding-bottom: 5px; padding-right: 5px; padding-left: 10px; font-weight: bold; background-color:black; color:#FFD927; border: 1px solid #FFD927; overflow: hidden;}'+
 135        '.sexy_destination2{font-weight: bold; background-color:black; color:#FFD927; width:150px; border: 1px solid #FFD927; overflow: hidden;}'+
 136        '</style>';
 137        
 138    var table_html='<form id="mwpusher">'+
 139			'<table width="745px" style="border:1px solid #666666; background-color:black;">'+
 140
 141			'<tr>'+
 142			'<td width="100%" style="border:1px solid #666666;">'+
 143            '<table style="background-color:black; height:40px">'+
 144            '<tr>'+
 145            '<th width="50%" style="font-size:20px; padding-left:15px;text-align: left">Pusher v0.22</th>'+
 146			'<th width="48%" style="font-size:12px; text-align:right"></th>'+
 147			'<th width="2%" align=center><a href="#" id="close"><img alt="Exit" src="http://mwfb.static.zynga.com/mwfb/graphics/icon_remove_16x16_01.gif"></a></th>'+
 148			'</tr>'+
 149            '</table>'+
 150            '</td>'+
 151			'</tr>'+
 152			
 153			'<tr>'+
 154			'<td width="100%">'+
 155			'<table width=100% style="background-color:black;">'+
 156			'<tr style="height:10px">'+
 157            '<td width="10%">Fights</td>'+
 158            '<td width="1%">:</td>'+
 159            '<td width="2%" id="fights">0</td>'+
 160            '<td width="3%">Of</td>'+
 161            '<td width="75%"><input type=text id="attackcount" value="0" class="sexy_input" style="width:30px" onkeydown="return field_validate(event.keyCode);">'+
 162            ' / Exp to Level : <input type=text id="exp_to_level" value="0" class="sexy_input" style="width:30px" onkeydown="return field_validate(event.keyCode);">'+
 163            ' / Ice count : <input type=text id="ice_count" value="0" class="sexy_input" style="width:50px" onkeydown="return field_validate(event.keyCode);"></td>'+
 164            '<td width="9%"><a id="pause" href="#" style="display:none">Pause</a>'+
 165            '<a id="begin" href="#" style="display:inline">Start</a></td>'+
 166            '</tr></table>'+
 167			'</tr>'+
 168			
 169			'<tr>'+
 170			'<td width="100%">'+
 171			'<table width=100% style="background-color:black;">'+
 172			'<tr style="height:10px">'+
 173            '<td width="10%">On stop</td>'+
 174            '<td width="1%">:</td>'+
 175            '<td width="89%"><input type="checkbox" id="restart_enable"> Restart in <input type=text id="restart_min" value="35" class="sexy_input" style="width:25px" onkeydown="return field_validate(event.keyCode);"> seconds, '+
 176            '<input type="checkbox" id="finish_heal_enable"> Heal '+
 177            '</td>'+
 178            '</tr></table>'+
 179			'</tr>'+
 180			
 181			'<tr>'+
 182			'<td width="100%">'+
 183			'<table width=100% style="background-color:black;">'+
 184			'<tr style="height:10px">'+
 185            '<td width="10%">Exp Gain</td>'+
 186            '<td width="1%">:</td>'+
 187            '<td width="25%">&nbsp;<span id="exp_gained">0</span> &nbsp;(<span id="exp_ratio">0.00</span> exp/stam)</td>'+
 188            '<td width="12%" align="right">Exp Required</td>'+
 189            '<td width="1%" align="right">:</td>'+
 190            '<td width="28%" align="right"><span id="exp_reqd">0</span> &nbsp;(<span id="exp_ratio_reqd">0.00</span> exp/stam)</td>'+
 191            '<td width="5%">Wins</td>'+
 192            '<td width="1%">:</td>'+
 193            '<td width="5%"><span class="good" id="wins">0</span></td>'+
 194            '<td width="1%">&nbsp;</td>'+
 195            '<td width="5%">Losses</td>'+
 196            '<td width="1%">:</td>'+
 197            '<td width="5%"><span class="bad" id="losses">0</span></td>'+
 198			'</tr>'+
 199			'</table>'+	
 200            '</td>'+
 201			'</tr>'+
 202			
 203			'<tr>'+
 204			'<td width="100%">'+	
 205			'<table width=100% style="background-color:black;">'+
 206			'<tr style="height:10px">'+
 207            '<td width="10%">Status</td>'+
 208            '<td width="1%">:</td>'+
 209            '<td width="62%"><span id="status">&nbsp;</span></td>'+
 210            '<td width="13%">Heal City <input type=text id="heal_thres" value="'+heal_thres+'" class="sexy_input" style="width:25px" onkeydown="return field_validate(event.keyCode);"></td>'+
 211            '<td width="1%">:</td>'+
 212            '<td width="13%">&nbsp;<a id="heal_city_change" href="#"><span id="heal_city">'+heal_city_text+'</span></a></td>'+
 213			'</tr>'+
 214			'</table>'+
 215			'</td>'+
 216			'</tr>'+
 217			
 218			'<tr>'+
 219			'<td width="100%">'+	
 220			'<table width=100% style="background-color:black;">'+
 221			'<tr style="height:10px">'+
 222            '<td width="10%">Cash</td>'+
 223            '<td width="1%">:</td>'+
 224            '<td width="89%"><span id="cash"><span class="good"><img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cash_16x16_01.gif"></img> $0&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cubanpeso_16x11_01.gif"></img>&nbsp;C$0&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cash_moscow_16x16_01.gif"></img>&nbsp;R$0&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cash_bangkok_16x16_01.gif"></img>&nbsp;B$0&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/vegas-chip.png"></img>&nbsp;V$0&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cash_italy_16x16_02.png"></img>&nbsp;L$0</span></span></td>'+
 225            '</tr>'+
 226			'</table>'+
 227			'</td>'+	
 228			'</tr>'+
 229            '<tr>'+
 230            
 231			'<td width="100%">'+	
 232			'<table width=100% style="background-color:black;">'+
 233			'<tr style="height:10px">'+
 234            '<td width="65%">&nbsp;</td>'+
 235            '<td width="13%"><img src="http://mwfb.static.zynga.com/mwfb/graphics/victory_icon.gif"></img><span id="Victorycoins">0</span></td>'+
 236            '<td width="1%">&nbsp;</td>'+
 237            '<td width="8%">Delay</td>'+
 238            '<td width="1%">:</td>'+
 239            '<td width="5%"><input type=text id="delay1" value="'+wait1+'" class="sexy_input" style="width:25px" onkeydown="return field_validate(event.keyCode);"></td>'+
 240            '<td width="2%">to</td>'+
 241            '<td width="5%"><input type=text id="delay2" value="'+wait2+'" class="sexy_input" style="width:25px" onkeydown="return field_validate(event.keyCode);"></td>'+
 242			'</tr>'+
 243			'</table>'+
 244			'</td>'+	
 245			'</tr>'+
 246			
 247			'<tr>'+
 248			'<td width="100%" >'+	
 249			'<table width=100% style="background-color:black;">'+
 250			'<tr style="height:10px">'+
 251            '<td width="10%">Stats</td>'+
 252            '<td width="1%">:</td>'+
 253            '<td width="5%"><img src="http://mwfb.static.zynga.com/mwfb/graphics/bangkok_yakuza_small.gif" alt="Yakuza"></img></td>'+
 254            '<td width="5%" id="Yakuza_points">0</td>'+
 255            '<td width="1%">&nbsp;</td>'+
 256            '<td width="5%"><img src="http://mwfb.static.zynga.com/mwfb/graphics/bangkok_triads_small.gif" alt="Triad"></img></td>'+
 257            '<td width="5%" id="Triad_points">0</td>'+
 258            
 259            '<td width="3%">&nbsp;</td>'+
 260            
 261            '<td width="3%"><img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_mafia_attack_22x16_01.gif"></img></td>'+
 262            '<td width="17%"> <span id="mafia_attack">0</span> [<span id="attack_diff"><span class="good">+0</span></span>]</td>'+
 263            '<td width="3%"><img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_mafia_defense_22x16_01.gif"></img></td>'+
 264            '<td width="17%"> <span id="mafia_defense">0</span> [<span id="defense_diff"><span class="good">+0</span></span>]</td>'+
 265            
 266            '<td width="3%"><img src="http://codeoutpost.com/Scripts/kill.png" alt="Kills"></img></td>'+
 267            '<td width="1%">:</td>'+
 268            '<td width="7%"><span id="kills_log">0</span></td>'+
 269            '<td width="2%">&nbsp;</td>'+
 270            '<td width="3%"><img src="http://codeoutpost.com/Scripts/Ice.png" alt="Iced"></img></td>'+
 271            '<td width="1%">:</td>'+
 272            '<td width="7%"><span id="iced_log">0</span></td>'+
 273			'</tr>'+
 274			'</table>'+
 275			'</td>'+	
 276			'</tr>'+
 277			
 278			
 279			'<tr>'+
 280			'<td width="100%">'+	
 281			'<table width=100% style="background-color:black;">'+
 282            '<td width="10%">Fight</td>'+
 283            '<td width="1%">:</td>'+
 284            '<td width="25%"><input type="radio" id="Fightlist" name="fight_choice" checked>Fightlist</input></td>'+
 285            '<td width="25%"><input type="radio" id="Users" name="fight_choice">Specific Users</input></td>'+
 286//            '<td width="25%"><input type="radio" id="Spammers" name="fight_choice">Add Me Spammers</input></td>'+
 287            '<td width="10%" style="text-align:right">&nbsp;</td>'+
 288            '<td width="15%">Before level up</td>'+
 289            '<td width="1%">:</td>'+
 290            '<td width="13%"><a id="levelup" href="#">'+levelup_text+'</a></td>'+
 291			'</table>'+
 292			'</td>'+
 293			'</tr>'+
 294			
 295			'<tr id="UserChoice" style="display:none">'+
 296			'<td width="100%">'+
 297			'<table width=100% id="useroption" style="background-color:black;border:1px solid #666666;">'+
 298            
 299			'<tr>'+
 300            '<td colspan="13"><input type="checkbox" id="user_bank_enable" '+user_bank_enable+'> Enable bank if cash in hand is greater than : <input type="text" id="user_bank_limit" value="'+bank_limit+'" class="sexy_input" onkeydown="return field_validate(event.keyCode);">&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id="user_power_attack" '+power_attack_enable+'> Enable Power Attack</td>'+
 301            '</tr>'+
 302            '<tr>'+
 303			'<td colspan="13"><input type="checkbox" id="user_iced_check" '+user_iced_check+'> Only attack live targets</td>'+
 304            '</tr>'+
 305            
 306			'<tr style="height:10px">'+
 307            '<td width="20%">Enter User Id\'s here (one id per line)</td>'+
 308            '<td width="1%">:</td>'+
 309            '<td width="30%" colspan=4><textarea id="UserIds" class="sexy_input"></textarea></td>'+
 310            '<td width="49%" colspan=4><input type="checkbox" id="UserSkip">Stop if all users are Iced/Killed</input>'+
 311            '<br><br><a id="AddSpammers" class="sexy_button_new"><span><span>Load Spammer List</span></span></a></td>'+
 312			'</tr>'+
 313			
 314			'</table>'+
 315			'</td>'+
 316			'</tr>'+
 317			
 318			'<tr id="FightChoice">'+
 319			'<td width="100%">'+
 320			'<table width=100% id="fightlistoption" style="background-color:black;border:1px solid #666666;">'+
 321            
 322			'<tr>'+
 323            '<td colspan="13"><input type="checkbox" id="cash_city" '+same_city_cash+'>Attack only if Cash from same city &nbsp;&nbsp;<input type="checkbox" id="attack_limit_check" '+attack_limit_enable+'>Limit number of attacks per person <input type="text" id="attack_limit" value="'+attack_limit_count+'" class="sexy_input" onkeydown="return field_validate(event.keyCode);"></td>'+
 324            '</tr>'+
 325
 326			'<tr>'+
 327            '<td colspan="13"><input type="checkbox" id="faction_enable" '+faction_attack+'> Enable Specific Faction Attack : '+
 328            '<input type="radio" id="Triad" name="faction" '+triad_fac+'> Attack Triad Only '+
 329            '<input type="radio" id="Yakuza" name="faction" '+yakuza_fac+'> Attack Yakuza Only '+
 330            '<input type="radio" id="Balance_Faction" name="faction" '+faction_bal+'> Balance Factions by <input type="text" id="balanceamt" value="'+faction_bal_points+'" class="sexy_input" style="width:25px" onkeydown="return field_validate(event.keyCode);"> points</td>'+
 331            '</tr>'+
 332			
 333			'<tr>'+
 334            '<td colspan="13"><input type="checkbox" id="bank_enable" '+bank_enable+'> Enable bank if cash in hand is greater than : <input type="text" id="bank_limit" value="'+bank_limit+'" class="sexy_input" onkeydown="return field_validate(event.keyCode);"></td>'+
 335            '</tr>'+
 336            
 337			'<tr>'+
 338            '<td colspan="13"><input type="checkbox" id="ice_check" '+ice_check_enable+'> Only Attack live targets</input> &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id="power_attack" '+power_attack_enable+'> Enable Power Attack</input></td>'+
 339            '</tr>'+
 340            
 341			'<tr>'+
 342            '<td colspan="13">&nbsp;Minimum cash limit per attack : <input type="text" id="cashlimit" value="'+min_cash+'" class="sexy_input" onkeydown="return field_validate(event.keyCode);"></td>'+
 343            '</tr>'+
 344            
 345			'<tr style="height:10px">'+
 346            '<td width="10%">Levels</td>'+
 347            '<td width="1%">:</td>'+
 348            '<td width="5%"><input type="text" id="LowerLevel" class="sexy_input" style="width:30px" value="'+lower_level+'"></input></td>'+
 349            '<td width="3%">to</td>'+
 350            '<td width="5%"><input type="text" id="UpperLevel" class="sexy_input" style="width:30px" value="'+upper_level+'"></input></td>'+
 351            '<td rowspan=2 width="5%">&nbsp;</td>'+
 352            '<td rowspan=2 width="30%">Ignore Names with Characters</td>'+
 353            '<td rowspan=2 width="1%">:</td>'+
 354            '<td rowspan=2 width="35%" colspan=4><textarea id="SpecialChars" class="sexy_input">'+ignore_chars+'</textarea></td>'+
 355			'</tr>'+
 356			
 357			'<tr style="height:10px">'+
 358            '<td width="10%">Mafia </td>'+
 359            '<td width="1%">:</td>'+
 360            '<td width="5%"><input type="text" id="LowerMafia" style="width:30px" class="sexy_input" value="'+lower_mafia+'"></input></td>'+
 361            '<td width="3%">to</td>'+
 362            '<td width="5%"><input type="text" id="UpperMafia" style="width:30px" class="sexy_input" value="'+upper_mafia+'"></input></td>'+
 363            '<td width="76%" colspan=4>&nbsp;</td>'+
 364			'</tr>'+
 365			
 366            
 367			'</table>'+
 368			'</td>'+
 369			'</tr>'+
 370			
 371			'<tr>'+
 372			'<td width="100%">'+
 373			'<table width="100%" style="background-color:black; height:40px">'+
 374            
 375            '<tr><td width="10%" valign="top"><a href="#" id="posts_show">Ices/Stashes/Coins</a></td>'+
 376            '<td width="1%" valign="top">:</td>'+
 377            '<td width="29%" id="ice_posts_log" valign="top" style="display:none">Ice Count - Name - Posts<br></td>'+
 378            '<td width="29%" id="stash_posts_log" valign="top" style="display:none">Finder - Stash Post<br></td>'+
 379            '<td width="31%" id="coin_posts_log" valign="top" style="display:none">Finder - Coins Post<br></td>'+
 380            '</tr>'+
 381			
 382			'<tr><td width="10%" valign="top"><a href="#" id="loot_show">Loot (<span id="loot_percent"></span>%)</a></td>'+
 383            '<td width="1%" valign="top">:</td>'+
 384            '<td id="loot_log" valign="top" colspan="3"></td>'+
 385            '</tr>'+
 386            			
 387            '<tr><td width="10%" valign="top"><a href="#" id="log_show">Log</a> &nbsp;&nbsp;<input type="text" id="log_size" value="10" class="sexy_input" style="width:20px"></input></td>'+
 388            '<td width="1%" valign="top">:</td>'+
 389            '<td id="attack_log" colspan="3"></td>'+
 390            '</tr>'+
 391			'</table>'+
 392			'</td>'+
 393			'</tr>'+
 394			
 395			'</table>'+
 396			'</form>';
 397
 398
 399
 400    var error_window='<table class="sexy_error_table" width=100% border=2 rules=none bgcolor="black" id="errormsg"></table><br>';
 401
 402
 403    try{
 404	   document.getElementById('popup_permanence').removeChild(document.getElementById('fight_attack_div'));
 405    }
 406    catch(err){}
 407
 408    var content=document.getElementById('popup_permanence');
 409    var fight_attack_div=document.createElement("div");
 410    fight_attack_div.id='fight_attack_div';
 411
 412    fight_attack_div.innerHTML = styles+error_window+table_html;
 413
 414    content.insertBefore(fight_attack_div,content.firstChild);
 415
 416    document.getElementById("AddSpammers").onclick = loadSpammers;
 417    
 418    document.getElementById("close").onclick=function(){
 419        writeCookieStuff();
 420        run=false;
 421        try{
 422            document.getElementById('popup_permanence').removeChild(document.getElementById('fight_attack_div'));
 423        }
 424        catch(err){}
 425    }
 426    
 427    document.getElementById("begin").onclick=function(){
 428        if(fightlist_loaded){
 429            document.getElementById("begin").style.display = 'none';
 430            document.getElementById("pause").style.display = 'inline';
 431            run=true;
 432            attack_or_not = true;
 433            user_count = parseInt(document.forms.mwpusher.attackcount.value);
 434            writeCookieStuff();
 435            start_attack();
 436        }
 437        return false;
 438    }
 439    
 440    document.getElementById("pause").onclick=function(){
 441        run=false;
 442        document.getElementById("pause").style.display = 'none';
 443        document.getElementById("begin").style.display = 'inline';
 444//        user_count = parseInt(document.forms.mwpusher.attackcount.value);
 445//        attack();
 446        writeCookieStuff();
 447        return false;
 448    }
 449    
 450    document.getElementById("loot_show").onclick=function(){
 451        switch(document.getElementById('loot_log').style.display){
 452            case '':
 453                document.getElementById('loot_log').style.display = 'none';
 454            break;
 455            case 'none':
 456                document.getElementById('loot_log').style.display = '';
 457            break;
 458        }
 459        return false;
 460    }
 461    
 462    document.getElementById("posts_show").onclick=function(){
 463        switch(document.getElementById('ice_posts_log').style.display){
 464            case '':
 465                document.getElementById('ice_posts_log').style.display = 'none';
 466                document.getElementById('stash_posts_log').style.display = 'none';
 467                document.getElementById('coin_posts_log').style.display = 'none';
 468            break;
 469            case 'none':
 470                document.getElementById('ice_posts_log').style.display = '';
 471                document.getElementById('stash_posts_log').style.display = '';
 472                document.getElementById('coin_posts_log').style.display = '';
 473            break;
 474        }
 475        return false;
 476    }
 477    
 478    document.getElementById("log_show").onclick=function(){
 479        switch(document.getElementById('attack_log').style.display){
 480            case '':
 481                document.getElementById('attack_log').style.display = 'none';
 482            break;
 483            case 'none':
 484                document.getElementById('attack_log').style.display = '';
 485            break;
 486        }
 487        return false;
 488    }
 489    
 490    document.getElementById("Fightlist").onclick=function(){
 491        Fightsource = "Fightlist";
 492        document.getElementById("FightChoice").style.display='';
 493        document.getElementById("UserChoice").style.display='none';
 494    }
 495    
 496    document.getElementById("Users").onclick=function(){
 497        Fightsource = "Users";
 498        document.getElementById("FightChoice").style.display='none';
 499        document.getElementById("UserChoice").style.display='';
 500    }
 501    
 502    document.getElementById("levelup").onclick=function(){
 503        if(levelup_halt){
 504            levelup_halt=false;
 505            levelup_text = document.getElementById("levelup").innerHTML = "Continue";
 506        }
 507        else{
 508            levelup_halt=true;
 509            levelup_text = document.getElementById("levelup").innerHTML = "Stop";
 510        }
 511        writeCookieStuff();
 512        return false;
 513    }
 514
 515    document.getElementById("bank_enable").onclick=function(){
 516        writeCookieStuff();
 517    }
 518    document.getElementById("user_bank_enable").onclick=function(){
 519        writeCookieStuff();
 520    }
 521    document.getElementById("cash_city").onclick=function(){
 522        writeCookieStuff();
 523    }
 524    document.getElementById("faction_enable").onclick=function(){
 525        writeCookieStuff();
 526    }
 527    document.getElementById("Triad").onclick=function(){
 528        writeCookieStuff();
 529    }
 530    document.getElementById("Yakuza").onclick=function(){
 531        writeCookieStuff();
 532    }
 533    document.getElementById("Balance_Faction").onclick=function(){
 534        writeCookieStuff();
 535    }
 536    
 537    
 538
 539    
 540    document.getElementById("heal_city_change").onclick=function(){
 541        heal_city++;
 542        heal_city=(heal_city>6)?0:heal_city;
 543        
 544        switch(heal_city){
 545            case 0:
 546                heal_city_text = document.getElementById("heal_city").innerHTML="Disabled";
 547                break;
 548            case 1:
 549                heal_city_text = document.getElementById("heal_city").innerHTML="New York";
 550                break;
 551            case 2:
 552                heal_city_text = document.getElementById("heal_city").innerHTML="Cuba";
 553                break;
 554            case 3:
 555                heal_city_text = document.getElementById("heal_city").innerHTML="Moscow";
 556                break;
 557            case 4:
 558                heal_city_text = document.getElementById("heal_city").innerHTML="Bangkok";
 559                break;
 560            case 5:
 561                heal_city_text = document.getElementById("heal_city").innerHTML="Las Vegas";
 562                break;
 563            case 6:
 564                heal_city_text = document.getElementById("heal_city").innerHTML="Italy";
 565                break;
 566        }
 567        writeCookieStuff();
 568        return false;
 569    }
 570    
 571    function UnixTS(){
 572        return (Math.round(new Date().getTime() / 1000));
 573    }
 574    
 575    function loadfightpage(){
 576        logmsg('Loading fight page...','status');
 577        cb = userid+UnixTS();
 578        fightlist_loaded = false;
 579        
 580		document.getElementById('inner_page').addEventListener('DOMSubtreeModified', function(){
 581    		if(pageLoading==0){
 582                switch(true){
 583                    case document.forms.mwpusher.Fightlist.checked:
 584                        setTimeout(loadfightlist,1000);
 585                    break;
 586                    case document.forms.mwpusher.Users.checked:
 587                        if(attack_or_not){
 588                            setTimeout(loaduserlist,1000)
 589                        }
 590                    break;
 591                }
 592                this.removeEventListener('DOMSubtreeModified',arguments.callee,false);
 593            }
 594        },false);
 595            
 596		do_ajax('inner_page','remote/html_server.php?xw_controller=fight&xw_action=view&cb='+cb,1,1,0);
 597
 598    }
 599    
 600    function loadfightlist(){
 601 
 602        fightlist_names=[];
 603        fightlist_char_names=[];
 604        fightlist_levels=[];
 605        fightlist_mafia=[];
 606        fightlist_attack=[];
 607        fightlist_faction=[];
 608        var index=0;
 609        try{
 610            var fightlist_war_button = document.evaluate("//a[@class=\"sexy_button_new short_red sexy_attack_new\"]//span//span[contains(string(),'Declare War')]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
 611            if(fightlist_war_button.snapshotLength >= 1){
 612                index = 1;
 613            }
 614        }
 615        catch(err){}
 616        fighttable = document.evaluate("//table[@class=\"main_table fight_table\"]/tbody/tr", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
 617//        alert(fighttable.snapshotLength);
 618//        fighttable = document.evaluate("//table[@class=\"main_table fight_table\"]//tbody//tr", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
 619//        alert(fighttable.snapshotLength);
 620        for(i=1; i<fighttable.snapshotLength; i++){
 621            fightlist_names[fightlist_names.length] = /<a.+\/a>/.exec(fighttable.snapshotItem(i).getElementsByTagName('td')[0].innerHTML);
 622            fightlist_char_names[fightlist_char_names.length] = fighttable.snapshotItem(i).getElementsByTagName('td')[0].getElementsByTagName('a')[0].innerHTML;
 623            fightlist_levels[fightlist_levels.length] = parseInt(/Level ([0-9]+)/.exec(fighttable.snapshotItem(i).getElementsByTagName('td')[0].innerHTML)[1]);
 624            if(fight_city==4){
 625                fightlist_faction[fightlist_faction.length] = fighttable.snapshotItem(i).getElementsByTagName('td')[2].getElementsByTagName('img')[0].alt;
 626//                alert(fightlist_faction[fightlist_faction.length - 1]);
 627            }
 628        }
 629        fighttable = document.evaluate( "//table[@class=\"main_table fight_table\"]/tbody/tr/td[2]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
 630        for(i=0; i<fighttable.snapshotLength; i++){
 631            fightlist_mafia[fightlist_mafia.length] = parseInt(fighttable.snapshotItem(i).innerHTML.replace(/\s/g,""));
 632        }
 633//        if(fight_city==4){
 634//            for(i=1; i<fighttable.snapshotLength; i+=6){
 635//                fightlist_mafia[fightlist_mafia.length] = parseInt(fighttable.snapshotItem(i).innerHTML.replace(/\s/g,""));
 636//            }
 637//        }
 638//        else{
 639//            for(i=1; i<fighttable.snapshotLength; i+=5){
 640//                fightlist_mafia[fightlist_mafia.length] = parseInt(fighttable.snapshotItem(i).innerHTML.replace(/\s/g,""));
 641//            }        
 642//        }		
 643        fighttable = document.evaluate( "//table[@class=\"main_table fight_table\"]//td[@class=\"action\"]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
 644        try{
 645            for(i=0; i<fighttable.snapshotLength; i++){
 646                fightlist_attack[fightlist_attack.length] = /'([^']+)/.exec(/reg_fight_view_attack\(([^\)]+)\);/.exec(fighttable.snapshotItem(i).innerHTML)[0].replace(/&amp;/g,'&'))[1];
 647            }
 648        }        
 649        catch(err){alert(fighttable.snapshotItem(i).innerHTML);}
 650        i=0;
 651        
 652        fightlist_match++;
 653        fightlist_loaded=true;
 654        logmsg('Fightlist loaded..','status');
 655
 656        if(fightlist_match >= 3){
 657            logmsg('No matches on the fightlist with set criteria, trying again in 10 seconds','status');
 658            fightlist_match=0;
 659            setTimeout(function(){attack_or_not=true;loadfightpage();},10000);
 660            return;
 661        }
 662        
 663        if(fighttable.snapshotLength <= 0){
 664            logmsg('Blank Fightlist, reloading.','status');
 665            loadfightpage();
 666            return;
 667        }
 668//        document.getElementById('popup_fodder').innerHTML = fightlist_attack;
 669//        document.getElementById('popup_fodder').innerHTML = document.getElementById('popup_fodder').innerHTML.replace(/,/g,'<br>');
 670        
 671        if(attack_or_not == true){
 672            start_attack();
 673        }
 674    }
 675    
 676    function loaduserlist(){
 677        user_list = [];
 678        user_names = [];
 679        user_urls = [];
 680        try{
 681            if(document.getElementById('UserIds').value.length > 0){
 682                user_list = document.getElementById('UserIds').value.split('\n');
 683                user_names = document.getElementById('UserIds').value.split('\n');
 684            }
 685            else if(document.getElementById('UserIds').value.length == 0){
 686                logmsg('Userlist is empty, Stopping..','status');
 687                logmsg('Userlist is empty, Stopping..','attack_log');
 688                stop();
 689                firsttime=true;
 690                return;
 691            }
 692                
 693        }
 694        catch(err){alert('Error ! Check entered Ids');}
 695//        alert(user_list);
 696//        alert(document.getElementById('UserIds').value.split('\n'));
 697//        tmp_key = '';
 698//        tmp_key = /reg_fight_view_attack.*tmp=([^&]+)/.exec(document.body.innerHTML)[1];
 699//        alert(/reg_fight_view_attack.*tmp=([^&]+)/.exec(document.body.innerHTML));
 700//        return;
 701        cb = userid + UnixTS();
 702        for(m=0; m < user_list.length; m++){
 703//            user_urls[user_urls.length]= 'http://facebook.mafiawars.com/mwfb/remote/html_server.php?xw_controller=fight&xw_action=attack&xw_city=1&tmp='+tmp_key+'&cb='+cb+'&opponent_id='+user_list[m]+'&xw_client_id=8&ajax=1&liteload=1&sf_xw_user_id='+userid+'&sf_xw_sig='+local_xw_sig;
 704            tmp_key[tmp_key.length] = '';
 705            user_urls[user_urls.length]= '';
 706//            http://facebook.mafiawars.com/mwfb/remote/html_server.php?sf_xw_user_id=100000540938995&sf_xw_sig=2d32d688c9fe2a40895d5b36068b23d7&xw_controller=fight&xw_action=attack&xw_city=1&tmp=6b686168b37c1472ce5aad8e4e58d643&opponent_id=73904206&ajax=1&skip_req_frame=1
 707        }
 708//        alert(user_urls);
 709        j=0;
 710        attack_user();
 711    }
 712    
 713    function publish_ice(){
 714        var num = this.id;
 715        num = parseInt(/ice_post([0-9]+)/.exec(num)[1]);
 716        eval(iced_posts[num][1]);
 717        this.innerHTML = "Posted";
 718        postFeedAndSendFightBrag();
 719        return false;
 720    }
 721    
 722    function publish_stash(){
 723        var num = this.id;
 724        num = parseInt(/stash_post([0-9]+)/.exec(num)[1]);
 725        eval(stash_posts[num]);
 726        this.innerHTML = "Posted";
 727        popFightLootFeed_0();
 728        return false;
 729    }
 730    
 731    function publish_coins(){
 732        var num = this.id;
 733        num = parseInt(/coin_post([0-9]+)/.exec(num)[1]);
 734        eval(coin_posts[num]);
 735        this.innerHTML = "Posted";
 736        postW2Wback(coin_owner_id[num]);
 737        return false;
 738    }
 739    
 740    function start_attack(){
 741    
 742        if(run == false){
 743            logmsg('Paused...','status');
 744            return;
 745        }
 746        
 747        user_count = parseInt(document.forms.mwpusher.attackcount.value);
 748        if(actual_count >= user_count && user_count!=0){
 749            logmsg('Finished Attack run, Stopping..','status');
 750            stop();
 751            return;
 752        }
 753        
 754        if(document.getElementById('user_stamina').innerHTML <= 0){
 755            logmsg('Ran out of stamina, stopping..','status');
 756            stop();
 757            return;
 758        }        
 759        
 760        if(power_attack && (parseInt(exp_to_levelup) <= 30) && levelup_halt){
 761            logmsg('Could level up on next Attack, Stopping..','status');
 762            stop();
 763            return;
 764        }
 765        
 766        if((!power_attack) && (parseInt(exp_to_levelup) <= 6) && levelup_halt){
 767            logmsg('Could level up on next Attack, Stopping..','status');
 768            stop();
 769            return;
 770        }
 771        
 772        var user_ice_count = parseInt(document.getElementById('ice_count').value);
 773        if((iced_count >= user_ice_count) && (user_ice_count != 0)){
 774            logmsg('Reached specified iced count, Stopping..','status');
 775            stop();
 776            return;        
 777        }
 778        
 779        if(parseInt(document.getElementById('exp_to_level').value) != 0){
 780            if(power_attack){
 781                var user_exp_level = parseInt(document.getElementById('exp_to_level').value) + 30;
 782            }
 783            else{
 784                var user_exp_level = parseInt(document.getElementById('exp_to_level').value) + 6;
 785            }
 786            if(parseInt(exp_to_levelup) < user_exp_level){
 787                logmsg('Could cross user set level up exp on next attack, Stopping..','status');
 788                stop();
 789                return;
 790            }
 791        }
 792        
 793        Trace('In Start attack function');
 794        switch(true){
 795            case document.forms.mwpusher.Fightlist.checked:
 796                pre_check();
 797            break;
 798            case document.forms.mwpusher.Users.checked:
 799                if(firsttime){
 800                    loaduserlist();
 801                }
 802                else{
 803                    attack_user();
 804                }
 805            break;
 806        }
 807    }
 808    
 809    function attack_user(){
 810    	wait1 = parseInt(document.getElementById('delay1').value);
 811        wait2 = parseInt(document.getElementById('delay2').value);
 812        var higher = (wait2 > wait1 ? wait2 : wait1);
 813        var lower = (wait2 > wait1 ? wait1 : wait2);
 814        var random_delay = Math.floor((higher-(lower-1))*Math.random()) + lower;
 815        random_delay = (random_delay < 0)? 0 : random_delay;
 816        
 817        firsttime = false;
 818        Trace('In attack user function');
 819        if(run == false){
 820            logmsg('Paused...','status');
 821            return;
 822        }
 823        
 824        user_count = parseInt(document.forms.mwpusher.attackcount.value);
 825        
 826        heal_thres = parseInt(document.getElementById('heal_thres').value);
 827        if(document.getElementById('user_health').innerHTML < heal_thres){
 828            heal();
 829            return;
 830        }
 831        
 832        if(actual_count >= user_count && user_count != 0){
 833            logmsg('Finished Attack run, Stopping..','status');
 834            stop();
 835            return;
 836        }
 837        
 838        if(document.getElementById('user_stamina').innerHTML <= 0){
 839            logmsg('Ran out of stamina, stopping..','status');
 840            stop();
 841            return;
 842        }        
 843        
 844        if(power_attack && (parseInt(exp_to_levelup) <= 30) && levelup_halt){
 845            logmsg('Could level up on next Attack, Stopping..','status');
 846            stop();
 847            return;
 848        }
 849        
 850        if((!power_attack) && (parseInt(exp_to_levelup) <= 6) && levelup_halt){
 851            logmsg('Could level up on next Attack, Stopping..','status');
 852            stop();
 853            return;
 854        }
 855        
 856        var user_ice_count = parseInt(document.getElementById('ice_count').value);
 857        if((iced_count >= user_ice_count) && (user_ice_count != 0)){
 858            logmsg('Reached specified iced count, Stopping..','status');
 859            stop();
 860            return;        
 861        }
 862        
 863        if(parseInt(document.getElementById('exp_to_level').value) != 0){
 864            if(power_attack){
 865                var user_exp_level = parseInt(document.getElementById('exp_to_level').value) + 30;
 866            }
 867            else{
 868                var user_exp_level = parseInt(document.getElementById('exp_to_level').value) + 6;
 869            }
 870            if(parseInt(exp_to_levelup) < user_exp_level){
 871                logmsg('Could cross user set level up exp on next attack, Stopping..','status');
 872                stop();
 873                return;
 874            }
 875        }
 876        if(user_urls[j]==''){
 877        	logmsg('Fetching Temp key for '+user_names[j]+'..','status');
 878            var params = { 'ajax': 1, 
 879                        'liteload': 1, 
 880                        'sf_xw_user_id': userid,
 881                        'sf_xw_sig': local_xw_sig
 882                    };
 883            var profile_link = 'http://facebook.mafiawars.com/mwfb/remote/html_server.php?xw_controller=stats&xw_action=view&xw_city='+fight_city+'&user='+user_list[j]+'&xw_client_id=8';
 884            $.ajax({type: "POST",url: profile_link, data: params,
 885              success: function (msg){
 886                if(/was not found/.test(msg)){
 887                    logmsg(user_list[j] + ' is not a valid mafia member, skipping..','attack_log');
 888                    j++;
 889//                document.getElementById('logged').innerHTML = document.getElementById('logger').innerHTML +'<br>'+ document.getElementById('logged').innerHTML;
 890                    if(j >= user_list.length){
 891                        if(document.forms.something.UserSkip.checked){
 892                            logmsg('All users Iced/Killed. Stopping..','status');
 893                            document.getElementById('pause').style.display = 'none';
 894                            document.getElementById('begin').style.display = 'inline';
 895                            return;
 896                        }
 897//                        logmsg('Reached last member, reloading..','attack_log');
 898                        logmsg('Reached last member, reloading..','attack_log');
 899                        j=0;
 900                    }
 901                    setTimeout(attack_user,random_delay*1000);
 902                    return;
 903                }
 904                 tmp_key[j] = /tryBuy.*?tmp=([a-f0-9]+)/.exec(msg)[1];
 905                 user_names[j] = /levels">\((.*?)\)/.exec(msg)[1];
 906                 user_list[j] = 'p|'+(/user=p\|(\d+)'.+>Profile/.exec(msg)[1]);
 907//                 user_urls[j]= 'http://facebook.mafiawars.com/mwfb/remote/html_server.php?xw_controller=fight&xw_action=attack&xw_city=1&tmp='+tmp_key+'&cb='+cb+'&opponent_id='+user_list[j]+'&xw_client_id=8&ajax=1&liteload=1&sf_xw_user_id='+userid+'&sf_xw_sig='+local_xw_sig;
 908                 user_urls[j]= 'http://facebook.mafiawars.com/mwfb/remote/html_server.php?xw_controller=fight&xw_action=attack&xw_city='+fight_city+'&tmp='+tmp_key[j]+'&cb='+cb+'&opponent_id='+user_list[j]+'&origin=fight_page&xw_client_id=8';
 909                 setTimeout(attack_user,random_delay*1000);
 910              }
 911            });
 912            return;
 913        }
 914		if(document.getElementById('user_iced_check').checked){
 915            logmsg('Running Ice Check on '+user_names[j],'status');
 916			var target_id = /p\|(\d+)/.exec(user_list[j])[1];
 917            var params = { 'ajax': 1, 
 918                        'liteload': 1, 
 919                        'sf_xw_user_id': userid,
 920                        'sf_xw_sig': local_xw_sig
 921                        };
 922            var hitlist_url = 'http://facebook.mafiawars.com/mwfb/remote/html_server.php?xw_controller=hitlist&xw_action=set&xw_city='+fight_city+'&target_pid='+target_id;
 923            $.ajax({type: "POST",url: hitlist_url, data: params,
 924                success: function (msg){
 925                    if (/You can't add/.test(msg)){
 926                        logmsg(user_names[j]+' is already Iced/Dead, skipping..','status');
 927                        logmsg(user_names[j]+' is already Iced/Dead, skipping..','attack_log');
 928						j++;
 929			            if(j >= user_list.length){
 930			                if(document.forms.something.UserSkip.checked){
 931			                    logmsg('All users Iced/Killed. Stopping..','status');
 932			                    document.getElementById('pause').style.display = 'none';
 933			                    document.getElementById('begin').style.display = 'inline';
 934			                    return;
 935			                }
 936			                logmsg('Reached last member, reloading..','attack_log');
 937			                j=0;
 938			            }
 939			            setTimeout(attack_user,random_delay*1000);
 940                        return;
 941                    }
 942                    else{
 943                        logmsg('Attacking '+user_names[j],'status');
 944				        user_power_attack_enable = document.getElementById('user_power_attack').checked;
 945				        if(user_power_attack){
 946				            user_urls[j] = user_urls[j].replace(/xw_action=attack&/,'xw_action=power_attack&');
 947				            user_urls[j] = user_urls[j].replace(/&origin=fight_page&tab=0/,'');
 948				            try{
 949				                var temp_var = /&tmp=(.+?)&/.exec(user_urls[j])[1];
 950				                user_urls[j] = user_urls[j].replace(temp_var,temp_variable);
 951				            }
 952				            catch(err){}
 953				        }
 954				        var link = user_urls[j];
 955				        var params = { 'ajax': 1, 
 956				                        'liteload': 1, 
 957				                        'sf_xw_user_id': userid,
 958				                        'sf_xw_sig': local_xw_sig
 959				                    };
 960				        req = $.ajax({type: "POST", url: link, data: params,
 961				            success: function (msg){
 962				                document.getElementById('fights').innerHTML = actual_count;
 963				                process_user_attack(msg);
 964				            }
 965				        });
 966                    }
 967                }
 968            });
 969            return;
 970		}
 971		else{
 972			logmsg('Attacking '+user_names[j],'status');
 973			user_power_attack_enable = document.getElementById('user_power_attack').checked;
 974			if(user_power_attack){
 975			    user_urls[j] = user_urls[j].replace(/xw_action=attack&/,'xw_action=power_attack&');
 976			    user_urls[j] = user_urls[j].replace(/&origin=fight_page&tab=0/,'');
 977			    try{
 978			        var temp_var = /&tmp=(.+?)&/.exec(user_urls[j])[1];
 979			        user_urls[j] = user_urls[j].replace(temp_var,temp_variable);
 980			    }
 981			    catch(err){}
 982			}
 983			var link = user_urls[j];
 984			var params = { 'ajax': 1, 
 985			                'liteload': 1, 
 986			                'sf_xw_user_id': userid,
 987			                'sf_xw_sig': local_xw_sig
 988			            };
 989			req = $.ajax({type: "POST", url: link, data: params,
 990			    success: function (msg){
 991			        document.getElementById('fights').innerHTML = actual_count;
 992			        process_user_attack(msg);
 993			    }
 994			});
 995		}
 996    }
 997    
 998    function attack(){
 999        Trace('In attack function');
1000//        alert(fightlist_names.length);
1001
1002        if(run == false){
1003            logmsg('Paused...','status');
1004            return;
1005        }
1006        
1007        user_count = parseInt(document.forms.mwpusher.attackcount.value);
1008        
1009        heal_thres = parseInt(document.getElementById('heal_thres').value);
1010        if(document.getElementById('user_health').innerHTML < heal_thres){
1011            heal();
1012            return;
1013        }
1014        
1015        if(actual_count >= user_count && user_count!=0){
1016            logmsg('Finished Attack run, Stopping..','status');
1017            stop();
1018            return;
1019        }
1020        
1021        if(document.getElementById('user_stamina').innerHTML <= 0){
1022            logmsg('Ran out of stamina, stopping..','status');
1023            stop();
1024            return;
1025        }        
1026        
1027        if(parseInt(document.getElementById('exp_to_level').value) != 0){
1028            if(power_attack){
1029                var user_exp_level = parseInt(document.getElementById('exp_to_level').value) + 30;
1030            }
1031            else{
1032                var user_exp_level = parseInt(document.getElementById('exp_to_level').value) + 6;
1033            }
1034            if(parseInt(exp_to_levelup) < user_exp_level){
1035                logmsg('Could cross user set level up exp on next attack, Stopping..','status');
1036                stop();
1037                return;
1038            }
1039        }
1040        
1041        if(power_attack && (parseInt(exp_to_levelup) <= 30) && levelup_halt){
1042            logmsg('Could level up on next Attack, Stopping..','status');
1043            stop();
1044            return;
1045        }
1046        
1047        if((!power_attack) && (parseInt(exp_to_levelup) <= 6) && levelup_halt){
1048            logmsg('Could level up on next Attack, Stopping..','status');
1049            stop();
1050            return;
1051        }
1052        
1053        var user_ice_count = parseInt(document.getElementById('ice_count').value);
1054        if((iced_count >= user_ice_count) && (user_ice_count != 0)){
1055            logmsg('Reached specified iced count, Stopping..','status');
1056            stop();
1057            return;        
1058        }
1059        
1060        try{
1061            logmsg('Attacking '+fightlist_names[i]+' Level - '+fightlist_levels[i],'status');
1062//        alert(fightlist_attack[i].replace(/&tmp=([^&]+)/.exec(fightlist_attack[i])[0],''));
1063//            timeout_timer = setTimeout(function(){
1064//                if(req){
1065//                    req.abort();
1066//                }
1067//                attack();
1068//            },30000);
1069            power_attack_enable = document.getElementById('power_attack').checked;
1070            if(power_attack){
1071                fightlist_attack[i] = fightlist_attack[i].replace(/xw_action=attack&/,'xw_action=power_attack&');
1072                fightlist_attack[i] = fightlist_attack[i].replace(/&origin=fight_page&tab=0/,'');
1073                var temp_var = /&tmp=(.+?)&/.exec(fightlist_attack[i])[1];
1074                fightlist_attack[i] = fightlist_attack[i].replace(temp_var,temp_variable);
1075            }
1076
1077            var link="http://facebook.mafiawars.com/mwfb/"+fightlist_attack[i]+"&xw_client_id=8";
1078        }
1079        catch(err){alert(err);}
1080  
1081        var params = { 'ajax': 1, 
1082                        'liteload': 1, 
1083                        'sf_xw_user_id': userid,
1084                        'sf_xw_sig': local_xw_sig
1085                    };
1086        req = $.ajax({type: "POST",url: link, timeout: 30000, data: params,
1087            success: function (msg){
1088                //clearTimeout(timeout_timer);
1089                fightlist_match=0;
1090                process_attack(msg);
1091            },
1092            error: function(req,status,err){
1093                logmsg('Request timed out, Retrying attack..','status');
1094                setTimeout(attack,2000);
1095            }
1096        });
1097//    }
1098    
1099//    catch(err){alert(err);}
1100    }
1101    
1102    function process_attack(attack_results){
1103        var temp;
1104        var logtext;
1105        logtext = '';
1106        wait1 = parseInt(document.getElementById('delay1').value);
1107        wait2 = parseInt(document.getElementById('delay2').value);
1108        var higher = (wait2 > wait1 ? wait2 : wait1);
1109        var lower = (wait2 > wait1 ? wait1 : wait2);
1110        var random_delay = Math.floor((higher-(lower-1))*Math.random()) + lower;
1111        
1112        random_delay = (random_delay < 0)? 0 : random_delay;
1113        
1114        Trace('In process attack function');
1115        if(/This player is currently part of your mafia/.test(attack_results)){
1116            logmsg('Player part of your mafia. Fetching next target in '+random_delay+' seconds..','attack_log');
1117            next();
1118            return;
1119        }
1120        else if(!((/You won/i.test(attack_results)) || (/You lost/i.test(attack_results)))){
1121            logmsg('Possible session timeout, Reloading..','status');
1122            attack_or_not = true;
1123            loadfightpage();
1124            return;
1125        }
1126        
1127        actual_count++;
1128        document.getElementById('fights').innerHTML = actual_count;
1129//        document.getElementById('inner_page').innerHTML = attack_results;
1130
1131        killed = false;
1132        iced = false;
1133//        health_lost = /fightres_health">took ([0-9]+)/.exec(attack_results)[1];
1134        document.getElementById('user_health').innerHTML = /user_fields\['user_health'\] = parseInt\("([0-9]+)/.exec(attack_results)[1];
1135        document.getElementById('user_stamina').innerHTML = /user_fields\['user_stamina'\] = parseInt\("([0-9]+)/.exec(attack_results)[1];
1136//        document.getElementById('user_experience').innerHTML = /user_fields\['user_experience'\] = parseInt\("([0-9]+)/.exec(attack_results)[1];
1137        exp_to_levelup = parseInt(/user_fields\['exp_for_next_level'\] = parse

Large files files are truncated, but you can click here to view the full file