PageRenderTime 227ms CodeModel.GetById 43ms RepoModel.GetById 7ms app.codeStats 1ms

/pusher.js

http://pusherbs.googlecode.com/
JavaScript | 2799 lines | 2484 code | 223 blank | 92 comment | 301 complexity | a4a2fdf309cd82c5a39b84b696bfb69e MD5 | raw 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. var trace_enable=false;
  9. var skip_reason;
  10. javascript:(function(){
  11. var run=false;
  12. var req;
  13. var temp_variable;
  14. var fighttable;
  15. var fightlist_names=[];
  16. var fightlist_char_names=[];
  17. var fightlist_levels=[];
  18. var fightlist_attack=[];
  19. var fightlist_mafia=[];
  20. var fightlist_faction=[];
  21. var i=0,j=0;
  22. var user_count=0,actual_count=0;
  23. var cash_city = 1;
  24. var ny_cash=0, moscow_cash=0, bk_cash=0, cuba_cash=0, vegas_cash=0, italy_cash=0;
  25. var exp_gained=0;
  26. var heal_travel=false;
  27. var health_lost=0;
  28. var user_health;
  29. var exp_ratio;
  30. var exp_ratio_reqd;
  31. var exp_to_levelup;
  32. var fightlist_loaded=false;
  33. var fightlist_match=0;
  34. var win=0, loss=0;
  35. var loot_item=[],loot_count,loot_log,l_log='';
  36. var loot_img;
  37. var total_loot=0,temp_loot;
  38. var attack_log=[];
  39. var strong_list=[];
  40. var kills=0, ices=0;
  41. var killed=false, iced=false;
  42. var attack_or_not=false;
  43. var attack_count=0;
  44. var Fightsource = "Fightlist";
  45. var user_list = [];
  46. var user_names = [];
  47. var user_urls = [];
  48. var tmp_key = [];
  49. var cash=0, cash_limit=0, cash_in_hand=0;
  50. var firsttime = true;
  51. var AddMeSpammers = "1726730933\n100000085626146";
  52. var timeout_timer;
  53. var fight_city;
  54. var userid;
  55. var Triad=0, Yakuza=0;
  56. var mafia_attack,initial_mafia_attack=0;
  57. var mafia_defense,initial_mafia_defense=0;
  58. var power_attack = false, user_power_attack = false;
  59. var iced_count=0,killed_count=0;
  60. var iced_posts = [];
  61. var stash_posts = [];
  62. var coin_posts = [],coin_owner_id=[];
  63. // var vault_tmp_variable='', vault_cb_variable='';
  64. var vic_pts = 0,initial_vic_pts = 0;
  65. //cookie stuff
  66. var wait1=1, wait2=2;
  67. var heal_city=1, heal_city_text='New York';
  68. var levelup_halt=true, levelup_text='Stop';
  69. var ignore_chars='';
  70. var bank_enable='',user_bank_enable='', bank_limit=10000;
  71. var attack_limit_enable='', attack_limit_count=3;
  72. var lower_mafia = 1, upper_mafia = 501;
  73. var upper_level = 9999, lower_level = 0;
  74. var min_cash = 0;
  75. var same_city_cash = 'checked';
  76. var faction_bal_points = 10;
  77. var faction_attack = 'checked', triad_fac = '', yakuza_fac = '', faction_bal = 'checked';
  78. var ice_check_enable = 'checked', user_iced_check = 'checked';
  79. var power_attack_enable = false,user_power_attack_enable = false;;
  80. var heal_thres = 30;
  81. var frame=document.getElementsByName('mafiawars');
  82. try{
  83. if(frame.length>0 || (!frame)){
  84. window.location.href=document.getElementsByName('mafiawars')[0].src;
  85. return;
  86. }
  87. else{
  88. document.body.parentNode.style.overflowY="scroll";
  89. try{
  90. if(typeof FB!='undefined'){
  91. FB.CanvasClient.stopTimerToSizeToContent;
  92. window.clearInterval(FB.CanvasClient._timer);
  93. FB.CanvasClient._timer=-1;
  94. }
  95. }
  96. catch(err){}
  97. }
  98. }
  99. catch(err){}
  100. try{
  101. document.getElementById('header_top_promo_banner').parentNode.removeChild(document.getElementById('header_top_promo_banner'));
  102. }
  103. catch(fberr){}
  104. try{
  105. document.getElementById('LoadingOverlay').parentNode.removeChild(document.getElementById('LoadingOverlay'));
  106. document.getElementById('LoadingBackground').parentNode.removeChild(document.getElementById('LoadingBackground'));
  107. }
  108. catch(fberr){}
  109. var userid = /sf_xw_user_id': '(.+)'/.exec(document.body.innerHTML)[1];
  110. var person = /[a-z]\|([0-9]+)/.exec(userid)[1];
  111. fight_city = current_city();
  112. var temp_key = /&tmp=(.+?)&/.exec(document.body.innerHTML)[1];
  113. var cb_value = /&cb=(.+?)&/.exec(document.body.innerHTML)[1];
  114. //Mr redneck cunt and his equally stupid mrs
  115. if(userid == 'p|47869484' || userid == 'p|78199035'){
  116. return;
  117. }
  118. readCookieStuff();
  119. var styles='<style type="text/css">'+
  120. '.sexy_table1{font-weight:bold; border:1px solid #666666; padding-left:10px; }'+
  121. '.sexy_error_table{font-size:17px; background-color:black; color:red; padding-left:10px display:none}'+
  122. '.sexy_select{color:#D0D0D0; border: 1px solid #666666; background-color:black;}'+
  123. '.sexy_input{background-color:black; color:#D0D0D0; font-size:13px; border: 1px solid #666666; padding-left:0.1em}'+
  124. '.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;}'+
  125. '.sexy_destination2{font-weight: bold; background-color:black; color:#FFD927; width:150px; border: 1px solid #FFD927; overflow: hidden;}'+
  126. '</style>';
  127. var table_html='<form id="mwpusher">'+
  128. '<table width="745px" style="border:1px solid #666666; background-color:black;">'+
  129. '<tr>'+
  130. '<td width="100%" style="border:1px solid #666666;">'+
  131. '<table style="background-color:black; height:40px">'+
  132. '<tr>'+
  133. '<th width="50%" style="font-size:20px; padding-left:15px;text-align: left">Pusher v0.22</th>'+
  134. '<th width="48%" style="font-size:12px; text-align:right"></th>'+
  135. '<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>'+
  136. '</tr>'+
  137. '</table>'+
  138. '</td>'+
  139. '</tr>'+
  140. '<tr>'+
  141. '<td width="100%">'+
  142. '<table width=100% style="background-color:black;">'+
  143. '<tr style="height:10px">'+
  144. '<td width="10%">Fights</td>'+
  145. '<td width="1%">:</td>'+
  146. '<td width="2%" id="fights">0</td>'+
  147. '<td width="3%">Of</td>'+
  148. '<td width="75%"><input type=text id="attackcount" value="0" class="sexy_input" style="width:30px" onkeydown="return field_validate(event.keyCode);">'+
  149. ' / Exp to Level : <input type=text id="exp_to_level" value="0" class="sexy_input" style="width:30px" onkeydown="return field_validate(event.keyCode);">'+
  150. ' / Ice count : <input type=text id="ice_count" value="0" class="sexy_input" style="width:50px" onkeydown="return field_validate(event.keyCode);"></td>'+
  151. '<td width="9%"><a id="pause" href="#" style="display:none">Pause</a>'+
  152. '<a id="begin" href="#" style="display:inline">Start</a></td>'+
  153. '</tr></table>'+
  154. '</tr>'+
  155. '<tr>'+
  156. '<td width="100%">'+
  157. '<table width=100% style="background-color:black;">'+
  158. '<tr style="height:10px">'+
  159. '<td width="10%">On stop</td>'+
  160. '<td width="1%">:</td>'+
  161. '<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, '+
  162. '<input type="checkbox" id="finish_heal_enable"> Heal '+
  163. '</td>'+
  164. '</tr></table>'+
  165. '</tr>'+
  166. '<tr>'+
  167. '<td width="100%">'+
  168. '<table width=100% style="background-color:black;">'+
  169. '<tr style="height:10px">'+
  170. '<td width="10%">Exp Gain</td>'+
  171. '<td width="1%">:</td>'+
  172. '<td width="25%">&nbsp;<span id="exp_gained">0</span> &nbsp;(<span id="exp_ratio">0.00</span> exp/stam)</td>'+
  173. '<td width="12%" align="right">Exp Required</td>'+
  174. '<td width="1%" align="right">:</td>'+
  175. '<td width="28%" align="right"><span id="exp_reqd">0</span> &nbsp;(<span id="exp_ratio_reqd">0.00</span> exp/stam)</td>'+
  176. '<td width="5%">Wins</td>'+
  177. '<td width="1%">:</td>'+
  178. '<td width="5%"><span class="good" id="wins">0</span></td>'+
  179. '<td width="1%">&nbsp;</td>'+
  180. '<td width="5%">Losses</td>'+
  181. '<td width="1%">:</td>'+
  182. '<td width="5%"><span class="bad" id="losses">0</span></td>'+
  183. '</tr>'+
  184. '</table>'+
  185. '</td>'+
  186. '</tr>'+
  187. '<tr>'+
  188. '<td width="100%">'+
  189. '<table width=100% style="background-color:black;">'+
  190. '<tr style="height:10px">'+
  191. '<td width="10%">Status</td>'+
  192. '<td width="1%">:</td>'+
  193. '<td width="62%"><span id="status">&nbsp;</span></td>'+
  194. '<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>'+
  195. '<td width="1%">:</td>'+
  196. '<td width="13%">&nbsp;<a id="heal_city_change" href="#"><span id="heal_city">'+heal_city_text+'</span></a></td>'+
  197. '</tr>'+
  198. '</table>'+
  199. '</td>'+
  200. '</tr>'+
  201. '<tr>'+
  202. '<td width="100%">'+
  203. '<table width=100% style="background-color:black;">'+
  204. '<tr style="height:10px">'+
  205. '<td width="10%">Cash</td>'+
  206. '<td width="1%">:</td>'+
  207. '<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>'+
  208. '</tr>'+
  209. '</table>'+
  210. '</td>'+
  211. '</tr>'+
  212. '<tr>'+
  213. '<td width="100%">'+
  214. '<table width=100% style="background-color:black;">'+
  215. '<tr style="height:10px">'+
  216. '<td width="65%">&nbsp;</td>'+
  217. '<td width="13%"><img src="http://mwfb.static.zynga.com/mwfb/graphics/victory_icon.gif"></img><span id="Victorycoins">0</span></td>'+
  218. '<td width="1%">&nbsp;</td>'+
  219. '<td width="8%">Delay</td>'+
  220. '<td width="1%">:</td>'+
  221. '<td width="5%"><input type=text id="delay1" value="'+wait1+'" class="sexy_input" style="width:25px" onkeydown="return field_validate(event.keyCode);"></td>'+
  222. '<td width="2%">to</td>'+
  223. '<td width="5%"><input type=text id="delay2" value="'+wait2+'" class="sexy_input" style="width:25px" onkeydown="return field_validate(event.keyCode);"></td>'+
  224. '</tr>'+
  225. '</table>'+
  226. '</td>'+
  227. '</tr>'+
  228. '<tr>'+
  229. '<td width="100%" >'+
  230. '<table width=100% style="background-color:black;">'+
  231. '<tr style="height:10px">'+
  232. '<td width="10%">Stats</td>'+
  233. '<td width="1%">:</td>'+
  234. '<td width="5%"><img src="http://mwfb.static.zynga.com/mwfb/graphics/bangkok_yakuza_small.gif" alt="Yakuza"></img></td>'+
  235. '<td width="5%" id="Yakuza_points">0</td>'+
  236. '<td width="1%">&nbsp;</td>'+
  237. '<td width="5%"><img src="http://mwfb.static.zynga.com/mwfb/graphics/bangkok_triads_small.gif" alt="Triad"></img></td>'+
  238. '<td width="5%" id="Triad_points">0</td>'+
  239. '<td width="3%">&nbsp;</td>'+
  240. '<td width="3%"><img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_mafia_attack_22x16_01.gif"></img></td>'+
  241. '<td width="17%"> <span id="mafia_attack">0</span> [<span id="attack_diff"><span class="good">+0</span></span>]</td>'+
  242. '<td width="3%"><img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_mafia_defense_22x16_01.gif"></img></td>'+
  243. '<td width="17%"> <span id="mafia_defense">0</span> [<span id="defense_diff"><span class="good">+0</span></span>]</td>'+
  244. '<td width="3%"><img src="http://codeoutpost.com/Scripts/kill.png" alt="Kills"></img></td>'+
  245. '<td width="1%">:</td>'+
  246. '<td width="7%"><span id="kills_log">0</span></td>'+
  247. '<td width="2%">&nbsp;</td>'+
  248. '<td width="3%"><img src="http://codeoutpost.com/Scripts/Ice.png" alt="Iced"></img></td>'+
  249. '<td width="1%">:</td>'+
  250. '<td width="7%"><span id="iced_log">0</span></td>'+
  251. '</tr>'+
  252. '</table>'+
  253. '</td>'+
  254. '</tr>'+
  255. '<tr>'+
  256. '<td width="100%">'+
  257. '<table width=100% style="background-color:black;">'+
  258. '<td width="10%">Fight</td>'+
  259. '<td width="1%">:</td>'+
  260. '<td width="25%"><input type="radio" id="Fightlist" name="fight_choice" checked>Fightlist</input></td>'+
  261. '<td width="25%"><input type="radio" id="Users" name="fight_choice">Specific Users</input></td>'+
  262. // '<td width="25%"><input type="radio" id="Spammers" name="fight_choice">Add Me Spammers</input></td>'+
  263. '<td width="10%" style="text-align:right">&nbsp;</td>'+
  264. '<td width="15%">Before level up</td>'+
  265. '<td width="1%">:</td>'+
  266. '<td width="13%"><a id="levelup" href="#">'+levelup_text+'</a></td>'+
  267. '</table>'+
  268. '</td>'+
  269. '</tr>'+
  270. '<tr id="UserChoice" style="display:none">'+
  271. '<td width="100%">'+
  272. '<table width=100% id="useroption" style="background-color:black;border:1px solid #666666;">'+
  273. '<tr>'+
  274. '<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>'+
  275. '</tr>'+
  276. '<tr>'+
  277. '<td colspan="13"><input type="checkbox" id="user_iced_check" '+user_iced_check+'> Only attack live targets</td>'+
  278. '</tr>'+
  279. '<tr style="height:10px">'+
  280. '<td width="20%">Enter User Id\'s here (one id per line)</td>'+
  281. '<td width="1%">:</td>'+
  282. '<td width="30%" colspan=4><textarea id="UserIds" class="sexy_input"></textarea></td>'+
  283. '<td width="49%" colspan=4><input type="checkbox" id="UserSkip">Stop if all users are Iced/Killed</input>'+
  284. '<br><br><a id="AddSpammers" class="sexy_button_new"><span><span>Load Spammer List</span></span></a></td>'+
  285. '</tr>'+
  286. '</table>'+
  287. '</td>'+
  288. '</tr>'+
  289. '<tr id="FightChoice">'+
  290. '<td width="100%">'+
  291. '<table width=100% id="fightlistoption" style="background-color:black;border:1px solid #666666;">'+
  292. '<tr>'+
  293. '<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>'+
  294. '</tr>'+
  295. '<tr>'+
  296. '<td colspan="13"><input type="checkbox" id="faction_enable" '+faction_attack+'> Enable Specific Faction Attack : '+
  297. '<input type="radio" id="Triad" name="faction" '+triad_fac+'> Attack Triad Only '+
  298. '<input type="radio" id="Yakuza" name="faction" '+yakuza_fac+'> Attack Yakuza Only '+
  299. '<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>'+
  300. '</tr>'+
  301. '<tr>'+
  302. '<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>'+
  303. '</tr>'+
  304. '<tr>'+
  305. '<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>'+
  306. '</tr>'+
  307. '<tr>'+
  308. '<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>'+
  309. '</tr>'+
  310. '<tr style="height:10px">'+
  311. '<td width="10%">Levels</td>'+
  312. '<td width="1%">:</td>'+
  313. '<td width="5%"><input type="text" id="LowerLevel" class="sexy_input" style="width:30px" value="'+lower_level+'"></input></td>'+
  314. '<td width="3%">to</td>'+
  315. '<td width="5%"><input type="text" id="UpperLevel" class="sexy_input" style="width:30px" value="'+upper_level+'"></input></td>'+
  316. '<td rowspan=2 width="5%">&nbsp;</td>'+
  317. '<td rowspan=2 width="30%">Ignore Names with Characters</td>'+
  318. '<td rowspan=2 width="1%">:</td>'+
  319. '<td rowspan=2 width="35%" colspan=4><textarea id="SpecialChars" class="sexy_input">'+ignore_chars+'</textarea></td>'+
  320. '</tr>'+
  321. '<tr style="height:10px">'+
  322. '<td width="10%">Mafia </td>'+
  323. '<td width="1%">:</td>'+
  324. '<td width="5%"><input type="text" id="LowerMafia" style="width:30px" class="sexy_input" value="'+lower_mafia+'"></input></td>'+
  325. '<td width="3%">to</td>'+
  326. '<td width="5%"><input type="text" id="UpperMafia" style="width:30px" class="sexy_input" value="'+upper_mafia+'"></input></td>'+
  327. '<td width="76%" colspan=4>&nbsp;</td>'+
  328. '</tr>'+
  329. '</table>'+
  330. '</td>'+
  331. '</tr>'+
  332. '<tr>'+
  333. '<td width="100%">'+
  334. '<table width="100%" style="background-color:black; height:40px">'+
  335. '<tr><td width="10%" valign="top"><a href="#" id="posts_show">Ices/Stashes/Coins</a></td>'+
  336. '<td width="1%" valign="top">:</td>'+
  337. '<td width="29%" id="ice_posts_log" valign="top" style="display:none">Ice Count - Name - Posts<br></td>'+
  338. '<td width="29%" id="stash_posts_log" valign="top" style="display:none">Finder - Stash Post<br></td>'+
  339. '<td width="31%" id="coin_posts_log" valign="top" style="display:none">Finder - Coins Post<br></td>'+
  340. '</tr>'+
  341. '<tr><td width="10%" valign="top"><a href="#" id="loot_show">Loot (<span id="loot_percent"></span>%)</a></td>'+
  342. '<td width="1%" valign="top">:</td>'+
  343. '<td id="loot_log" valign="top" colspan="3"></td>'+
  344. '</tr>'+
  345. '<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>'+
  346. '<td width="1%" valign="top">:</td>'+
  347. '<td id="attack_log" colspan="3"></td>'+
  348. '</tr>'+
  349. '</table>'+
  350. '</td>'+
  351. '</tr>'+
  352. '</table>'+
  353. '</form>';
  354. var error_window='<table class="sexy_error_table" width=100% border=2 rules=none bgcolor="black" id="errormsg"></table><br>';
  355. try{
  356. document.getElementById('popup_permanence').removeChild(document.getElementById('fight_attack_div'));
  357. }
  358. catch(err){}
  359. var content=document.getElementById('popup_permanence');
  360. var fight_attack_div=document.createElement("div");
  361. fight_attack_div.id='fight_attack_div';
  362. fight_attack_div.innerHTML = styles+error_window+table_html;
  363. content.insertBefore(fight_attack_div,content.firstChild);
  364. document.getElementById("AddSpammers").onclick = loadSpammers;
  365. document.getElementById("close").onclick=function(){
  366. writeCookieStuff();
  367. run=false;
  368. try{
  369. document.getElementById('popup_permanence').removeChild(document.getElementById('fight_attack_div'));
  370. }
  371. catch(err){}
  372. }
  373. document.getElementById("begin").onclick=function(){
  374. if(fightlist_loaded){
  375. document.getElementById("begin").style.display = 'none';
  376. document.getElementById("pause").style.display = 'inline';
  377. run=true;
  378. attack_or_not = true;
  379. user_count = parseInt(document.forms.mwpusher.attackcount.value);
  380. writeCookieStuff();
  381. start_attack();
  382. }
  383. return false;
  384. }
  385. document.getElementById("pause").onclick=function(){
  386. run=false;
  387. document.getElementById("pause").style.display = 'none';
  388. document.getElementById("begin").style.display = 'inline';
  389. // user_count = parseInt(document.forms.mwpusher.attackcount.value);
  390. // attack();
  391. writeCookieStuff();
  392. return false;
  393. }
  394. document.getElementById("loot_show").onclick=function(){
  395. switch(document.getElementById('loot_log').style.display){
  396. case '':
  397. document.getElementById('loot_log').style.display = 'none';
  398. break;
  399. case 'none':
  400. document.getElementById('loot_log').style.display = '';
  401. break;
  402. }
  403. return false;
  404. }
  405. document.getElementById("posts_show").onclick=function(){
  406. switch(document.getElementById('ice_posts_log').style.display){
  407. case '':
  408. document.getElementById('ice_posts_log').style.display = 'none';
  409. document.getElementById('stash_posts_log').style.display = 'none';
  410. document.getElementById('coin_posts_log').style.display = 'none';
  411. break;
  412. case 'none':
  413. document.getElementById('ice_posts_log').style.display = '';
  414. document.getElementById('stash_posts_log').style.display = '';
  415. document.getElementById('coin_posts_log').style.display = '';
  416. break;
  417. }
  418. return false;
  419. }
  420. document.getElementById("log_show").onclick=function(){
  421. switch(document.getElementById('attack_log').style.display){
  422. case '':
  423. document.getElementById('attack_log').style.display = 'none';
  424. break;
  425. case 'none':
  426. document.getElementById('attack_log').style.display = '';
  427. break;
  428. }
  429. return false;
  430. }
  431. document.getElementById("Fightlist").onclick=function(){
  432. Fightsource = "Fightlist";
  433. document.getElementById("FightChoice").style.display='';
  434. document.getElementById("UserChoice").style.display='none';
  435. }
  436. document.getElementById("Users").onclick=function(){
  437. Fightsource = "Users";
  438. document.getElementById("FightChoice").style.display='none';
  439. document.getElementById("UserChoice").style.display='';
  440. }
  441. document.getElementById("levelup").onclick=function(){
  442. if(levelup_halt){
  443. levelup_halt=false;
  444. levelup_text = document.getElementById("levelup").innerHTML = "Continue";
  445. }
  446. else{
  447. levelup_halt=true;
  448. levelup_text = document.getElementById("levelup").innerHTML = "Stop";
  449. }
  450. writeCookieStuff();
  451. return false;
  452. }
  453. document.getElementById("bank_enable").onclick=function(){
  454. writeCookieStuff();
  455. }
  456. document.getElementById("user_bank_enable").onclick=function(){
  457. writeCookieStuff();
  458. }
  459. document.getElementById("cash_city").onclick=function(){
  460. writeCookieStuff();
  461. }
  462. document.getElementById("faction_enable").onclick=function(){
  463. writeCookieStuff();
  464. }
  465. document.getElementById("Triad").onclick=function(){
  466. writeCookieStuff();
  467. }
  468. document.getElementById("Yakuza").onclick=function(){
  469. writeCookieStuff();
  470. }
  471. document.getElementById("Balance_Faction").onclick=function(){
  472. writeCookieStuff();
  473. }
  474. document.getElementById("heal_city_change").onclick=function(){
  475. heal_city++;
  476. heal_city=(heal_city>6)?0:heal_city;
  477. switch(heal_city){
  478. case 0:
  479. heal_city_text = document.getElementById("heal_city").innerHTML="Disabled";
  480. break;
  481. case 1:
  482. heal_city_text = document.getElementById("heal_city").innerHTML="New York";
  483. break;
  484. case 2:
  485. heal_city_text = document.getElementById("heal_city").innerHTML="Cuba";
  486. break;
  487. case 3:
  488. heal_city_text = document.getElementById("heal_city").innerHTML="Moscow";
  489. break;
  490. case 4:
  491. heal_city_text = document.getElementById("heal_city").innerHTML="Bangkok";
  492. break;
  493. case 5:
  494. heal_city_text = document.getElementById("heal_city").innerHTML="Las Vegas";
  495. break;
  496. case 6:
  497. heal_city_text = document.getElementById("heal_city").innerHTML="Italy";
  498. break;
  499. }
  500. writeCookieStuff();
  501. return false;
  502. }
  503. function UnixTS(){
  504. return (Math.round(new Date().getTime() / 1000));
  505. }
  506. function loadfightpage(){
  507. logmsg('Loading fight page...','status');
  508. cb = userid+UnixTS();
  509. fightlist_loaded = false;
  510. document.getElementById('inner_page').addEventListener('DOMSubtreeModified', function(){
  511. if(pageLoading==0){
  512. switch(true){
  513. case document.forms.mwpusher.Fightlist.checked:
  514. setTimeout(loadfightlist,1000);
  515. break;
  516. case document.forms.mwpusher.Users.checked:
  517. if(attack_or_not){
  518. setTimeout(loaduserlist,1000)
  519. }
  520. break;
  521. }
  522. this.removeEventListener('DOMSubtreeModified',arguments.callee,false);
  523. }
  524. },false);
  525. do_ajax('inner_page','remote/html_server.php?xw_controller=fight&xw_action=view&cb='+cb,1,1,0);
  526. }
  527. function loadfightlist(){
  528. fightlist_names=[];
  529. fightlist_char_names=[];
  530. fightlist_levels=[];
  531. fightlist_mafia=[];
  532. fightlist_attack=[];
  533. fightlist_faction=[];
  534. var index=0;
  535. try{
  536. 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 );
  537. if(fightlist_war_button.snapshotLength >= 1){
  538. index = 1;
  539. }
  540. }
  541. catch(err){}
  542. fighttable = document.evaluate("//table[@class=\"main_table fight_table\"]/tbody/tr", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
  543. // alert(fighttable.snapshotLength);
  544. // fighttable = document.evaluate("//table[@class=\"main_table fight_table\"]//tbody//tr", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
  545. // alert(fighttable.snapshotLength);
  546. for(i=1; i<fighttable.snapshotLength; i++){
  547. fightlist_names[fightlist_names.length] = /<a.+\/a>/.exec(fighttable.snapshotItem(i).getElementsByTagName('td')[0].innerHTML);
  548. fightlist_char_names[fightlist_char_names.length] = fighttable.snapshotItem(i).getElementsByTagName('td')[0].getElementsByTagName('a')[0].innerHTML;
  549. fightlist_levels[fightlist_levels.length] = parseInt(/Level ([0-9]+)/.exec(fighttable.snapshotItem(i).getElementsByTagName('td')[0].innerHTML)[1]);
  550. if(fight_city==4){
  551. fightlist_faction[fightlist_faction.length] = fighttable.snapshotItem(i).getElementsByTagName('td')[2].getElementsByTagName('img')[0].alt;
  552. // alert(fightlist_faction[fightlist_faction.length - 1]);
  553. }
  554. }
  555. fighttable = document.evaluate( "//table[@class=\"main_table fight_table\"]/tbody/tr/td[2]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
  556. for(i=0; i<fighttable.snapshotLength; i++){
  557. fightlist_mafia[fightlist_mafia.length] = parseInt(fighttable.snapshotItem(i).innerHTML.replace(/\s/g,""));
  558. }
  559. // if(fight_city==4){
  560. // for(i=1; i<fighttable.snapshotLength; i+=6){
  561. // fightlist_mafia[fightlist_mafia.length] = parseInt(fighttable.snapshotItem(i).innerHTML.replace(/\s/g,""));
  562. // }
  563. // }
  564. // else{
  565. // for(i=1; i<fighttable.snapshotLength; i+=5){
  566. // fightlist_mafia[fightlist_mafia.length] = parseInt(fighttable.snapshotItem(i).innerHTML.replace(/\s/g,""));
  567. // }
  568. // }
  569. fighttable = document.evaluate( "//table[@class=\"main_table fight_table\"]//td[@class=\"action\"]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
  570. try{
  571. for(i=0; i<fighttable.snapshotLength; i++){
  572. fightlist_attack[fightlist_attack.length] = /'([^']+)/.exec(/reg_fight_view_attack\(([^\)]+)\);/.exec(fighttable.snapshotItem(i).innerHTML)[0].replace(/&amp;/g,'&'))[1];
  573. }
  574. }
  575. catch(err){alert(fighttable.snapshotItem(i).innerHTML);}
  576. i=0;
  577. fightlist_match++;
  578. fightlist_loaded=true;
  579. logmsg('Fightlist loaded..','status');
  580. if(fightlist_match >= 3){
  581. logmsg('No matches on the fightlist with set criteria, trying again in 10 seconds','status');
  582. fightlist_match=0;
  583. setTimeout(function(){attack_or_not=true;loadfightpage();},10000);
  584. return;
  585. }
  586. if(fighttable.snapshotLength <= 0){
  587. logmsg('Blank Fightlist, reloading.','status');
  588. loadfightpage();
  589. return;
  590. }
  591. // document.getElementById('popup_fodder').innerHTML = fightlist_attack;
  592. // document.getElementById('popup_fodder').innerHTML = document.getElementById('popup_fodder').innerHTML.replace(/,/g,'<br>');
  593. if(attack_or_not == true){
  594. start_attack();
  595. }
  596. }
  597. function loaduserlist(){
  598. user_list = [];
  599. user_names = [];
  600. user_urls = [];
  601. try{
  602. if(document.getElementById('UserIds').value.length > 0){
  603. user_list = document.getElementById('UserIds').value.split('\n');
  604. user_names = document.getElementById('UserIds').value.split('\n');
  605. }
  606. else if(document.getElementById('UserIds').value.length == 0){
  607. logmsg('Userlist is empty, Stopping..','status');
  608. logmsg('Userlist is empty, Stopping..','attack_log');
  609. stop();
  610. firsttime=true;
  611. return;
  612. }
  613. }
  614. catch(err){alert('Error ! Check entered Ids');}
  615. // alert(user_list);
  616. // alert(document.getElementById('UserIds').value.split('\n'));
  617. // tmp_key = '';
  618. // tmp_key = /reg_fight_view_attack.*tmp=([^&]+)/.exec(document.body.innerHTML)[1];
  619. // alert(/reg_fight_view_attack.*tmp=([^&]+)/.exec(document.body.innerHTML));
  620. // return;
  621. cb = userid + UnixTS();
  622. for(m=0; m < user_list.length; m++){
  623. // 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;
  624. tmp_key[tmp_key.length] = '';
  625. user_urls[user_urls.length]= '';
  626. // 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
  627. }
  628. // alert(user_urls);
  629. j=0;
  630. attack_user();
  631. }
  632. function publish_ice(){
  633. var num = this.id;
  634. num = parseInt(/ice_post([0-9]+)/.exec(num)[1]);
  635. eval(iced_posts[num][1]);
  636. this.innerHTML = "Posted";
  637. postFeedAndSendFightBrag();
  638. return false;
  639. }
  640. function publish_stash(){
  641. var num = this.id;
  642. num = parseInt(/stash_post([0-9]+)/.exec(num)[1]);
  643. eval(stash_posts[num]);
  644. this.innerHTML = "Posted";
  645. popFightLootFeed_0();
  646. return false;
  647. }
  648. function publish_coins(){
  649. var num = this.id;
  650. num = parseInt(/coin_post([0-9]+)/.exec(num)[1]);
  651. eval(coin_posts[num]);
  652. this.innerHTML = "Posted";
  653. postW2Wback(coin_owner_id[num]);
  654. return false;
  655. }
  656. function start_attack(){
  657. if(run == false){
  658. logmsg('Paused...','status');
  659. return;
  660. }
  661. user_count = parseInt(document.forms.mwpusher.attackcount.value);
  662. if(actual_count >= user_count && user_count!=0){
  663. logmsg('Finished Attack run, Stopping..','status');
  664. stop();
  665. return;
  666. }
  667. if(document.getElementById('user_stamina').innerHTML <= 0){
  668. logmsg('Ran out of stamina, stopping..','status');
  669. stop();
  670. return;
  671. }
  672. if(power_attack && (parseInt(exp_to_levelup) <= 30) && levelup_halt){
  673. logmsg('Could level up on next Attack, Stopping..','status');
  674. stop();
  675. return;
  676. }
  677. if((!power_attack) && (parseInt(exp_to_levelup) <= 6) && levelup_halt){
  678. logmsg('Could level up on next Attack, Stopping..','status');
  679. stop();
  680. return;
  681. }
  682. var user_ice_count = parseInt(document.getElementById('ice_count').value);
  683. if((iced_count >= user_ice_count) && (user_ice_count != 0)){
  684. logmsg('Reached specified iced count, Stopping..','status');
  685. stop();
  686. return;
  687. }
  688. if(parseInt(document.getElementById('exp_to_level').value) != 0){
  689. if(power_attack){
  690. var user_exp_level = parseInt(document.getElementById('exp_to_level').value) + 30;
  691. }
  692. else{
  693. var user_exp_level = parseInt(document.getElementById('exp_to_level').value) + 6;
  694. }
  695. if(parseInt(exp_to_levelup) < user_exp_level){
  696. logmsg('Could cross user set level up exp on next attack, Stopping..','status');
  697. stop();
  698. return;
  699. }
  700. }
  701. Trace('In Start attack function');
  702. switch(true){
  703. case document.forms.mwpusher.Fightlist.checked:
  704. pre_check();
  705. break;
  706. case document.forms.mwpusher.Users.checked:
  707. if(firsttime){
  708. loaduserlist();
  709. }
  710. else{
  711. attack_user();
  712. }
  713. break;
  714. }
  715. }
  716. function attack_user(){
  717. wait1 = parseInt(document.getElementById('delay1').value);
  718. wait2 = parseInt(document.getElementById('delay2').value);
  719. var higher = (wait2 > wait1 ? wait2 : wait1);
  720. var lower = (wait2 > wait1 ? wait1 : wait2);
  721. var random_delay = Math.floor((higher-(lower-1))*Math.random()) + lower;
  722. random_delay = (random_delay < 0)? 0 : random_delay;
  723. firsttime = false;
  724. Trace('In attack user function');
  725. if(run == false){
  726. logmsg('Paused...','status');
  727. return;
  728. }
  729. user_count = parseInt(document.forms.mwpusher.attackcount.value);
  730. heal_thres = parseInt(document.getElementById('heal_thres').value);
  731. if(document.getElementById('user_health').innerHTML < heal_thres){
  732. heal();
  733. return;
  734. }
  735. if(actual_count >= user_count && user_count != 0){
  736. logmsg('Finished Attack run, Stopping..','status');
  737. stop();
  738. return;
  739. }
  740. if(document.getElementById('user_stamina').innerHTML <= 0){
  741. logmsg('Ran out of stamina, stopping..','status');
  742. stop();
  743. return;
  744. }
  745. if(power_attack && (parseInt(exp_to_levelup) <= 30) && levelup_halt){
  746. logmsg('Could level up on next Attack, Stopping..','status');
  747. stop();
  748. return;
  749. }
  750. if((!power_attack) && (parseInt(exp_to_levelup) <= 6) && levelup_halt){
  751. logmsg('Could level up on next Attack, Stopping..','status');
  752. stop();
  753. return;
  754. }
  755. var user_ice_count = parseInt(document.getElementById('ice_count').value);
  756. if((iced_count >= user_ice_count) && (user_ice_count != 0)){
  757. logmsg('Reached specified iced count, Stopping..','status');
  758. stop();
  759. return;
  760. }
  761. if(parseInt(document.getElementById('exp_to_level').value) != 0){
  762. if(power_attack){
  763. var user_exp_level = parseInt(document.getElementById('exp_to_level').value) + 30;
  764. }
  765. else{
  766. var user_exp_level = parseInt(document.getElementById('exp_to_level').value) + 6;
  767. }
  768. if(parseInt(exp_to_levelup) < user_exp_level){
  769. logmsg('Could cross user set level up exp on next attack, Stopping..','status');
  770. stop();
  771. return;
  772. }
  773. }
  774. if(user_urls[j]==''){
  775. logmsg('Fetching Temp key for '+user_names[j]+'..','status');
  776. var params = { 'ajax': 1,
  777. 'liteload': 1,
  778. 'sf_xw_user_id': userid,
  779. 'sf_xw_sig': local_xw_sig
  780. };
  781. 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';
  782. $.ajax({type: "POST",url: profile_link, data: params,
  783. success: function (msg){
  784. if(/was not found/.test(msg)){
  785. logmsg(user_list[j] + ' is not a valid mafia member, skipping..','attack_log');
  786. j++;
  787. // document.getElementById('logged').innerHTML = document.getElementById('logger').innerHTML +'<br>'+ document.getElementById('logged').innerHTML;
  788. if(j >= user_list.length){
  789. if(document.forms.something.UserSkip.checked){
  790. logmsg('All users Iced/Killed. Stopping..','status');
  791. document.getElementById('pause').style.display = 'none';
  792. document.getElementById('begin').style.display = 'inline';
  793. return;
  794. }
  795. // logmsg('Reached last member, reloading..','attack_log');
  796. logmsg('Reached last member, reloading..','attack_log');
  797. j=0;
  798. }
  799. setTimeout(attack_user,random_delay*1000);
  800. return;
  801. }
  802. tmp_key[j] = /tryBuy.*?tmp=([a-f0-9]+)/.exec(msg)[1];
  803. user_names[j] = /levels">\((.*?)\)/.exec(msg)[1];
  804. user_list[j] = 'p|'+(/user=p\|(\d+)'.+>Profile/.exec(msg)[1]);
  805. // 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;
  806. 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';
  807. setTimeout(attack_user,random_delay*1000);
  808. }
  809. });
  810. return;
  811. }
  812. if(document.getElementById('user_iced_check').checked){
  813. logmsg('Running Ice Check on '+user_names[j],'status');
  814. var target_id = /p\|(\d+)/.exec(user_list[j])[1];
  815. var params = { 'ajax': 1,
  816. 'liteload': 1,
  817. 'sf_xw_user_id': userid,
  818. 'sf_xw_sig': local_xw_sig
  819. };
  820. 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;
  821. $.ajax({type: "POST",url: hitlist_url, data: params,
  822. success: function (msg){
  823. if (/You can't add/.test(msg)){
  824. logmsg(user_names[j]+' is already Iced/Dead, skipping..','status');
  825. logmsg(user_names[j]+' is already Iced/Dead, skipping..','attack_log');
  826. j++;
  827. if(j >= user_list.length){
  828. if(document.forms.something.UserSkip.checked){
  829. logmsg('All users Iced/Killed. Stopping..','status');
  830. document.getElementById('pause').style.display = 'none';
  831. document.getElementById('begin').style.display = 'inline';
  832. return;
  833. }
  834. logmsg('Reached last member, reloading..','attack_log');
  835. j=0;
  836. }
  837. setTimeout(attack_user,random_delay*1000);
  838. return;
  839. }
  840. else{
  841. logmsg('Attacking '+user_names[j],'status');
  842. user_power_attack_enable = document.getElementById('user_power_attack').checked;
  843. if(user_power_attack){
  844. user_urls[j] = user_urls[j].replace(/xw_action=attack&/,'xw_action=power_attack&');
  845. user_urls[j] = user_urls[j].replace(/&origin=fight_page&tab=0/,'');
  846. try{
  847. var temp_var = /&tmp=(.+?)&/.exec(user_urls[j])[1];
  848. user_urls[j] = user_urls[j].replace(temp_var,temp_variable);
  849. }
  850. catch(err){}
  851. }
  852. var link = user_urls[j];
  853. var params = { 'ajax': 1,
  854. 'liteload': 1,
  855. 'sf_xw_user_id': userid,
  856. 'sf_xw_sig': local_xw_sig
  857. };
  858. req = $.ajax({type: "POST", url: link, data: params,
  859. success: function (msg){
  860. document.getElementById('fights').innerHTML = actual_count;
  861. process_user_attack(msg);
  862. }
  863. });
  864. }
  865. }
  866. });
  867. return;
  868. }
  869. else{
  870. logmsg('Attacking '+user_names[j],'status');
  871. user_power_attack_enable = document.getElementById('user_power_attack').checked;
  872. if(user_power_attack){
  873. user_urls[j] = user_urls[j].replace(/xw_action=attack&/,'xw_action=power_attack&');
  874. user_urls[j] = user_urls[j].replace(/&origin=fight_page&tab=0/,'');
  875. try{
  876. var temp_var = /&tmp=(.+?)&/.exec(user_urls[j])[1];
  877. user_urls[j] = user_urls[j].replace(temp_var,temp_variable);
  878. }
  879. catch(err){}
  880. }
  881. var link = user_urls[j];
  882. var params = { 'ajax': 1,
  883. 'liteload': 1,
  884. 'sf_xw_user_id': userid,
  885. 'sf_xw_sig': local_xw_sig
  886. };
  887. req = $.ajax({type: "POST", url: link, data: params,
  888. success: function (msg){
  889. document.getElementById('fights').innerHTML = actual_count;
  890. process_user_attack(msg);
  891. }
  892. });
  893. }
  894. }
  895. function attack(){
  896. Trace('In attack function');
  897. // alert(fightlist_names.length);
  898. if(run == false){
  899. logmsg('Paused...','status');
  900. return;
  901. }
  902. user_count = parseInt(document.forms.mwpusher.attackcount.value);
  903. heal_thres = parseInt(document.getElementById('heal_thres').value);
  904. if(document.getElementById('user_health').innerHTML < heal_thres){
  905. heal();
  906. return;
  907. }
  908. if(actual_count >= user_count && user_count!=0){
  909. logmsg('Finished Attack run, Stopping..','status');
  910. stop();
  911. return;
  912. }
  913. if(document.getElementById('user_stamina').innerHTML <= 0){
  914. logmsg('Ran out of stamina, stopping..','status');
  915. stop();
  916. return;
  917. }
  918. if(parseInt(document.getElementById('exp_to_level').value) != 0){
  919. if(power_attack){
  920. var user_exp_level = parseInt(document.getElementById('exp_to_level').value) + 30;
  921. }
  922. else{
  923. var user_exp_level = parseInt(document.getElementById('exp_to_level').value) + 6;
  924. }
  925. if(parseInt(exp_to_levelup) < user_exp_level){
  926. logmsg('Could cross user set level up exp on next attack, Stopping..','status');
  927. stop();
  928. return;
  929. }
  930. }
  931. if(power_attack && (parseInt(exp_to_levelup) <= 30) && levelup_halt){
  932. logmsg('Could level up on next Attack, Stopping..','status');
  933. stop();
  934. return;
  935. }
  936. if((!power_attack) && (parseInt(exp_to_levelup) <= 6) && levelup_halt){
  937. logmsg('Could level up on next Attack, Stopping..','status');
  938. stop();
  939. return;
  940. }
  941. var user_ice_count = parseInt(document.getElementById('ice_count').value);
  942. if((iced_count >= user_ice_count) && (user_ice_count != 0)){
  943. logmsg('Reached specified iced count, Stopping..','status');
  944. stop();
  945. return;
  946. }
  947. try{
  948. logmsg('Attacking '+fightlist_names[i]+' Level - '+fightlist_levels[i],'status');
  949. // alert(fightlist_attack[i].replace(/&tmp=([^&]+)/.exec(fightlist_attack[i])[0],''));
  950. // timeout_timer = setTimeout(function(){
  951. // if(req){
  952. // req.abort();
  953. // }
  954. // attack();
  955. // },30000);
  956. power_attack_enable = document.getElementById('power_attack').checked;
  957. if(power_attack){
  958. fightlist_attack[i] = fightlist_attack[i].replace(/xw_action=attack&/,'xw_action=power_attack&');
  959. fightlist_attack[i] = fightlist_attack[i].replace(/&origin=fight_page&tab=0/,'');
  960. var temp_var = /&tmp=(.+?)&/.exec(fightlist_attack[i])[1];
  961. fightlist_attack[i] = fightlist_attack[i].replace(temp_var,temp_variable);
  962. }
  963. var link="http://facebook.mafiawars.com/mwfb/"+fightlist_attack[i]+"&xw_client_id=8";
  964. }
  965. catch(err){alert(err);}
  966. var params = { 'ajax': 1,
  967. 'liteload': 1,
  968. 'sf_xw_user_id': userid,
  969. 'sf_xw_sig': local_xw_sig
  970. };
  971. req = $.ajax({type: "POST",url: link, timeout: 30000, data: params,
  972. success: function (msg){
  973. //clearTimeout(timeout_timer);
  974. fightlist_match=0;
  975. process_attack(msg);
  976. },
  977. error: function(req,status,err){
  978. logmsg('Request timed out, Retrying attack..','status');
  979. setTimeout(attack,2000);
  980. }
  981. });
  982. // }
  983. // catch(err){alert(err);}
  984. }
  985. function process_attack(attack_results){
  986. var temp;
  987. var logtext;
  988. logtext = '';
  989. wait1 = parseInt(document.getElementById('delay1').value);
  990. wait2 = parseInt(document.getElementById('delay2').value);
  991. var higher = (wait2 > wait1 ? wait2 : wait1);
  992. var lower = (wait2 > wait1 ? wait1 : wait2);
  993. var random_delay = Math.floor((higher-(lower-1))*Math.random()) + lower;
  994. random_delay = (random_delay < 0)? 0 : random_delay;
  995. Trace('In process attack function');
  996. if(/This player is currently part of your mafia/.test(attack_results)){
  997. logmsg('Player part of your mafia. Fetching next target in '+random_delay+' seconds..','attack_log');
  998. next();
  999. return;
  1000. }
  1001. else if(!((/You won/i.test(attack_results)) || (/You lost/i.test(attack_results)))){
  1002. logmsg('Possible session timeout, Reloading..','status');
  1003. attack_or_not = true;
  1004. loadfightpage();
  1005. return;
  1006. }
  1007. actual_count++;
  1008. document.getElementById('fights').innerHTML = actual_count;
  1009. // document.getElementById('inner_page').innerHTML = attack_results;
  1010. killed = false;
  1011. iced = false;
  1012. // health_lost = /fightres_health">took ([0-9]+)/.exec(attack_results)[1];
  1013. document.getElementById('user_health').innerHTML = /user_fields\['user_health'\] = parseInt\("([0-9]+)/.exec(attack_results)[1];
  1014. document.getElementById('user_stamina').innerHTML = /user_fields\['user_stamina'\] = parseInt\("([0-9]+)/.exec(attack_results)[1];
  1015. // document.getElementById('user_experience').innerHTML = /user_fields\['user_experience'\] = parseInt\("([0-9]+)/.exec(attack_results)[1];
  1016. exp_to_levelup = parseInt(/user_fields\['exp_for_next_level'\] = parseInt\("([0-9]+)/.exec(attack_results)[1]) - parseInt(/user_fields\['user_experience'\] = parseInt\("([0-9]+)/.exec(attack_results)[1]);
  1017. try{document.getElementById('exp_to_next_level').innerHTML = exp_to_levelup;}
  1018. catch(err){document.getElementById('user_xp_to_next_level').innerHTML = exp_to_levelup;}
  1019. try{document.getElementById('user_experience').innerHTML = /user_fields\['user_experience'\] = parseInt\("([0-9]+)/.exec(attack_results)[1];}
  1020. catch(err){}
  1021. exp_ratio_reqd = exp_to_levelup/parseInt(document.getElementById('user_stamina').innerHTML);
  1022. document.getElementById('exp_reqd').innerHTML = exp_to_levelup;
  1023. document.getElementById('exp_ratio_reqd').innerHTML = exp_ratio_reqd.toFixed(2);
  1024. mafia_attack = parseInt((/title="Mafia Attack Strength".+?> (.+?)<\/div>/.exec(attack_results)[1]).replace(/,/g,''));
  1025. if(initial_mafia_attack == 0){
  1026. initial_mafia_attack = mafia_attack;
  1027. }
  1028. mafia_defense = parseInt((/title="Mafia Defense Strength".+?> (.+?)<\/div>/.exec(attack_results)[1]).replace(/,/g,''));
  1029. if(initial_mafia_defense == 0){
  1030. initial_mafia_defense = mafia_defense;
  1031. }
  1032. document.getElementById('mafia_attack').innerHTML = format_cash(mafia_attack);
  1033. document.getElementById('mafia_defense').innerHTML = format_cash(mafia_defense);
  1034. document.getElementById('attack_diff').innerHTML = (mafia_attack >= initial_mafia_attack)?'<span class="good">+'+(mafia_attack - initial_mafia_attack)+'</span>':'<span class="bad">-'+(initial_mafia_attack - mafia_attack)+'</span>';
  1035. document.getElementById('defense_diff').innerHTML = (mafia_defense >= initial_mafia_defense)?'<span class="good">+'+(mafia_defense - initial_mafia_defense)+'</span>':'<span class="bad">-'+(initial_mafia_defense - mafia_defense)+'</span>';
  1036. if(vic_pts == 0){
  1037. initial_vic_pts = /<div class="fightmastery_tokens">[^\d]+(\d+)/.exec(attack_results)[1];
  1038. }
  1039. vic_pts = /<div class="fightmastery_tokens">[^\d]+(\d+)/.exec(attack_results)[1];
  1040. document.getElementById('Victorycoins').innerHTML = vic_pts + '[<span class="good">'+(vic_pts-initial_vic_pts)+'</span>]';
  1041. try{
  1042. temp='';
  1043. loot_log = [];
  1044. if(/(found|gained|earned) (some|an|a|A) (.+?)(See|while|\.|)/.test(attack_results)){
  1045. temp_loot = attack_results.match(/(<div class="fightres_bonus_message".+?<img src="(.+?)".+?|)(found|gained|earned) (some|an|a|A) (.+?)(See|while|\.)/g);
  1046. for(z=0;z<temp_loot.length;z++){
  1047. temp = /(found|gained|earned) (some|an|a|A) (.+?)(See|while|\.)/.exec(temp_loot[z]);
  1048. loot_img = /<div class="fightres_bonus_message".+?<img src="(.+?)"/.exec(temp_loot[z]);
  1049. loot_img = loot_img ? loot_img[1]:"";
  1050. temp = temp[3].replace(/!/g,'');
  1051. temp = temp.replace(/<br\/>/g,'');
  1052. Add_to_loot(temp,1,loot_img);
  1053. temp = temp.replace(/\(.+?\)/g,'');
  1054. if(loot_img!=""){
  1055. loot_log[loot_log.length] = '<img src="'+loot_img+'" style="width: 20px; height: 20px;"></img> '+temp;
  1056. }
  1057. else{
  1058. loot_log[loot_log.length] = ' '+temp;
  1059. }
  1060. }
  1061. }
  1062. }
  1063. catch(err){alert('Error ! '+err);alert('temp_loot length = '+temp_loot.length);alert('Error occured, temp_loot = '+temp_loot);return;}
  1064. try{
  1065. if(/secret stash/.test(attack_results)){
  1066. var stash_script = /function continuation_popFightLootFeed(.+?)<\/script>/.exec(attack_results)[0].replace(/<\/script>/,'');
  1067. stash_script = stash_script.replace(/"/g,'\"');
  1068. stash_posts[stash_posts.length] = stash_script;
  1069. var stash_owner = /<a(.+?)<\/a> found the location of the secret stash/.exec(attack_results)[1];
  1070. document.getElementById('stash_posts_log').innerHTML += '<a'+stash_owner+'<\/a> - <a href="#" id="stash_post'+(stash_posts.length-1)+'" onclick="return false;">Stash #'+stash_posts.length+'</a><br>';
  1071. // document.getElementById('stash_post'+(stash_posts.length-1)).onclick = new Function(this.id,publish_stash);
  1072. for(l=0;l<stash_posts.length;l++){
  1073. document.getElementById('stash_post'+l).onclick = publish_stash;
  1074. }
  1075. }
  1076. }
  1077. catch(err){alert(err);}
  1078. try{
  1079. if(/Share Coins/.test(attack_results)){
  1080. var coins_script = /function continuation_postW2Wback(.+?)<\/script>/.exec(attack_results)[0].replace(/<\/script>/,'');
  1081. coins_script = coins_script.replace(/"/g,'\"');
  1082. coin_posts[coin_posts.length] = coins_script;
  1083. var coin_post_owner = /<a(.+?)<\/a><\/span> <span>earned you \d extra Victory Coins/.exec(attack_results)[1];
  1084. coin_owner_id[coin_owner_id.length] = /postW2Wback\('(.+?)'\)/.exec(attack_results)[1];
  1085. document.getElementById('coin_posts_log').innerHTML += '<a'+coin_post_owner+'<\/a> - <a href="#" id="coin_post'+(coin_posts.length-1)+'" onclick="return false;">VCoin Post #'+coin_posts.length+'</a><br>';
  1086. // document.getElementById('stash_post'+(stash_posts.length-1)).onclick = new Function(this.id,publish_stash);
  1087. for(l=0;l<coin_posts.length;l++){
  1088. document.getElementById('coin_post'+l).onclick = publish_coins;
  1089. }
  1090. }
  1091. }
  1092. catch(err){}
  1093. try{
  1094. if(/found (\d) (.+?)See them/.test(attack_results)){
  1095. temp='';
  1096. temp = /found (\d) (.+?)See them/.exec(attack_results);
  1097. temp[2] = temp[2].replace(/!/,'');
  1098. temp[2] = temp[2].replace(/<br\/>/g,'');
  1099. Add_to_loot(temp[2],parseInt(temp[1]),'');
  1100. loot_log[loot_log.length] = temp[1] + ' ' + temp[2];
  1101. }
  1102. }
  1103. catch(err){$('#inner_page').html(attack_results);alert('Error ! '+err);return;}
  1104. try{
  1105. document.getElementById('loot_percent').innerHTML = ((total_loot/(win+loss)) * 100).toFixed(1);
  1106. }
  1107. catch(err){}
  1108. if(/killed your opponent/.test(attack_results)){
  1109. killed=true;
  1110. kills++;
  1111. killed_count = /You killed your opponent, bringing your total body count to (\d+?)!/.exec(attack_results)[1];
  1112. document.getElementById('kills_log').innerHTML = killed_count +'[<span class="good">'+kills+'</span>]';
  1113. }
  1114. if(/iced_pop_text/.test(attack_results)){
  1115. iced=true;
  1116. ices++;
  1117. iced_count = /<div class=\\"iced_pop_body_count_number\\">(.+?)<\/div>/.exec(attack_results)[1].replace(/,/g,'');
  1118. document.getElementById('iced_log').innerHTML = iced_count +'[<span class="good">'+ices+'</span>]';
  1119. var script = /function continuation_postFeedAndSendFightBrag(.+?)<\/script>/.exec(attack_results)[0].replace(/<\/script>/,'');
  1120. script = script.replace(/"/g,'\"');
  1121. if(iced_posts.length <= 0){
  1122. iced_posts[iced_posts.length] = new Array(iced_count,script);
  1123. }
  1124. else{
  1125. iced_posts[iced_posts.length] = [];
  1126. iced_posts[iced_posts.length-1][1] = script;
  1127. iced_posts[iced_posts.length-1][0] = iced_count;
  1128. }
  1129. document.getElementById('ice_posts_log').innerHTML += iced_posts[iced_posts.length-1][0]+' - '+fightlist_names[i]+' - <a href="#" id="ice_post'+(iced_posts.length-1)+'"return false;">Post</a><br>';
  1130. // document.getElementById('ice_post'+(iced_posts.length-1)).onclick = new Function(this.id,publish_ice);
  1131. for(l=0;l<iced_posts.length;l++){
  1132. document.getElementById('ice_post'+l).onclick = publish_ice;
  1133. }
  1134. }
  1135. var check_city = parseInt(/&xw_city=(\d+)&tmp/.exec(attack_results)[1]);
  1136. if(check_city != fight_city){
  1137. logmsg('Invalid city change detected, Travelling to fight city...','status');
  1138. logmsg('Invalid city change detected, Travelling to fight city...','attack_log');
  1139. var params = { 'ajax': 1,
  1140. 'liteload': 1,
  1141. 'sf_xw_user_id': userid,
  1142. 'sf_xw_sig': local_xw_sig
  1143. };
  1144. $.ajax({type: "POST", data: params,
  1145. url: "http://facebook.mafiawars.com/mwfb/remote/html_server.php?xw_controller=travel&xw_action=travel&xw_city="+check_city+"&cb="+cb+"&destination="+fight_city+"&from=fight&nextParams=&xw_client_id=8",
  1146. success: function (msg){
  1147. attack_or_not=true;
  1148. loadfightpage();
  1149. return;
  1150. }
  1151. });
  1152. return;
  1153. }
  1154. try{
  1155. if(fight_city == 4){
  1156. var faction_level = attack_results.match(/zy_progress_bar_faction_text">(.+) \/ 1500/g);
  1157. document.getElementById('Yakuza_points').innerHTML = Yakuza = parseInt(/zy_progress_bar_faction_text">(.+) \/ 1500/.exec(faction_level[0])[1]);
  1158. document.getElementById('Triad_points').innerHTML = Triad = parseInt(/zy_progress_bar_faction_text">(.+) \/ 1500/.exec(faction_level[1])[1]);
  1159. }
  1160. }
  1161. catch(err){}
  1162. switch(parseInt(fight_city)){
  1163. case 1:
  1164. document.getElementById('user_cash_nyc').innerHTML = /user_fields\['user_cash_nyc'\] = "([^"]+)/.exec(attack_results)[1];
  1165. cash_in_hand = document.getElementById('user_cash_nyc').innerHTML.replace(/,/g,'').replace(/\$/g,'');
  1166. if((parseInt(cash_in_hand) > parseInt(document.getElementById('bank_limit').value)) && (document.forms.mwpusher.bank_enable.checked)){
  1167. logmsg('Banking <span class="good">'+document.getElementById('user_cash_nyc').innerHTML+'</span>','attack_log');
  1168. bank(cash_in_hand,'nyc');
  1169. }
  1170. break;
  1171. case 2:
  1172. document.getElementById('user_cash_cuba').innerHTML = /user_fields\['user_cash_cuba'\] = "([^"]+)/.exec(attack_results)[1];
  1173. cash_in_hand = document.getElementById('user_cash_cuba').innerHTML.replace(/,/g,'').replace(/C\$/g,'');
  1174. if((parseInt(cash_in_hand) > parseInt(document.getElementById('bank_limit').value)) && (document.forms.mwpusher.bank_enable.checked)){
  1175. logmsg('Banking <span class="good">'+document.getElementById('user_cash_cuba').innerHTML+'</span>','attack_log');
  1176. bank(cash_in_hand,'cuba');
  1177. }
  1178. break;
  1179. case 3:
  1180. document.getElementById('user_cash_moscow').innerHTML = /user_fields\['user_cash_moscow'\] = "([^"]+)/.exec(attack_results)[1];
  1181. cash_in_hand = document.getElementById('user_cash_moscow').innerHTML.replace(/,/g,'').replace(/R\$/g,'');
  1182. if((parseInt(cash_in_hand) > parseInt(document.getElementById('bank_limit').value)) && (document.forms.mwpusher.bank_enable.checked)){
  1183. logmsg('Banking <span class="good">'+document.getElementById('user_cash_moscow').innerHTML+'</span>','attack_log');
  1184. bank(cash_in_hand,'moscow');
  1185. }
  1186. break;
  1187. case 4:
  1188. document.getElementById('user_cash_bangkok').innerHTML = /user_fields\['user_cash_bangkok'\] = "([^"]+)/.exec(attack_results)[1];
  1189. cash_in_hand = document.getElementById('user_cash_bangkok').innerHTML.replace(/,/g,'').replace(/B\$/g,'');
  1190. if((parseInt(cash_in_hand) > parseInt(document.getElementById('bank_limit').value)) && (document.forms.mwpusher.bank_enable.checked)){
  1191. logmsg('Banking <span class="good">'+document.getElementById('user_cash_bangkok').innerHTML+'</span>','attack_log');
  1192. bank(cash_in_hand,'bangkok');
  1193. }
  1194. break;
  1195. case 5:
  1196. document.getElementById('user_cash_vegas').innerHTML = /user_fields\['user_cash_vegas'\] = "([^"]+)/.exec(attack_results)[1];
  1197. cash_in_hand = document.getElementById('user_cash_vegas').innerHTML.replace(/,/g,'').replace(/V\$/g,'');
  1198. if((parseInt(cash_in_hand) > parseInt(document.getElementById('bank_limit').value)) && (document.forms.mwpusher.bank_enable.checked)){
  1199. logmsg('Banking <span class="good">'+document.getElementById('user_cash_vegas').innerHTML+'</span>','attack_log');
  1200. bank(cash_in_hand,'vegas');
  1201. }
  1202. break;
  1203. case 6:
  1204. document.getElementById('user_cash_italy').innerHTML = /user_fields\['user_cash_italy'\] = "([^"]+)/.exec(attack_results)[1];
  1205. cash_in_hand = document.getElementById('user_cash_italy').innerHTML.replace(/,/g,'').replace(/L\$/g,'');
  1206. if((parseInt(cash_in_hand) > parseInt(document.getElementById('bank_limit').value)) && (document.forms.something.bank_enable.checked)){
  1207. logmsg('Banking <span class="good">'+document.getElementById('user_cash_italy').innerHTML+'</span>','attack_log');
  1208. bank(cash_in_hand,'italy');
  1209. }
  1210. break;
  1211. }
  1212. if(/You won/i.test(attack_results)){
  1213. if(/<span class="good">Win: (\d)<\/span>/.test(attack_results)){
  1214. win += parseInt(/<span class="good">Win: (\d)<\/span>/.exec(attack_results)[1]);
  1215. }
  1216. else{
  1217. win++;
  1218. }
  1219. if(/<span class="bad">Loss: (\d)<\/span>/.test(attack_results)){
  1220. loss += parseInt(/<span class="bad">Loss: (\d)<\/span>/.exec(attack_results)[1]);
  1221. }
  1222. if(/Attack Again/.test(attack_results)){
  1223. if(/Attack again 5 times/.test(attack_results)){
  1224. if(power_attack_enable){
  1225. power_attack = true;
  1226. }
  1227. else{
  1228. power_attack = false;
  1229. }
  1230. temp_variable = /&xw_action=power_attack&xw_city=.+?&tmp=(.+?)&/.exec(attack_results)[1];
  1231. }
  1232. logtext = '<img src="http://codeoutpost.com/Scripts/attack.png" alt="alive"></img> ';
  1233. }
  1234. document.getElementById('wins').innerHTML = win;
  1235. logtext += '<span class="good">Attacked '+fightlist_names[i]+' and won !</span> ';
  1236. // if(/rallied/.test(attack_results)){
  1237. // exp_gained += 2 * parseInt(/fightres_experience good">\n(.*)\+(\d*) Experience/.exec(attack_results)[2]);
  1238. // logtext += 'Exp gained - <span class="good">' + (2 * parseInt(/fightres_experience good">\n(.*)\+(\d*) Experience/.exec(attack_results)[2]))+'</span>';
  1239. // }
  1240. // else{
  1241. exp_gained += parseInt(/\+(\d*) Experience/.exec(attack_results)[1]);
  1242. logtext += '<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_experience_16x16_01.gif" alt="Exp"> <span class="good">' + parseInt(/\+(\d*) Experience/.exec(attack_results)[1])+'</span>';
  1243. // }
  1244. exp_ratio = exp_gained/(win+loss);
  1245. document.getElementById('exp_ratio').innerHTML = exp_ratio.toFixed(2);
  1246. if(/Fan Bonus/.test(attack_results)){
  1247. if(/rallied/.test(attack_results)){
  1248. exp_gained += 2 * parseInt(/(\d*) Fan Bonus/.exec(attack_results)[1]);
  1249. logtext += ' Fan Bonus - <span class="good">' + (2 * parseInt(/(\d*) Fan Bonus/.exec(attack_results)[1]))+'</span>';
  1250. }
  1251. else{
  1252. exp_gained += parseInt(/(\d*) Fan Bonus/.exec(attack_results)[1]);
  1253. logtext += ' Fan Bonus - <span class="good">' + parseInt(/(\d*) Fan Bonus/.exec(attack_results)[1])+'</span>';
  1254. }
  1255. }
  1256. // alert(/(sexy_cuba_cash|sexy_bangkok_cash|sexy_moscow_cash|sexy_new_york_cash|sexy_vegas_cash) good"\>(\n|\f|\r)([^<]+)/.exec(attack_results)[0]);
  1257. cash = /(sexy_cuba_cash|sexy_bangkok_cash|sexy_moscow_cash|sexy_vegas_cash|sexy_italy_cash|sexy_new_york_cash) good"\>(\n|\f|\r)([^<]+)/.exec(attack_results)[3];
  1258. // cash = cash.replace(/\n/g,'');
  1259. logtext += ' <img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cash_16x16_01.gif" alt="cash"></img> <span class="good">'+cash+'</span>';
  1260. if(iced == true){
  1261. logtext += ' <img src="http://codeoutpost.com/Scripts/Ice.png" alt="Iced"></img>';
  1262. }
  1263. if(killed == true){
  1264. logtext += ' <img src="http://codeoutpost.com/Scripts/kill.png" alt="Kill"></img>';
  1265. }
  1266. try{
  1267. logtext += ' <img src="http://mwfb.static.zynga.com/mwfb/graphics/victory_icon.gif"></img>+<span class="good">'+ (/\+(\d+).*Victory Coins/.exec(attack_results)[1])+'</span> ';
  1268. }
  1269. catch(err){}
  1270. if(loot_log.length >= 1){
  1271. logtext += ' '+loot_log;
  1272. }
  1273. logmsg(logtext,'attack_log');
  1274. document.getElementById('exp_gained').innerHTML = exp_gained;
  1275. switch(true){
  1276. case (/sexy_cuba_cash good"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1277. process_cash(2,(/sexy_cuba_cash good"\>[^\$]+\$([^<]+)/.exec(attack_results)[1].replace(/,/g,'')));
  1278. cash_city = 2;
  1279. break;
  1280. case (/sexy_moscow_cash good"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1281. process_cash(3,(/sexy_moscow_cash good"\>[^\$]+\$([^<]+)/.exec(attack_results)[1].replace(/,/g,'')));
  1282. cash_city = 3;
  1283. break;
  1284. case (/sexy_bangkok_cash good"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1285. process_cash(4,(/sexy_bangkok_cash good"\>[^\$]+\$([^<]+)/.exec(attack_results)[1].replace(/,/g,'')));
  1286. cash_city = 4;
  1287. break;
  1288. case (/sexy_vegas_cash good"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1289. process_cash(5,(/sexy_vegas_cash good"\>[^\$]+\$([^<]+)/.exec(attack_results)[1].replace(/,/g,'')));
  1290. cash_city = 5;
  1291. break;
  1292. case (/sexy_italy_cash good"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1293. process_cash(6,(/sexy_italy_cash good"\>[^\$]+\$([^<]+)/.exec(attack_results)[1].replace(/,/g,'')));
  1294. cash_city = 6;
  1295. break;
  1296. case (/sexy_new_york_cash good"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1297. process_cash(1,(/sexy_new_york_cash good"\>[^\$]+\$([^<]+)/.exec(attack_results)[1].replace(/,/g,'')));
  1298. cash_city = 1;
  1299. break;
  1300. }
  1301. if(parseInt(/(sexy_cuba_cash|sexy_bangkok_cash|sexy_moscow_cash|sexy_vegas_cash|sexy_italy_cash|sexy_new_york_cash) good"\>[^\$]+\$([^<]+)/.exec(attack_results)[2].replace(/,/g,'')) < parseInt(cash_limit)){
  1302. logmsg('Below cash limit, Fetching next target in '+random_delay+' seconds..','attack_log');
  1303. next();
  1304. return;
  1305. }
  1306. if((cash_city != fight_city) && document.forms.mwpusher.cash_city.checked){
  1307. logmsg('Cash not from same city as fight city. Fetching next target in '+random_delay+' seconds..','attack_log');
  1308. next();
  1309. return;
  1310. }
  1311. attack_count++;
  1312. if((attack_count >= parseInt(document.forms.mwpusher.attack_limit.value)) && document.forms.mwpusher.attack_limit_check.checked){
  1313. logmsg('Done with '+fightlist_names[i]+' Fetching next target in '+random_delay+' seconds..','attack_log');
  1314. next();
  1315. return;
  1316. }
  1317. if(/Attack Again/.test(attack_results)){
  1318. setTimeout(attack,random_delay*1000);
  1319. }
  1320. else{
  1321. logmsg('Done with '+fightlist_names[i]+' Fetching next target in '+random_delay+' seconds..','attack_log');
  1322. next();
  1323. }
  1324. return;
  1325. }
  1326. else{
  1327. if(/You lost/i.test(attack_results)){
  1328. logtext = '';
  1329. loss++;
  1330. document.getElementById('losses').innerHTML = loss;
  1331. exp_ratio = exp_gained/(win+loss);
  1332. document.getElementById('exp_ratio').innerHTML = exp_ratio.toFixed(2);
  1333. // document.getElementById('logger').innerHTML = 'You Lost ! Cash Lost - '+cash;
  1334. cash = /(sexy_cuba_cash|sexy_bangkok_cash|sexy_moscow_cash|sexy_vegas_cash|sexy_italy_cash|sexy_new_york_cash) (bad|good)"\>(\n|\f|\r)([^<]+)/.exec(attack_results)[4];
  1335. // document.getElementById('popup_fodder').innerHTML = attack_results;
  1336. // return;
  1337. try{
  1338. switch(true){
  1339. case (/sexy_cuba_cash (bad|good)"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1340. process_cash(2,-(/sexy_cuba_cash (bad|good)"\>[^\$]+\$([^<]+)/.exec(attack_results)[2].replace(/,/g,'')));
  1341. break;
  1342. case (/sexy_moscow_cash (bad|good)"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1343. process_cash(3,-(/sexy_moscow_cash (bad|good)"\>[^\$]+\$([^<]+)/.exec(attack_results)[2].replace(/,/g,'')));
  1344. break;
  1345. case (/sexy_bangkok_cash (bad|good)"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1346. process_cash(4,-(/sexy_bangkok_cash (bad|good)"\>[^\$]+\$([^<]+)/.exec(attack_results)[2].replace(/,/g,'')));
  1347. break;
  1348. case (/sexy_vegas_cash (bad|good)"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1349. process_cash(5,-(/sexy_vegas_cash (bad|good)"\>[^\$]+\$([^<]+)/.exec(attack_results)[2].replace(/,/g,'')));
  1350. break;
  1351. case (/sexy_italy_cash (bad|good)"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1352. process_cash(6,-(/sexy_italy_cash (bad|good)"\>[^\$]+\$([^<]+)/.exec(attack_results)[2].replace(/,/g,'')));
  1353. break;
  1354. case (/sexy_new_york_cash (bad|good)"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1355. process_cash(1,-(/sexy_new_york_cash (bad|good)"\>[^\$]+\$([^<]+)/.exec(attack_results)[2].replace(/,/g,'')));
  1356. // alert(-(/fightres_cash sexy_cash bad">\n(.*)-(.*)\$([^<]+)/.exec(attack_results)[1].replace(/,/g,'')));
  1357. break;
  1358. }
  1359. }
  1360. catch(err){}
  1361. if(/Attack Again/.test(attack_results)){
  1362. logtext = '<img src="http://codeoutpost.com/Scripts/attack.png" alt="alive"></img> ';
  1363. }
  1364. logtext += '<span class="bad">You Lost !</span> Cash Lost <span class="bad">'+cash+'</span>';
  1365. if(iced == true){
  1366. logtext += ' <img src="http://codeoutpost.com/Scripts/Ice.png" alt="Iced"></img>';
  1367. }
  1368. if(killed == true){
  1369. logtext += ' <img src="http://codeoutpost.com/Scripts/kill.png" alt="Kill"></img>';
  1370. }
  1371. logmsg(logtext,'attack_log');
  1372. }
  1373. strong_list[strong_list.length] = fightlist_char_names[i];
  1374. logmsg(fightlist_names[i]+' too strong, Fetching next target in '+random_delay+' seconds..','attack_log');
  1375. var check_city = parseInt(/&xw_city=(\d+)&tmp/.exec(attack_results)[1]);
  1376. if(check_city != fight_city){
  1377. logmsg('Invalid city change detected, Travelling to fight city...','status');
  1378. logmsg('Invalid city change detected, Travelling to fight city...','attack_log');
  1379. var params = { 'ajax': 1,
  1380. 'liteload': 1,
  1381. 'sf_xw_user_id': userid,
  1382. 'sf_xw_sig': local_xw_sig
  1383. };
  1384. $.ajax({type: "POST", data: params,
  1385. url: "http://facebook.mafiawars.com/mwfb/remote/html_server.php?xw_controller=travel&xw_action=travel&xw_city="+check_city+"&cb="+cb+"&destination="+fight_city+"&from=fight&nextParams=&xw_client_id=8",
  1386. success: function (msg){
  1387. attack_or_not=true;
  1388. loadfightpage();
  1389. return;
  1390. }
  1391. });
  1392. return;
  1393. }
  1394. next();
  1395. }
  1396. }
  1397. function process_user_attack(attack_results){
  1398. var temp;
  1399. var logtext;
  1400. logtext = '';
  1401. wait1 = parseInt(document.getElementById('delay1').value);
  1402. wait2 = parseInt(document.getElementById('delay2').value);
  1403. var higher = (wait2 > wait1 ? wait2 : wait1);
  1404. var lower = (wait2 > wait1 ? wait1 : wait2);
  1405. var random_delay = Math.floor((higher-(lower-1))*Math.random()) + lower;
  1406. random_delay = (random_delay < 0)? 0 : random_delay;
  1407. Trace('In process user attack function');
  1408. if(/session has timed out/.test(attack_results)){
  1409. logmsg('Session timeout, fetching temp key..','attack_log');
  1410. user_urls[j]='';
  1411. setTimeout(attack_user,random_delay*1000);
  1412. return;
  1413. }
  1414. if(/This player is currently part of your mafia/.test(attack_results)){
  1415. logmsg('Player part of your mafia. Fetching next target in '+random_delay+' seconds..','attack_log');
  1416. j++;
  1417. if(j >= user_list.length){
  1418. if(document.forms.something.UserSkip.checked){
  1419. logmsg('All users Iced/Killed. Stopping..','status');
  1420. document.getElementById('pause').style.display = 'none';
  1421. document.getElementById('begin').style.display = 'inline';
  1422. return;
  1423. }
  1424. logmsg('Reached last member, reloading..','attack_log');
  1425. j=0;
  1426. }
  1427. setTimeout(attack_user,random_delay*1000);
  1428. return;
  1429. }
  1430. actual_count++;
  1431. killed = false;
  1432. iced = false;
  1433. // health_lost = /fightres_health">took ([0-9]+)/.exec(attack_results)[1];
  1434. document.getElementById('user_health').innerHTML = /user_fields\['user_health'\] = parseInt\("([0-9]+)/.exec(attack_results)[1];
  1435. document.getElementById('user_stamina').innerHTML = /user_fields\['user_stamina'\] = parseInt\("([0-9]+)/.exec(attack_results)[1];
  1436. // document.getElementById('user_experience').innerHTML = /user_fields\['user_experience'\] = parseInt\("([0-9]+)/.exec(attack_results)[1];
  1437. exp_to_levelup = parseInt(/user_fields\['exp_for_next_level'\] = parseInt\("([0-9]+)/.exec(attack_results)[1]) - parseInt(/user_fields\['user_experience'\] = parseInt\("([0-9]+)/.exec(attack_results)[1]);
  1438. try{document.getElementById('exp_to_next_level').innerHTML = exp_to_levelup;}
  1439. catch(err){document.getElementById('user_xp_to_next_level').innerHTML = exp_to_levelup;}
  1440. try{document.getElementById('user_experience').innerHTML = /user_fields\['user_experience'\] = parseInt\("([0-9]+)/.exec(attack_results)[1];}
  1441. catch(err){}
  1442. exp_ratio_reqd = exp_to_levelup/parseInt(document.getElementById('user_stamina').innerHTML);
  1443. document.getElementById('exp_reqd').innerHTML = exp_to_levelup;
  1444. document.getElementById('exp_ratio_reqd').innerHTML = exp_ratio_reqd.toFixed(2);
  1445. mafia_attack = parseInt((/title="Mafia Attack Strength".+?> (.+?)<\/div>/.exec(attack_results)[1]).replace(/,/g,''));
  1446. if(initial_mafia_attack == 0){
  1447. initial_mafia_attack = mafia_attack;
  1448. }
  1449. mafia_defense = parseInt((/title="Mafia Defense Strength".+?> (.+?)<\/div>/.exec(attack_results)[1]).replace(/,/g,''));
  1450. if(initial_mafia_defense == 0){
  1451. initial_mafia_defense = mafia_defense;
  1452. }
  1453. document.getElementById('mafia_attack').innerHTML = format_cash(mafia_attack);
  1454. document.getElementById('mafia_defense').innerHTML = format_cash(mafia_defense);
  1455. document.getElementById('attack_diff').innerHTML = (mafia_attack >= initial_mafia_attack)?'<span class="good">+'+(mafia_attack - initial_mafia_attack)+'</span>':'<span class="bad">-'+(initial_mafia_attack - mafia_attack)+'</span>';
  1456. document.getElementById('defense_diff').innerHTML = (mafia_defense >= initial_mafia_defense)?'<span class="good">+'+(mafia_defense - initial_mafia_defense)+'</span>':'<span class="bad">-'+(initial_mafia_defense - mafia_defense)+'</span>';
  1457. if(vic_pts == 0){
  1458. initial_vic_pts = /<div class="fightmastery_tokens">[^\d]+(\d+)/.exec(attack_results)[1];
  1459. }
  1460. vic_pts = /<div class="fightmastery_tokens">[^\d]+(\d+)/.exec(attack_results)[1];
  1461. document.getElementById('Victorycoins').innerHTML = vic_pts + '[<span class="good">'+(vic_pts-initial_vic_pts)+'</span>]';
  1462. try{
  1463. temp='';
  1464. loot_log = [];
  1465. if(/(found|gained|earned) (some|an|a|A) (.+?)(See|while|\.|)/.test(attack_results)){
  1466. temp_loot = attack_results.match(/(<div class="fightres_bonus_message".+?<img src="(.+?)".+?|)(found|gained|earned) (some|an|a|A) (.+?)(See|while|\.)/g);
  1467. for(z=0;z<temp_loot.length;z++){
  1468. temp = /(found|gained|earned) (some|an|a|A) (.+?)(See|while|\.)/.exec(temp_loot[z]);
  1469. loot_img = /<div class="fightres_bonus_message".+?<img src="(.+?)"/.exec(temp_loot[z]);
  1470. loot_img = loot_img ? loot_img[1]:"";
  1471. temp = temp[3].replace(/!/g,'');
  1472. temp = temp.replace(/<br\/>/g,'');
  1473. Add_to_loot(temp,1,loot_img);
  1474. temp = temp.replace(/\(.+?\)/g,'');
  1475. if(loot_img!=""){
  1476. loot_log[loot_log.length] = '<img src="'+loot_img+'" style="width: 20px; height: 20px;"></img> '+temp;
  1477. }
  1478. else{
  1479. loot_log[loot_log.length] = ' '+temp;
  1480. }
  1481. }
  1482. }
  1483. }
  1484. catch(err){alert('Error ! '+err);alert('temp_loot length = '+temp_loot.length);alert('Error occured, temp_loot = '+temp_loot);return;}
  1485. try{
  1486. if(/secret stash/.test(attack_results)){
  1487. var stash_script = /function continuation_popFightLootFeed(.+?)<\/script>/.exec(attack_results)[0].replace(/<\/script>/,'');
  1488. var stash_owner = /<a(.+?)<\/a> found the location of the secret stash/.exec(attack_results)[1];
  1489. stash_script = stash_script.replace(/"/g,'\"');
  1490. stash_posts[stash_posts.length] = stash_script;
  1491. document.getElementById('stash_posts_log').innerHTML += '<a'+stash_owner+'<\/a> - <a href="#" id="stash_post'+(stash_posts.length-1)+'" onclick="return false;">Stash #'+stash_posts.length+'</a><br>';
  1492. // document.getElementById('stash_post'+(stash_posts.length-1)).onclick = new Function(this.id,publish_stash);
  1493. for(l=0;l<stash_posts.length;l++){
  1494. document.getElementById('stash_post'+l).onclick = publish_stash;
  1495. }
  1496. }
  1497. }
  1498. catch(err){}
  1499. try{
  1500. if(/found (\d) (.+?)See them/.test(attack_results)){
  1501. temp='';
  1502. temp = /found (\d) (.+?)See them/.exec(attack_results);
  1503. temp[2] = temp[2].replace(/!/,'');
  1504. temp[2] = temp[2].replace(/<br\/>/g,'');
  1505. Add_to_loot(temp[2],parseInt(temp[1]),'');
  1506. temp = temp[1] + ' ' + temp[2];
  1507. }
  1508. }
  1509. catch(err){alert('Error ! '+err);return;}
  1510. try{
  1511. document.getElementById('loot_percent').innerHTML = ((total_loot/(win+loss)) * 100).toFixed(1);
  1512. }
  1513. catch(err){}
  1514. if(/killed your opponent/.test(attack_results)){
  1515. killed=true;
  1516. kills++;
  1517. killed_count = /You killed your opponent, bringing your total body count to (\d+?)!/.exec(attack_results)[1];
  1518. document.getElementById('kills_log').innerHTML = killed_count +'[<span class="good">'+kills+'</span>]';
  1519. }
  1520. if(/iced_pop_text/.test(attack_results)){
  1521. iced=true;
  1522. ices++;
  1523. iced_count = /<div class=\\"iced_pop_body_count_number\\">(.+?)<\/div>/.exec(attack_results)[1].replace(/,/g,'');
  1524. document.getElementById('iced_log').innerHTML = iced_count +'[<span class="good">'+ices+'</span>]';
  1525. var script = /function continuation_postFeedAndSendFightBrag(.+?)<\/script>/.exec(attack_results)[0].replace(/<\/script>/,'');
  1526. script = script.replace(/"/g,'\"');
  1527. if(iced_posts.length <= 0){
  1528. iced_posts[iced_posts.length] = new Array(iced_count,script);
  1529. }
  1530. else{
  1531. iced_posts[iced_posts.length] = [];
  1532. iced_posts[iced_posts.length-1][1] = script;
  1533. iced_posts[iced_posts.length-1][0] = iced_count;
  1534. }
  1535. }
  1536. if(fight_city==4){
  1537. var faction_level = attack_results.match(/zy_progress_bar_faction_text">(.+) \/ 1500/g);
  1538. document.getElementById('Yakuza_points').innerHTML = /zy_progress_bar_faction_text">(.+) \/ 1500/.exec(faction_level[0])[1];
  1539. document.getElementById('Triad_points').innerHTML = /zy_progress_bar_faction_text">(.+) \/ 1500/.exec(faction_level[1])[1];
  1540. }
  1541. switch(parseInt(fight_city)){
  1542. case 1:
  1543. document.getElementById('user_cash_nyc').innerHTML = /user_fields\['user_cash_nyc'\] = "([^"]+)/.exec(attack_results)[1];
  1544. cash_in_hand = document.getElementById('user_cash_nyc').innerHTML.replace(/,/g,'').replace(/\$/g,'');
  1545. if((parseInt(cash_in_hand) > parseInt(document.getElementById('user_bank_limit').value)) && (document.getElementById('user_bank_enable').checked)){
  1546. logmsg('Banking <span class="good">'+document.getElementById('user_cash_nyc').innerHTML+'</span>','attack_log');
  1547. bank(cash_in_hand);
  1548. }
  1549. break;
  1550. case 2:
  1551. document.getElementById('user_cash_cuba').innerHTML = /user_fields\['user_cash_cuba'\] = "([^"]+)/.exec(attack_results)[1];
  1552. cash_in_hand = document.getElementById('user_cash_cuba').innerHTML.replace(/,/g,'').replace(/C\$/g,'');
  1553. if((parseInt(cash_in_hand) > parseInt(document.getElementById('user_bank_limit').value)) && (document.getElementById('user_bank_enable').checked)){
  1554. logmsg('Banking <span class="good">'+document.getElementById('user_cash_cuba').innerHTML+'</span>','attack_log');
  1555. bank(cash_in_hand);
  1556. }
  1557. break;
  1558. case 3:
  1559. document.getElementById('user_cash_moscow').innerHTML = /user_fields\['user_cash_moscow'\] = "([^"]+)/.exec(attack_results)[1];
  1560. cash_in_hand = document.getElementById('user_cash_moscow').innerHTML.replace(/,/g,'').replace(/R\$/g,'');
  1561. if((parseInt(cash_in_hand) > parseInt(document.getElementById('user_bank_limit').value)) && (document.getElementById('user_bank_enable').checked)){
  1562. logmsg('Banking <span class="good">'+document.getElementById('user_cash_moscow').innerHTML+'</span>','attack_log');
  1563. bank(cash_in_hand);
  1564. }
  1565. break;
  1566. case 4:
  1567. document.getElementById('user_cash_bangkok').innerHTML = /user_fields\['user_cash_bangkok'\] = "([^"]+)/.exec(attack_results)[1];
  1568. cash_in_hand = document.getElementById('user_cash_bangkok').innerHTML.replace(/,/g,'').replace(/B\$/g,'');
  1569. if((parseInt(cash_in_hand) > parseInt(document.getElementById('user_bank_limit').value)) && (document.getElementById('user_bank_enable').checked)){
  1570. logmsg('Banking <span class="good">'+document.getElementById('user_cash_bangkok').innerHTML+'</span>','attack_log');
  1571. bank(cash_in_hand);
  1572. }
  1573. break;
  1574. case 5:
  1575. document.getElementById('user_cash_vegas').innerHTML = /user_fields\['user_cash_vegas'\] = "([^"]+)/.exec(attack_results)[1];
  1576. cash_in_hand = document.getElementById('user_cash_vegas').innerHTML.replace(/,/g,'').replace(/V\$/g,'');
  1577. if((parseInt(cash_in_hand) > parseInt(document.getElementById('bank_limit').value)) && (document.getElementById('user_bank_enable').checked)){
  1578. logmsg('Banking <span class="good">'+document.getElementById('user_cash_vegas').innerHTML+'</span>','attack_log');
  1579. bank(cash_in_hand,'vegas');
  1580. }
  1581. break;
  1582. case 6:
  1583. document.getElementById('user_cash_italy').innerHTML = /user_fields\['user_cash_italy'\] = "([^"]+)/.exec(attack_results)[1];
  1584. cash_in_hand = document.getElementById('user_cash_italy').innerHTML.replace(/,/g,'').replace(/L\$/g,'');
  1585. if((parseInt(cash_in_hand) > parseInt(document.getElementById('bank_limit').value)) && (document.forms.something.bank_enable.checked)){
  1586. logmsg('Banking <span class="good">'+document.getElementById('user_cash_italy').innerHTML+'</span>','attack_log');
  1587. bank(cash_in_hand,'italy');
  1588. }
  1589. break;
  1590. }
  1591. if(/You won/i.test(attack_results)){
  1592. if(/<span class="good">Win: (\d)<\/span>/.test(attack_results)){
  1593. win += parseInt(/<span class="good">Win: (\d)<\/span>/.exec(attack_results)[1]);
  1594. }
  1595. else{
  1596. win++;
  1597. }
  1598. if(/<span class="bad">Loss: (\d)<\/span>/.test(attack_results)){
  1599. loss += parseInt(/<span class="bad">Loss: (\d)<\/span>/.exec(attack_results)[1]);
  1600. }
  1601. if(/Attack Again/.test(attack_results)){
  1602. logtext = '<img src="http://codeoutpost.com/Scripts/attack.png" alt="alive"></img> ';
  1603. }
  1604. document.getElementById('wins').innerHTML = win;
  1605. logtext += '<span class="good">You won !</span> ';
  1606. // if(/rallied/.test(attack_results)){
  1607. // exp_gained += 2 * parseInt(/fightres_experience good">\n(.*)\+(\d*) Experience/.exec(attack_results)[2]);
  1608. // logtext += 'Exp gained - <span class="good">' + (2 * parseInt(/fightres_experience good">\n(.*)\+(\d*) Experience/.exec(attack_results)[2]))+'</span>';
  1609. // }
  1610. // else{
  1611. exp_gained += parseInt(/\+(\d*) Experience/.exec(attack_results)[1]);
  1612. logtext += '<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_experience_16x16_01.gif" alt="Exp"> <span class="good">' + parseInt(/\+(\d*) Experience/.exec(attack_results)[1])+'</span>';
  1613. // }
  1614. if(/Fan Bonus/.test(attack_results)){
  1615. if(/rallied/.test(attack_results)){
  1616. exp_gained += 2 * parseInt(/(\d*) Fan Bonus/.exec(attack_results)[1]);
  1617. logtext += ' Fan Bonus - <span class="good">' + (2 * parseInt(/(\d*) Fan Bonus/.exec(attack_results)[1]))+'</span>';
  1618. }
  1619. else{
  1620. exp_gained += parseInt(/(\d*) Fan Bonus/.exec(attack_results)[1]);
  1621. logtext += ' Fan Bonus - <span class="good">' + parseInt(/(\d*) Fan Bonus/.exec(attack_results)[1])+'</span>';
  1622. }
  1623. }
  1624. // alert(/fightres_cash sexy_cash good">\n(.*)\+( *)([^<]+)/.exec(attack_results));
  1625. cash = /(sexy_cuba_cash|sexy_bangkok_cash|sexy_moscow_cash|sexy_vegas_cash|sexy_italy_cash|sexy_new_york_cash) good"\>(\n|\f|\r)([^<]+)/.exec(attack_results)[3];
  1626. logtext += ' <img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cash_16x16_01.gif" alt="cash"></img> <span class="good">'+cash+'</span>';
  1627. if(iced == true){
  1628. logtext += ' <img src="http://codeoutpost.com/Scripts/Ice.png" alt="Iced"></img>';
  1629. }
  1630. if(killed == true){
  1631. logtext += ' <img src="http://codeoutpost.com/Scripts/kill.png" alt="Kill"></img>';
  1632. }
  1633. try{
  1634. logtext += ' <img src="http://mwfb.static.zynga.com/mwfb/graphics/victory_icon.gif"></img>+<span class="good">'+ (/\+(\d+).*Victory Coins/.exec(attack_results)[1])+'</span> ';
  1635. }
  1636. catch(err){}
  1637. if(temp != ''){
  1638. temp = temp.replace(/\(.+?\)/g,'');
  1639. logtext += ' <img src="'+loot_img+'" style="width: 20px; height: 20px;"></img>'+temp;
  1640. }
  1641. logmsg(logtext,'attack_log');
  1642. document.getElementById('exp_gained').innerHTML = exp_gained;
  1643. exp_ratio = exp_gained/(win+loss);
  1644. document.getElementById('exp_ratio').innerHTML = exp_ratio.toFixed(2);
  1645. // document.getElementById('logger').innerHTML = 'Fought '+ fightlist_names[i] +' and You won ! Total Exp gained - '+exp_gained;
  1646. // alert();
  1647. // alert(/fightres_cash sexy_cash good">\n(.*)\+(.*)\$([^<]+)/.exec(attack_results)[3].replace(/,/g,''));
  1648. // return;
  1649. switch(true){
  1650. case (/sexy_cuba_cash good"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1651. process_cash(2,(/sexy_cuba_cash good"\>[^\$]+\$([^<]+)/.exec(attack_results)[1].replace(/,/g,'')));
  1652. cash_city = 2;
  1653. break;
  1654. case (/sexy_moscow_cash good"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1655. process_cash(3,(/sexy_moscow_cash good"\>[^\$]+\$([^<]+)/.exec(attack_results)[1].replace(/,/g,'')));
  1656. cash_city = 3;
  1657. break;
  1658. case (/sexy_bangkok_cash good"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1659. process_cash(4,(/sexy_bangkok_cash good"\>[^\$]+\$([^<]+)/.exec(attack_results)[1].replace(/,/g,'')));
  1660. cash_city = 4;
  1661. break;
  1662. case (/sexy_vegas_cash good"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1663. process_cash(5,(/sexy_vegas_cash good"\>[^\$]+\$([^<]+)/.exec(attack_results)[1].replace(/,/g,'')));
  1664. cash_city = 5;
  1665. break;
  1666. case (/sexy_italy_cash good"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1667. process_cash(6,(/sexy_italy_cash good"\>[^\$]+\$([^<]+)/.exec(attack_results)[1].replace(/,/g,'')));
  1668. cash_city = 6;
  1669. break;
  1670. case (/sexy_new_york_cash good"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1671. process_cash(1,(/sexy_new_york_cash good"\>[^\$]+\$([^<]+)/.exec(attack_results)[1].replace(/,/g,'')));
  1672. cash_city = 1;
  1673. break;
  1674. }
  1675. // setTimeout(attack_user,random_delay*1000);
  1676. if(/Attack Again/.test(attack_results)){
  1677. if(/Attack again 5 times/.test(attack_results)){
  1678. if(user_power_attack_enable){
  1679. user_power_attack = true;
  1680. }
  1681. else{
  1682. user_power_attack = false;
  1683. }
  1684. temp_variable = /&xw_action=power_attack&xw_city=.+?&tmp=(.+?)&/.exec(attack_results)[1];
  1685. }
  1686. setTimeout(attack_user,random_delay*1000);
  1687. }
  1688. else{
  1689. if(user_list.length > 1){
  1690. logmsg('Done with '+user_names[j]+' Fetching next target in '+random_delay+' seconds..','attack_log');
  1691. }
  1692. // alert(user_list.length);
  1693. j++;
  1694. // document.getElementById('logged').innerHTML = document.getElementById('logger').innerHTML +'<br>'+ document.getElementById('logged').innerHTML;
  1695. if(j >= user_list.length){
  1696. if(document.forms.mwpusher.UserSkip.checked){
  1697. logmsg('All users Iced/Killed. Stopping..','status');
  1698. stop();
  1699. firsttime = true;
  1700. return;
  1701. }
  1702. // logmsg('Reached last member, reloading..','attack_log');
  1703. if(user_list.length > 1){
  1704. logmsg('Reached last member, reloading..','attack_log');
  1705. }
  1706. j=0;
  1707. }
  1708. setTimeout(attack_user,random_delay*1000);
  1709. }
  1710. return;
  1711. }
  1712. else{
  1713. if(/You lost/i.test(attack_results)){
  1714. logtext = '';
  1715. loss++;
  1716. document.getElementById('losses').innerHTML = loss;
  1717. cash = /(sexy_cuba_cash|sexy_bangkok_cash|sexy_moscow_cash|sexy_vegas_cash|sexy_italy_cash|sexy_new_york_cash) (bad|good)"\>(\n|\f|\r)([^<]+)/.exec(attack_results)[4];
  1718. switch(true){
  1719. case (/sexy_cuba_cash (bad|good)"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1720. process_cash(2,-(/sexy_cuba_cash (bad|good)"\>[^\$]+\$([^<]+)/.exec(attack_results)[2].replace(/,/g,'')));
  1721. break;
  1722. case (/sexy_moscow_cash (bad|good)"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1723. process_cash(3,-(/sexy_moscow_cash (bad|good)"\>[^\$]+\$([^<]+)/.exec(attack_results)[2].replace(/,/g,'')));
  1724. break;
  1725. case (/sexy_bangkok_cash (bad|good)"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1726. process_cash(4,-(/sexy_bangkok_cash (bad|good)"\>[^\$]+\$([^<]+)/.exec(attack_results)[2].replace(/,/g,'')));
  1727. break;
  1728. case (/sexy_vegas_cash (bad|good)"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1729. process_cash(5,-(/sexy_vegas_cash (bad|good)"\>[^\$]+\$([^<]+)/.exec(attack_results)[2].replace(/,/g,'')));
  1730. break;
  1731. case (/sexy_italy_cash (bad|good)"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1732. process_cash(6,-(/sexy_italy_cash (bad|good)"\>[^\$]+\$([^<]+)/.exec(attack_results)[2].replace(/,/g,'')));
  1733. break;
  1734. case (/sexy_new_york_cash (bad|good)"\>[^\$]+\$([^<]+)/.test(attack_results)):
  1735. process_cash(1,-(/sexy_new_york_cash (bad|good)"\>[^\$]+\$([^<]+)/.exec(attack_results)[2].replace(/,/g,'')));
  1736. break;
  1737. }
  1738. if(/Attack Again/.test(attack_results)){
  1739. logtext = '<img src="http://codeoutpost.com/Scripts/attack.png" alt="alive"></img> ';
  1740. }
  1741. logtext += '<span class="bad">You Lost !</span> Cash Lost <span class="bad">'+cash+'</span>';
  1742. if(iced == true){
  1743. logtext += ' Iced !';
  1744. }
  1745. if(killed == true){
  1746. logtext += ' Kill !';
  1747. }
  1748. logmsg(logtext,'attack_log');
  1749. }
  1750. if(/Attack Again/.test(attack_results)){
  1751. if(/Attack again 5 times/.test(attack_results)){
  1752. if(user_power_attack_enable){
  1753. user_power_attack = true;
  1754. }
  1755. else{
  1756. user_power_attack = false;
  1757. }
  1758. temp_variable = /&xw_action=power_attack&xw_city=.+?&tmp=(.+?)&/.exec(attack_results)[1];
  1759. }
  1760. setTimeout(attack_user,random_delay*1000);
  1761. }
  1762. else{
  1763. if(user_list.length > 1){
  1764. logmsg('Done with '+user_names[j]+' Fetching next target in '+random_delay+' seconds..','attack_log');
  1765. }
  1766. // alert(user_list.length);
  1767. j++;
  1768. // document.getElementById('logged').innerHTML = document.getElementById('logger').innerHTML +'<br>'+ document.getElementById('logged').innerHTML;
  1769. if(j >= user_list.length){
  1770. if(document.forms.mwpusher.UserSkip.checked){
  1771. logmsg('All users Iced/Killed. Stopping..','status');
  1772. stop();
  1773. firsttime = true;
  1774. return;
  1775. }
  1776. // logmsg('Reached last member, reloading..','attack_log');
  1777. if(user_list.length > 1){
  1778. logmsg('Reached last member, reloading..','attack_log');
  1779. }
  1780. j=0;
  1781. }
  1782. setTimeout(attack_user,random_delay*1000);
  1783. }
  1784. return;
  1785. //bs
  1786. //bs if(user_list.length > 1){
  1787. //bs logmsg(user_names[j]+' too strong, Fetching next target in '+random_delay+' seconds..','attack_log');
  1788. //bs }
  1789. j++;
  1790. // document.getElementById('logged').innerHTML = document.getElementById('logger').innerHTML +'<br>'+ document.getElementById('logged').innerHTML;
  1791. if(j >= user_list.length){
  1792. if(document.forms.mwpusher.UserSkip.checked){
  1793. logmsg('All users Iced/Killed. Stopping..','status');
  1794. stop();
  1795. firsttime = true;
  1796. return;
  1797. }
  1798. // logmsg('Reached last member, reloading..','attack_log');
  1799. if(user_list.length > 1){
  1800. logmsg('Reached last member, reloading..','status');
  1801. }
  1802. attack_or_not = true;
  1803. j=0;
  1804. setTimeout(attack_user,random_delay*1000);
  1805. return;
  1806. }
  1807. else{
  1808. setTimeout(attack_user,random_delay*1000);
  1809. return;
  1810. }
  1811. }
  1812. }
  1813. function stop(){
  1814. if((document.getElementById('finish_heal_enable').checked) && (heal_city != 0)){
  1815. if($('#user_health').html() != $('#user_max_health').html()){
  1816. heal();
  1817. return;
  1818. }
  1819. }
  1820. if(document.getElementById('restart_enable').checked){
  1821. var restart_time = parseInt(document.getElementById('restart_min').value);
  1822. attack_or_not=true;
  1823. logmsg('Attack run complete, Restarting in '+restart_time+' second(s)..','status');
  1824. setTimeout(loadfightpage,restart_time*1000);
  1825. return;
  1826. }
  1827. document.getElementById('pause').style.display = 'none';
  1828. document.getElementById('begin').style.display = 'inline';
  1829. }
  1830. function next(){
  1831. attack_count=0;
  1832. i++;
  1833. Trace('In NExt()');
  1834. wait1 = parseInt(document.getElementById('delay1').value);
  1835. wait2 = parseInt(document.getElementById('delay2').value);
  1836. var higher = (wait2 > wait1 ? wait2 : wait1);
  1837. var lower = (wait2 > wait1 ? wait1 : wait2);
  1838. var random_delay = Math.floor((higher-(lower-1))*Math.random()) + lower;
  1839. power_attack = false;
  1840. if(i >= fightlist_attack.length){
  1841. logmsg('Reached last member, reloading Fightlist..','status');
  1842. attack_or_not=true;
  1843. loadfightpage();
  1844. return;
  1845. }
  1846. pre_check();
  1847. }
  1848. function pre_check(){
  1849. var higher = (wait2 > wait1 ? wait2 : wait1);
  1850. var lower = (wait2 > wait1 ? wait1 : wait2);
  1851. var random_delay = Math.floor((higher-(lower-1))*Math.random()) + lower;
  1852. random_delay = (random_delay < 0)? 0 : random_delay;
  1853. Trace('In pre check');
  1854. if(fightlist_loaded==false){
  1855. logmsg('Fightlist loading, Please wait..','status');
  1856. return;
  1857. }
  1858. if(run == false){
  1859. logmsg('Paused...','status');
  1860. return;
  1861. }
  1862. user_count = parseInt(document.forms.mwpusher.attackcount.value);
  1863. heal_thres = parseInt(document.getElementById('heal_thres').value);
  1864. if(document.getElementById('user_health').innerHTML < heal_thres){
  1865. heal();
  1866. return;
  1867. }
  1868. if(actual_count >= user_count && user_count!=0){
  1869. logmsg('Finished Attack run, Stopping..','status');
  1870. stop();
  1871. return;
  1872. }
  1873. if(document.getElementById('user_stamina').innerHTML <= 0){
  1874. logmsg('Ran out of stamina, stopping..','status');
  1875. stop();
  1876. return;
  1877. }
  1878. if(power_attack && (parseInt(exp_to_levelup) <= 30) && levelup_halt){
  1879. logmsg('Could level up on next Attack, Stopping..','status');
  1880. stop();
  1881. return;
  1882. }
  1883. if((!power_attack) && (parseInt(exp_to_levelup) <= 6) && levelup_halt){
  1884. logmsg('Could level up on next Attack, Stopping..','status');
  1885. stop();
  1886. return;
  1887. }
  1888. if(parseInt(document.getElementById('exp_to_level').value) != 0){
  1889. if(power_attack){
  1890. var user_exp_level = parseInt(document.getElementById('exp_to_level').value) + 30;
  1891. }
  1892. else{
  1893. var user_exp_level = parseInt(document.getElementById('exp_to_level').value) + 6;
  1894. }
  1895. if(parseInt(exp_to_levelup) < user_exp_level){
  1896. logmsg('Could cross user set level up exp on next attack, Stopping..','status');
  1897. stop();
  1898. return;
  1899. }
  1900. }
  1901. cash_limit = parseInt(document.forms.mwpusher.cashlimit.value);
  1902. if(document.getElementById('SpecialChars').value != ''){
  1903. var avoid_chars = document.getElementById('SpecialChars').value.split('\n');
  1904. for(k=0; k < avoid_chars.length; k++){
  1905. if(fightlist_char_names[i].indexOf(avoid_chars[k]) != -1){
  1906. logmsg('Skipping '+fightlist_names[i]+' fetching next target','status');
  1907. skip_reason = 'Ignore char space';
  1908. next();
  1909. return;
  1910. }
  1911. }
  1912. }
  1913. if(document.forms.mwpusher.faction_enable.checked){
  1914. switch(true){
  1915. case document.forms.mwpusher.Triad.checked:
  1916. if(fightlist_faction[i]=='Yakuza'){
  1917. logmsg(fightlist_names[i]+' belongs to opposite faction, fetching next target','status');
  1918. skip_reason = 'Yakuza faction, Triad attack checked';
  1919. next();
  1920. return;
  1921. }
  1922. break;
  1923. case document.forms.mwpusher.Yakuza.checked:
  1924. if(fightlist_faction[i]=='Triad'){
  1925. logmsg(fightlist_names[i]+' belongs to opposite faction, fetching next target','status');
  1926. skip_reason = 'Triad faction, Yakuza attack checked';
  1927. next();
  1928. return;
  1929. }
  1930. break;
  1931. case document.forms.mwpusher.Balance_Faction.checked:
  1932. var faction_diff = parseInt(document.forms.mwpusher.balanceamt.value);
  1933. if(Triad > Yakuza){
  1934. Trace('Triad is higher');
  1935. if((Triad - Yakuza) > faction_diff){
  1936. if(fightlist_faction[i]=='Yakuza'){
  1937. skip_reason = 'Yakuza faction, Triad attack needed';
  1938. next();
  1939. return;
  1940. }
  1941. }
  1942. }
  1943. else if(Triad < Yakuza){
  1944. Trace('Yakuza is higher');
  1945. if((Yakuza - Triad) > faction_diff){
  1946. if(fightlist_faction[i]=='Triad'){
  1947. skip_reason = 'Triad faction, Yakuza attack needed';
  1948. next();
  1949. return;
  1950. }
  1951. }
  1952. }
  1953. break;
  1954. }
  1955. }
  1956. try{
  1957. var lwr_level = parseInt(document.getElementById('LowerLevel').value);
  1958. var uppr_level = parseInt(document.getElementById('UpperLevel').value);
  1959. var lwr_mafia = parseInt(document.getElementById('LowerMafia').value);
  1960. var uppr_mafia = parseInt(document.getElementById('UpperMafia').value);
  1961. for(k=0; k < strong_list.length; k++){
  1962. if(fightlist_char_names[i] == strong_list[k]){
  1963. skip_reason = 'Strong list volunteer';
  1964. next();
  1965. return;
  1966. }
  1967. }
  1968. if(!(fightlist_levels[i]>= lwr_level && fightlist_levels[i]<=uppr_level)){
  1969. skip_reason = 'Character Level limits';
  1970. next();
  1971. return;
  1972. }
  1973. if(!(fightlist_mafia[i]>= lwr_mafia && fightlist_mafia[i]<=uppr_mafia)){
  1974. skip_reason = 'Mafia level limits';
  1975. next();
  1976. return;
  1977. }
  1978. }
  1979. catch(err){alert(err);}
  1980. if(document.getElementById('ice_check').checked){
  1981. try{
  1982. var target_id = /opponent_id=p%7C(\d+)/.exec(fightlist_attack[i])[1];
  1983. var params = { 'ajax': 1,
  1984. 'liteload': 1,
  1985. 'sf_xw_user_id': userid,
  1986. 'sf_xw_sig': local_xw_sig
  1987. };
  1988. logmsg('Running Ice Check on '+fightlist_names[i],'status');
  1989. 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;
  1990. $.ajax({type: "POST",url: hitlist_url, timeout: 30000, data: params,
  1991. success: function (msg){
  1992. if (/You can't add/.test(msg)){
  1993. logmsg(fightlist_names[i]+' is already Iced/Dead, skipping..','status');
  1994. logmsg(fightlist_names[i]+' is already Iced/Dead, skipping..','attack_log');
  1995. skip_reason = 'Iced';
  1996. next();
  1997. return;
  1998. }
  1999. else{
  2000. setTimeout(attack,random_delay*1000);
  2001. return;
  2002. }
  2003. },
  2004. error: function(req,status,err){
  2005. pre_check();
  2006. return;
  2007. }
  2008. });
  2009. return;
  2010. }
  2011. catch(err){alert(err);alert(i);alert(fightlist_attack[i]);}
  2012. }
  2013. setTimeout(attack,random_delay*1000);
  2014. }
  2015. function get_xmlHTTP(){
  2016. if(window.XMLHttpRequest)
  2017. return new XMLHttpRequest();
  2018. if(window.ActiveXObject)
  2019. return new ActiveXObject('Microsoft.XMLHTTP');
  2020. return;
  2021. }
  2022. function loadSpammers(){
  2023. document.getElementById('UserIds').value = AddMeSpammers;
  2024. }
  2025. function Add_to_loot(loot,count,img){
  2026. var WeaponsDepot = /Forge|Arc Welder|Buzzsaw|Gunpowder|Gun Drill|Sonic Emitter|Weapon Part|Grapple|Boomerang|Railgun Barrel|Laser Rangefinder|Explosive Arrow|Portable Fusion Reactor/;
  2027. var Vegas = /Deposit Box|Magnetic Lock|Motion Sensor|Reinforced Steel|Security Camera|Concrete|Construction Tool|Steel Girder|Cinder Block|Bellhop|Chef|Poker Table|Slot Machine|Casino Dealer/;
  2028. var MHEL = /Zmeya Carbon Blade|Ubijca Assault Rifle|Konstantin Cargo Carrier|Executive Overcoat|Shturmovik|Zoloto Sports Car/;
  2029. var FHEL = /12 Gauge|Devastator|Zeus|Bomb Suit|Segmented Body Plate|Skull Cap|Cobra G7|Ruby Red|Turbo Road Warrior|Condor|Cougar|Rhinoceros/;
  2030. var FHEL2 = /Woodsman|Buzzard Combat Chopper|Tasmanian Devil|Domestic Defense/;
  2031. var ChopShop = /Cement Block|Power Tool|Car Lift|Acetylene Torch|Shipping Container|Car Part|High Tech Car Part|Cuban Car Part|Thai Car Part|Russian Car Part|Solar Panel|Bulletproof Glass|Suspension Coil/;
  2032. var BHEL = /Nak Kha Shotgun|Titanium Katar|Ninja|Royal Thai Marine|Raed Armored Sedan|Lamang Motorcycle|Chain Viper|Forest Scorpion/;
  2033. var Armory = /Micro-Fission Cell|Bio-Monitor/;
  2034. total_loot+=count;
  2035. if(/sexy_attack/.test(loot)){
  2036. var a = /sexy_attack">(\d+)<.*?sexy_defense">(\d+)/.exec(loot);
  2037. loot = loot.replace(/\(.+?\)/,'');
  2038. if(a[1] >= a[2]){
  2039. loot = '(<span class="sexy_attack">'+a[1]+'</span> <span class="sexy_defense">'+a[2]+'</span>) '+loot;
  2040. }
  2041. else{
  2042. loot = '(<span class="sexy_defense">'+a[2]+'</span> <span class="sexy_attack">'+a[1]+'</span>) '+loot;
  2043. }
  2044. }
  2045. if(loot.search(WeaponsDepot) > -1){
  2046. loot = '<span class="more_in">[WD]</span> ' + loot;
  2047. }
  2048. if(loot.search(ChopShop) > -1){
  2049. loot = '<span class="more_in">[CS]</span> ' + loot;
  2050. }
  2051. if(loot.search(FHEL) > -1){
  2052. loot = '<span class="more_in">[FHEL]</span> ' + loot;
  2053. }
  2054. if(loot.search(FHEL2) > -1){
  2055. loot = '<span class="more_in">[FHEL2]</span> ' + loot;
  2056. }
  2057. if(loot.search(Vegas) > -1){
  2058. loot = '<span class="more_in">[Vegas]</span> ' + loot;
  2059. }
  2060. if(loot.search(BHEL) > -1){
  2061. loot = '<span class="more_in">[BHEL]</span> ' + loot;
  2062. }
  2063. if(loot.search(MHEL) > -1){
  2064. loot = '<span class="more_in">[MHEL]</span> ' + loot;
  2065. }
  2066. if(loot.search(Armory) > -1){
  2067. loot = '<span class="more_in">[Armory]</span> ' + loot;
  2068. }
  2069. if(loot_item.length <= 0){
  2070. loot_item[loot_item.length]=new Array(loot,count,img);
  2071. }
  2072. else{
  2073. for(k=0; k<loot_item.length; k++){
  2074. if(loot == loot_item[k][0]){
  2075. loot_item[k][1]+=count;
  2076. break;
  2077. }
  2078. else if(k==loot_item.length-1){
  2079. loot_item[loot_item.length]=new Array(loot,count,img);
  2080. break;
  2081. }
  2082. }
  2083. }
  2084. loot_item.sort();
  2085. document.getElementById('loot_log').innerHTML = '';
  2086. try{
  2087. l_log = '';
  2088. for(l=(loot_item.length-1); l>=0; l--){
  2089. if(loot_item[l][2]!=""){
  2090. l_log += '<span class="good">'+loot_item[l][1]+'x</span> <img src="'+loot_item[l][2]+'" style="width:20px; height:20px" onmouseout="this.style.width=\'20px\';this.style.height=\'20px\';" onmouseover="this.style.width=\'40px\';this.style.height=\'40px\';"></img> '+loot_item[l][0]+'<br>';
  2091. }
  2092. else{
  2093. l_log += '<span class="good">'+loot_item[l][1]+'x</span> '+loot_item[l][0]+'<br>';
  2094. }
  2095. }
  2096. document.getElementById('loot_log').innerHTML = l_log;
  2097. }
  2098. catch(err){alert(err);}
  2099. }
  2100. function heal(){
  2101. Trace('In heal function');
  2102. //clearTimeout(timeout_timer);
  2103. cb=userid+UnixTS();
  2104. var params = { 'ajax': 1,
  2105. 'liteload': 1,
  2106. 'sf_xw_user_id': userid,
  2107. 'sf_xw_sig': local_xw_sig
  2108. };
  2109. // document.getElementById('popup_permanence').innerHTML += 'Heal travel value - '+heal_travel+'<br>';
  2110. if(heal_city == 0){
  2111. logmsg('Healing disabled, Stopping..','status');
  2112. logmsg('Healing disabled, Stopping..','attack_log');
  2113. stop();
  2114. return;
  2115. }
  2116. if(fight_city==heal_city){
  2117. heal_travel=false;
  2118. logmsg('Healing...','status');
  2119. $.ajax({type: "POST",data: params, dataType: "json",url: "http://facebook.mafiawars.com/mwfb/remote/html_server.php?xw_controller=hospital&xw_action=heal&cb="+cb+"&xw_client_id=8",
  2120. success: function (msg){
  2121. if(msg.hospital_message == null){
  2122. logmsg('Error during healing, retrying in 2 seconds..','status');
  2123. setTimeout(heal,2000);
  2124. return;
  2125. }
  2126. else if(/healed/.test(msg.hospital_message)){
  2127. process_cash(heal_city,-(/for (C|B|R|V|L|)\$([^.]+)/.exec(msg.hospital_message)[2].replace(/,/g,'')));
  2128. document.getElementById('user_health').innerHTML = msg.user_fields.user_health;
  2129. logmsg('<img src="http://codeoutpost.com/Scripts/heal.png" alt="heal"></img> Healed <span class="bad">'+(/for (C|B|R|V|L|)\$([^.]+)/.exec(msg.hospital_message)[0])+'</span>, Resuming attacks..','attack_log');
  2130. }
  2131. else if(msg.user_fields.user_health == msg.user_fields.user_max_health){
  2132. document.getElementById('user_health').innerHTML = msg.user_fields.user_health;
  2133. }
  2134. else if(/cannot heal so fast/.test(msg.hospital_message)){
  2135. logmsg('Cannot heal too fast, retrying in 10 seconds..','status');
  2136. document.getElementById('user_health').innerHTML = msg.user_fields.user_health;
  2137. setTimeout(heal,10000);
  2138. return;
  2139. }
  2140. else{
  2141. document.getElementById('user_health').innerHTML = msg.user_fields.user_health;
  2142. }
  2143. heal_travel=false;
  2144. start_attack();
  2145. return;
  2146. }
  2147. });
  2148. return;
  2149. }
  2150. else if(heal_travel==true){
  2151. logmsg('Retrying Heal...','status');
  2152. $.ajax({type: "POST",data: params, dataType: "json",url: "http://facebook.mafiawars.com/mwfb/remote/html_server.php?xw_controller=hospital&xw_action=heal&cb="+cb+"&xw_client_id=8",
  2153. success: function (msg){
  2154. if(msg.hospital_message == null){
  2155. logmsg('Error during healing, retrying in 2 seconds..','status');
  2156. setTimeout(heal,2000);
  2157. return;
  2158. }
  2159. else if(/healed/.test(msg.hospital_message)){
  2160. process_cash(heal_city,-(/for (C|B|R|V|L|)\$([^.]+)/.exec(msg.hospital_message)[2].replace(/,/g,'')));
  2161. logmsg('<img src="http://codeoutpost.com/Scripts/heal.png" alt="heal"></img> Healed <span class="bad">'+(/for (C|B|R|V|L|)\$([^.]+)/.exec(msg.hospital_message)[0])+'</span>, Travelling back..','status');
  2162. logmsg('<img src="http://codeoutpost.com/Scripts/heal.png" alt="heal"></img> Healed <span class="bad">'+(/for (C|B|R|V|L|)\$([^.]+)/.exec(msg.hospital_message)[0])+'</span>, Travelling back..','attack_log');
  2163. document.getElementById('user_health').innerHTML = msg.user_fields.user_health;
  2164. }
  2165. else if(msg.user_fields.user_health == msg.user_fields.user_max_health){
  2166. document.getElementById('user_health').innerHTML = msg.user_fields.user_health;
  2167. logmsg('Travelling back..','status');
  2168. }
  2169. else if(/cannot heal so fast/.test(msg.hospital_message)){
  2170. logmsg('Cannot heal too fast, retrying in 10 seconds..','status');
  2171. document.getElementById('user_health').innerHTML = msg.user_fields.user_health;
  2172. setTimeout(heal,10000);
  2173. return;
  2174. }
  2175. else{
  2176. document.getElementById('user_health').innerHTML = msg.user_fields.user_health;
  2177. }
  2178. $.ajax({type: "POST", data: params, url: "http://facebook.mafiawars.com/mwfb/remote/html_server.php?xw_controller=travel&xw_action=travel&xw_city="+heal_city+"&cb="+cb+"&destination="+fight_city+"&from=fight&nextParams=&xw_client_id=8",
  2179. success: function (msg){
  2180. logmsg('Travelled Back..','status');
  2181. heal_travel=false;
  2182. start_attack();
  2183. return;
  2184. }
  2185. });
  2186. }
  2187. });
  2188. return;
  2189. }
  2190. else{
  2191. logmsg('Travelling to heal city..','status');
  2192. $.ajax({type: "POST", data: params, url: "http://facebook.mafiawars.com/mwfb/remote/html_server.php?xw_controller=travel&xw_action=travel&xw_city="+fight_city+"&cb="+cb+"&destination="+heal_city+"&from=fight&nextParams=&xw_client_id=8",
  2193. success: function (msg){
  2194. heal_travel=true;
  2195. var t_c = parseInt(/'#mw_city_wrapper'.+?'mw_city(\d+?)'/.exec(msg)[1]);
  2196. // alert(t_c+'\n'+heal_city+'\n'+(t_c==heal_city));
  2197. if(t_c != heal_city){
  2198. heal_travel = false;
  2199. heal();
  2200. }
  2201. logmsg('Healing...','status');
  2202. $.ajax({type: "POST", data: params, dataType: "json",url: "http://facebook.mafiawars.com/mwfb/remote/html_server.php?xw_controller=hospital&xw_action=heal&cb="+cb+"&xw_client_id=8",
  2203. success: function (msg){
  2204. if(msg.hospital_message == null){
  2205. logmsg('Error during healing, retrying in 2 seconds..','status');
  2206. setTimeout(heal,2000);
  2207. return;
  2208. }
  2209. else if(/healed/.test(msg.hospital_message)){
  2210. process_cash(heal_city,-(/for (C|B|R|V|L|)\$([^.]+)/.exec(msg.hospital_message)[2].replace(/,/g,'')));
  2211. logmsg('<img src="http://codeoutpost.com/Scripts/heal.png" alt="heal"></img> Healed <span class="bad">'+(/for (C|B|R|V|L|)\$([^.]+)/.exec(msg.hospital_message)[0])+'</span>, Travelling back..','status');
  2212. logmsg('<img src="http://codeoutpost.com/Scripts/heal.png" alt="heal"></img> Healed <span class="bad">'+(/for (C|B|R|V|L|)\$([^.]+)/.exec(msg.hospital_message)[0])+'</span>, Travelling back..','attack_log');
  2213. document.getElementById('user_health').innerHTML = msg.user_fields.user_health;
  2214. }
  2215. else if(msg.user_fields.user_health == msg.user_fields.user_max_health){
  2216. document.getElementById('user_health').innerHTML = msg.user_fields.user_health;
  2217. logmsg('Travelling back..','status');
  2218. }
  2219. else if(/cannot heal so fast/.test(msg.hospital_message)){
  2220. logmsg('Cannot heal too fast, retrying in 10..','status');
  2221. setTimeout(heal,10000);
  2222. return;
  2223. }
  2224. else{
  2225. document.getElementById('user_health').innerHTML = msg.user_fields.user_health;
  2226. }
  2227. $.ajax({type: "POST", data: params, url: "http://facebook.mafiawars.com/mwfb/remote/html_server.php?xw_controller=travel&xw_action=travel&xw_city="+heal_city+"&cb="+cb+"&destination="+fight_city+"&from=fight&nextParams=&xw_client_id=8",
  2228. success: function (msg){
  2229. logmsg('Travelled Back..','status');
  2230. heal_travel=false;
  2231. start_attack();
  2232. return;
  2233. }
  2234. });
  2235. }
  2236. });
  2237. }
  2238. });
  2239. return;
  2240. }
  2241. }
  2242. function process_cash(city,cash){
  2243. // alert('city - '+city+' Cash - '+parseInt(cash));
  2244. try{
  2245. switch(parseInt(city)){
  2246. case 1:
  2247. ny_cash += parseInt(cash);
  2248. break;
  2249. case 2:
  2250. cuba_cash += parseInt(cash);
  2251. break;
  2252. case 3:
  2253. moscow_cash += parseInt(cash);
  2254. break;
  2255. case 4:
  2256. bk_cash += parseInt(cash);
  2257. break;
  2258. case 5:
  2259. vegas_cash += parseInt(cash);
  2260. break;
  2261. case 6:
  2262. italy_cash += parseInt(cash);
  2263. break;
  2264. }
  2265. if(ny_cash < 0){
  2266. document.getElementById('cash').innerHTML = '&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cash_16x16_01.gif"></img>&nbsp;<span class="bad">-$'+format_cash(ny_cash)+'</span>';
  2267. }
  2268. else{
  2269. document.getElementById('cash').innerHTML = '&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cash_16x16_01.gif"></img>&nbsp;<span class="good">$'+format_cash(ny_cash)+'</span>';
  2270. }
  2271. if(cuba_cash < 0){
  2272. document.getElementById('cash').innerHTML += '&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cubanpeso_16x11_01.gif"></img>&nbsp;<span class="bad">-C$'+format_cash(cuba_cash)+'</span>';
  2273. }
  2274. else{
  2275. document.getElementById('cash').innerHTML += '&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cubanpeso_16x11_01.gif"></img>&nbsp;<span class="good">C$'+format_cash(cuba_cash)+'</span>';
  2276. }
  2277. if(moscow_cash < 0){
  2278. document.getElementById('cash').innerHTML += '&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cash_moscow_16x16_01.gif"></img>&nbsp;<span class="bad">-R$'+format_cash(moscow_cash)+'</span>';
  2279. }
  2280. else{
  2281. document.getElementById('cash').innerHTML += '&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cash_moscow_16x16_01.gif"></img>&nbsp;<span class="good">R$'+format_cash(moscow_cash)+'</span>';
  2282. }
  2283. if(bk_cash < 0){
  2284. document.getElementById('cash').innerHTML += '&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cash_bangkok_16x16_01.gif"></img>&nbsp;<span class="bad">-B$'+format_cash(bk_cash)+'</span>';
  2285. }
  2286. else{
  2287. document.getElementById('cash').innerHTML += '&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cash_bangkok_16x16_01.gif"></img>&nbsp;<span class="good">B$'+format_cash(bk_cash)+'</span>';
  2288. }
  2289. if(vegas_cash < 0){
  2290. document.getElementById('cash').innerHTML += '&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/vegas-chip.png"></img>&nbsp;<span class="bad">-V$'+format_cash(vegas_cash)+'</span>';
  2291. }
  2292. else{
  2293. document.getElementById('cash').innerHTML += '&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/vegas-chip.png"></img>&nbsp;<span class="good">V$'+format_cash(vegas_cash)+'</span>';
  2294. }
  2295. if(italy_cash < 0){
  2296. document.getElementById('cash').innerHTML += '&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cash_italy_16x16_02.png"></img>&nbsp;<span class="bad">-L$'+format_cash(italy_cash)+'</span>';
  2297. }
  2298. else{
  2299. document.getElementById('cash').innerHTML += '&nbsp;<img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_cash_italy_16x16_02.png"></img>&nbsp;<span class="good">L$'+format_cash(italy_cash)+'</span>';
  2300. }
  2301. }
  2302. catch(err){alert(err);}
  2303. }
  2304. function format_cash(cash){
  2305. var d;
  2306. while (d=/(\d+)(\d{3}.*)/.exec(cash)) {
  2307. cash = d[1] + ',' + d[2];
  2308. }
  2309. return cash;
  2310. }
  2311. loadfightpage();
  2312. function logmsg(message,tag){
  2313. var l=0;
  2314. var hr = new Date().getHours();
  2315. var minute = new Date().getMinutes();
  2316. hr= (hr<10?'0'+hr:hr);
  2317. minute = (minute<10?'0'+minute:minute);
  2318. var timestamp = '<font color=#666666>['+hr+':'+minute+']</font>';
  2319. switch(tag){
  2320. case 'attack_log':
  2321. attack_log.splice(0,0,' ' + timestamp +' '+ message);
  2322. break;
  2323. case 'status':
  2324. document.getElementById('status').innerHTML= message;
  2325. break;
  2326. }
  2327. actual_count = win+loss;
  2328. document.getElementById('fights').innerHTML = actual_count;
  2329. l = attack_log.length;
  2330. var user_l_len = parseInt(document.getElementById('log_size').value);
  2331. attack_log.length = (l<user_l_len) ? l:user_l_len;
  2332. document.getElementById('attack_log').innerHTML = '';
  2333. var log_c = '';
  2334. for(l=0; l<attack_log.length; l++){
  2335. log_c += attack_log[l]+'<br>';
  2336. }
  2337. document.getElementById('attack_log').innerHTML += log_c;
  2338. }
  2339. function bank(amount,city){
  2340. if(fight_city == 5){
  2341. var params = { 'ajax': 1,
  2342. 'liteload': 0,
  2343. 'sf_xw_user_id': userid,
  2344. 'sf_xw_sig': local_xw_sig
  2345. };
  2346. $.ajax({type: "POST", data: params,
  2347. url: "http://facebook.mafiawars.com/mwfb/remote/html_server.php?xw_controller=propertyV2&xw_action=doaction&xw_city=5&doaction=ActionBankDeposit&xw_person="+person+"&amount="+amount+"&city=5&building_type=6&xw_client_id=8",
  2348. success: function (msg){},error: function (s1,s2,s3){}
  2349. });
  2350. return;
  2351. }
  2352. do_ajax('','remote/html_server.php?xw_controller=bank&xw_action=deposit&xw_city='+cash_city+'&cb='+userid+UnixTS()+'&amount='+amount+'&city='+city,1,0,0,0);
  2353. }
  2354. function writeCookieStuff(){
  2355. wait1 = document.getElementById('delay1').value;
  2356. wait1 = (wait1=='')?2:wait1;
  2357. wait2 = document.getElementById('delay2').value;
  2358. wait2 = (wait2=='')?2:wait2;
  2359. ignore_chars = document.getElementById('SpecialChars').value.split('\n');
  2360. createCookie('Brawler_ignore',escape(ignore_chars));
  2361. bank_enable = (document.getElementById('bank_enable').checked)?'checked':' ';
  2362. user_bank_enable = (document.getElementById('user_bank_enable').checked)?'checked':' ';
  2363. bank_limit = document.getElementById('bank_limit').value;
  2364. bank_limit = (bank_limit=='')?10000:bank_limit;
  2365. attack_limit_enable = (document.getElementById('attack_limit_check').checked)?'checked':' ';
  2366. attack_limit_count = document.getElementById('attack_limit').value;
  2367. attack_limit_count = (attack_limit_count=='')?3:attack_limit_count;
  2368. lower_mafia = document.getElementById('LowerMafia').value;
  2369. lower_mafia = (lower_mafia=='')?0:lower_mafia;
  2370. upper_mafia = document.getElementById('UpperMafia').value;
  2371. upper_mafia = (upper_mafia=='')?501:upper_mafia;
  2372. lower_level = document.getElementById('LowerLevel').value;
  2373. lower_level = (lower_level=='')?0:lower_level;
  2374. upper_level = document.getElementById('UpperLevel').value;
  2375. upper_level = (upper_level=='')?9999:upper_level;
  2376. min_cash = document.getElementById('cashlimit').value;
  2377. min_cash = (min_cash=='')?0:min_cash;
  2378. same_city_cash = (document.getElementById('cash_city').checked)?'checked':' ';
  2379. faction_bal_points = document.getElementById('balanceamt').value;
  2380. faction_bal_points = (faction_bal_points=='')?10:faction_bal_points;
  2381. faction_attack = (document.getElementById('faction_enable').checked)?'checked':' ';
  2382. triad_fac = (document.getElementById('Triad').checked)?'checked':' ';
  2383. yakuza_fac = (document.getElementById('Yakuza').checked)?'checked':' ';
  2384. faction_bal = (document.getElementById('Balance_Faction').checked)?'checked':' ';
  2385. ice_check_enable = (document.getElementById('ice_check').checked)?'checked':' ';
  2386. power_attack_enable = (document.getElementById('power_attack').checked)?'checked':' ';
  2387. user_power_attack_enable = (document.getElementById('user_power_attack').checked)?'checked':' ';
  2388. user_iced_check = (document.getElementById('user_iced_check').checked)?'checked':' ';
  2389. var cookieStuff = wait1+'|'+wait2+'|'+heal_city+'|'+heal_city_text+'|'+levelup_halt+'|'+levelup_text+'| |'+
  2390. bank_enable+'|'+user_bank_enable+'|'+bank_limit+'|'+attack_limit_enable+'|'+attack_limit_count+'|'+lower_mafia+'|'+upper_mafia+'|'+
  2391. lower_level+'|'+upper_level+'|'+min_cash+'|'+same_city_cash+'|'+faction_bal_points+'|'+faction_attack+'|'+
  2392. triad_fac+'|'+yakuza_fac+'|'+faction_bal+'|'+ice_check_enable+'|'+power_attack_enable+'|'+
  2393. user_power_attack_enable+'|'+user_iced_check;
  2394. createCookie('Brawler',cookieStuff);
  2395. }
  2396. function readCookieStuff(){
  2397. try{
  2398. var cookieStuff = readCookie('Brawler');
  2399. if(cookieStuff == null || (/undefined/.test(cookieStuff))){
  2400. return;
  2401. }
  2402. cookieStuff = cookieStuff.split('|');
  2403. wait1 = cookieStuff[0];
  2404. wait2 = cookieStuff[1];
  2405. heal_city = cookieStuff[2];
  2406. heal_city_text = cookieStuff[3];
  2407. levelup_halt = (cookieStuff[4] == 'true') ?true:false;
  2408. levelup_text = cookieStuff[5];
  2409. ignore_chars = readCookie('Brawler_ignore');
  2410. if(!(ignore_chars == null || ignore_chars=='')){
  2411. if(ignore_chars==' '){
  2412. ignore_chars='';
  2413. }
  2414. else{
  2415. ignore_chars = unescape(ignore_chars).replace(/,/g,'\n');
  2416. }
  2417. }
  2418. else{
  2419. ignore_chars='';
  2420. }
  2421. bank_enable = cookieStuff[7];
  2422. user_bank_enable = cookieStuff[8];
  2423. bank_limit = cookieStuff[9];
  2424. attack_limit_enable = cookieStuff[10];
  2425. attack_limit_count = cookieStuff[11];
  2426. lower_mafia = cookieStuff[12];
  2427. upper_mafia = cookieStuff[13];
  2428. lower_level = cookieStuff[14];
  2429. upper_level = cookieStuff[15];
  2430. min_cash = cookieStuff[16];
  2431. same_city_cash = cookieStuff[17];
  2432. faction_bal_points = cookieStuff[18];
  2433. faction_attack = cookieStuff[19];
  2434. triad_fac = cookieStuff[20];
  2435. yakuza_fac = cookieStuff[21];
  2436. faction_bal = cookieStuff[22];
  2437. ice_check_enable = cookieStuff[23];
  2438. power_attack_enable = cookieStuff[24];
  2439. user_power_attack_enable = cookieStuff[25];
  2440. user_iced_check = cookieStuff[26];
  2441. }
  2442. catch(err){}
  2443. }
  2444. function loadContent(file){
  2445. var head = document.getElementsByTagName('head').item(0)
  2446. var scriptTag = document.getElementById('loadScript');
  2447. if(scriptTag) head.removeChild(scriptTag);
  2448. script = document.createElement('script');
  2449. script.src = file;
  2450. script.type = 'text/javascript';
  2451. script.id = 'loadScript';
  2452. head.appendChild(script);
  2453. setTimeout(load,5000);
  2454. }
  2455. loadContent('http://www.google-analytics.com/ga.js');
  2456. function load(){
  2457. try {
  2458. var pageTracker = _gat._getTracker("UA-12870604-2");
  2459. pageTracker._trackPageview("/Brawler");
  2460. }
  2461. catch(err) {}
  2462. }
  2463. })();
  2464. function Trace(trace_message){
  2465. if(!trace_enable){
  2466. return;
  2467. }
  2468. var hr = new Date().getHours();
  2469. var minute = new Date().getMinutes();
  2470. hr= (hr<10?'0'+hr:hr);
  2471. minute = (minute<10?'0'+minute:minute);
  2472. var timestamp = '<font color=#666666>['+hr+':'+minute+']</font>';
  2473. document.getElementById('popup_permanence').innerHTML += timestamp + ' ' + skip_reason;
  2474. document.getElementById('popup_permanence').innerHTML += timestamp + ' ' + trace_message;
  2475. }
  2476. function temp_trace(trace_msg){
  2477. var hr = new Date().getHours();
  2478. var minute = new Date().getMinutes();
  2479. hr= (hr<10?'0'+hr:hr);
  2480. minute = (minute<10?'0'+minute:minute);
  2481. var timestamp = '<font color=#666666>['+hr+':'+minute+']</font>';
  2482. document.getElementById('popup_fodder').innerHTML += timestamp + ' ' + trace_msg;
  2483. }
  2484. function current_city(){
  2485. if($('#mw_city_wrapper').hasClass('mw_city1')){
  2486. return 1;
  2487. }
  2488. else if($('#mw_city_wrapper').hasClass('mw_city2')){
  2489. return 2;
  2490. }
  2491. else if($('#mw_city_wrapper').hasClass('mw_city3')){
  2492. return 3;
  2493. }
  2494. else if($('#mw_city_wrapper').hasClass('mw_city4')){
  2495. return 4;
  2496. }
  2497. else if($('#mw_city_wrapper').hasClass('mw_city5')){
  2498. return 5;
  2499. }
  2500. else if($('#mw_city_wrapper').hasClass('mw_city6')){
  2501. return 6;
  2502. }
  2503. }
  2504. function field_validate(key_code){
  2505. // alert(key_code);
  2506. if ((key_code>=48 && key_code<=57) || (key_code>=96 && key_code<=105) || key_code==8 || key_code==127 || key_code==37 || key_code==39 || key_code==9 || key_code==46 || key_code==13 || key_code==17 || key_code==86){
  2507. return true;
  2508. }
  2509. else{
  2510. return false;
  2511. }
  2512. }
  2513. // createCookie from Vern's Toolkit http://vern.com/mwtools/
  2514. function createCookie(name,value) {
  2515. // expire one month from now
  2516. var expires = new Date();
  2517. expires.setDate(expires.getDate()+30);
  2518. document.cookie = name+"="+value+";expires="+expires.toGMTString()+"; path=/";
  2519. }
  2520. // readCookie from Vern's Toolkit http://vern.com/mwtools/
  2521. function readCookie(name) {
  2522. var i,
  2523. cookie,
  2524. nameEQ = name+"=",
  2525. cookieArray = document.cookie.split(";");
  2526. for (i=0; i< cookieArray.length; i++) {
  2527. cookie = cookieArray[i];
  2528. while (cookie.charAt(0)==' ')
  2529. cookie = cookie.substring(1,cookie.length);
  2530. if (cookie.indexOf(nameEQ) == 0)
  2531. return cookie.substring(nameEQ.length,cookie.length);
  2532. }
  2533. return null;
  2534. }