// ==UserScript==
// @name PS Facebook Mafia Wars Autoplayer (MWAP)
// @namespace mafiawars
// @description Autoplayer for the facebook application - Mafia Wars
// @include /^https?://(facebook\.mafiawars|mwfb)(\.zynga)?\.com/mwfb/remote/html_server\.php.*?/
// @include /^https?://(facebook\.mafiawars|mwfb)(\.zynga)?\.com/\?skip_req_frame=1&mwcom=1.*?/
// @include /^https?://apps(\.new)?\.facebook\.com/inthemafia/.*?/
// @include /^https?://www.facebook.com/(connect/uiserver|dialog/(feed|apprequests)).*?/
// @exclude /^https?://(facebook.mafiawars|mwfb)(\.zynga)?\.com/.*?(sk_updater\.php|\#|iframe_proxy\.php).*?/
// @version 2.0.44
// ==/UserScript==
// to have the job array update, set to same as current version releasing.
// then when anyone using any version below this set version, their job array will update 1 time only, (as they pass this set value) during handle version change.
// job array automatically updates if length changes !
var updtJobArrayIfWasBelow=42;
var SCRIPT = {
version: '2.0.44',
name: 'inthemafia',
appID: 'app10979261223',
appNo: '10979261223',
presentationurl: 'http://www.playerscripts.co.uk',
url: 'http://cdn.playerscripts.co.uk/rokdownloads/ps_facebook_mafia_wars_a.user.js',
metadata: 'http://cdn.playerscripts.co.uk/rokdownloads/mwapmeta.js',
controller: 'remote/html_server.php?xw_controller=',
action: '&xw_action=',
city: '&xw_city=',
opponent: '&opponent_id=',
user: '&user_id=',
/*
pages for parsing with logJSONResponse(), added as final_wrapper sibling; we use two pages to prevent interference */
ajaxIDSync: 'ajax_sync', // page for Autoplay ('synchronous')
ajaxIDAsync: 'ajax_async', // page for asynchronous clicking (quickbanking, profile icecheck etc)
UseDebugConsole : false,
UseDebugCategory : 0,
PSMWAP_homePath: 'http://www.playerscripts.co.uk/',
PSMWAP_imagePath: 'http://cdn.playerscripts.co.uk/images/mwap_graphics/setlog/mwap_int_web_',
PSMWAP_iconPath: 'http://cdn.playerscripts.co.uk/images/mwap_graphics/icons/',
PSMWAP_imageBPath: 'http://cdn.playerscripts.co.uk/images/banners/'
};
// Set the storage path
var GMSTORAGE_PATH = 'GM_'+ SCRIPT.appID+'_';
if(/facebook\.com/.test(window.location.href)){
var profElt = xpathFirst('//ul[@id="pageNav"]//a[@accesskey="6"]');
if(profElt && profElt.getAttribute('href').match(/id=(\w+)/)){ GMSTORAGE_PATH = GMSTORAGE_PATH + RegExp.$1; }
var profLink = xpathFirst('//div[contains(@id,"div_story_") and contains(@data-ft,"actrs")]');
if(profLink && profLink.getAttribute('data-ft').match(/"actrs":"(\w+)/)){ GMSTORAGE_PATH = GMSTORAGE_PATH + RegExp.$1; }
}
if(/mwfb\.zynga\.com/.test(window.location.href)){
var docUrl = document.location.href;
if(docUrl.match(/sf_xw_user_id=(\w+)/)){ GMSTORAGE_PATH = GMSTORAGE_PATH + RegExp.$1; }
}
var gvar=function(){};
function GM_ApiBrowserCheck(){
var needApiUpgrade=false;
if(typeof(unsafeWindow)=='undefined'){
var div = document.createElement("div");
div.setAttribute("onclick", "return window;");
unsafeWindow = div.onclick();
}
if(typeof(GM_log)=='undefined'){ GM_log=function(msg){ try { unsafeWindow.console.log('GM_log: '+msg); } catch(err){} }; }
if(typeof(GM_setValue)!='undefined'){
try {
var gsv=GM_setValue.toString();
if(gsv.indexOf('staticArgs')>0){gvar.isGreaseMonkey=true;GM_log('GreaseMonkey Api detected...'); }
else if(/not\s+supported/.test(gsv)){ needApiUpgrade=true; isBuggedChrome=true; GM_log('Bugged Chrome GM Api detected...'); }
} catch(err){ gvar.isGreaseMonkey=true; needApiUpgrade = false; GM_log('GreaseMonkey Api detected...'); }
} else { needApiUpgrade=true; GM_log('No GM Api detected...'); }
if(needApiUpgrade){
GM_log('Try to recreate needed GM Api...');
GM_log('Using ['+ GMSTORAGE_PATH +'] as storage path.');
var ws=null; try { ws=typeof(unsafeWindow.localStorage); unsafeWindow.localStorage.length; } catch(err){ ws=null; } // Catch Security error
if(ws=='object'){
GM_log('Using localStorage for GM Api.');
GM_getValue=function(name,defValue){ var value=unsafeWindow.localStorage.getItem(GMSTORAGE_PATH+name); if(value==null){ if(defValue==null){ return 'undefined'; } else { return defValue; } } else { switch(value.substr(0,2)){ case 'S]': return value.substr(2); case 'N]': return parseInt(value.substr(2)); case 'B]': return value.substr(2)=='true'; } } return value; };
GM_setValue=function(name,value){ switch (typeof(value)){ case 'string': unsafeWindow.localStorage.setItem(GMSTORAGE_PATH+name,'S]'+value); break; case 'number': if(value.toString().indexOf('.')<0){ unsafeWindow.localStorage.setItem(GMSTORAGE_PATH+name,'N]'+value); } break; case 'boolean': unsafeWindow.localStorage.setItem(GMSTORAGE_PATH+name,'B]'+value); break; } };
GM_deleteValue=function(name){ unsafeWindow.localStorage.removeItem(GMSTORAGE_PATH+name); };
} else if(!gvar.isOpera || typeof(GM_setValue)=='undefined'){
GM_log('Using temporarilyStorage for GM Api.'); gvar.temporarilyStorage=new Array();
GM_getValue=function(name,defValue){ if(typeof(gvar.temporarilyStorage[GMSTORAGE_PATH+name])=='undefined'){ return defValue; } else { return gvar.temporarilyStorage[GMSTORAGE_PATH+name]; } };
GM_setValue=function(name,value){ switch (typeof(value)){ case "string": case "boolean": case "number": gvar.temporarilyStorage[GMSTORAGE_PATH+name]=value; } };
GM_deleteValue=function(name){ delete gvar.temporarilyStorage[GMSTORAGE_PATH+name]; };
}
if(typeof(GM_openInTab)=='undefined'){ GM_openInTab=function(url){ unsafeWindow.open(url,""); }; }
if((typeof(GM_registerMenuCommand)=='undefined') || gvar.isBuggedChrome){ GM_registerMenuCommand=function(name,cmd){ GM_log("Notice: GM_registerMenuCommand is not supported."); }; } // Dummy
if(!gvar.isOpera || typeof(GM_xmlhttpRequest)=='undefined'){
GM_log('Using XMLHttpRequest for GM Api.');
GM_xmlhttpRequest=function(obj){
var request=new XMLHttpRequest();
request.onreadystatechange=function(){ if(obj.onreadystatechange){ obj.onreadystatechange(request); } if(request.readyState==4 && obj.onload){ obj.onload(request); } };
request.onerror=function(){ if(obj.onerror){ obj.onerror(request); } };
try { request.open(obj.method,obj.url,true); } catch(err){ if(obj.onerror){ obj.onerror( {readyState:4,responseHeaders:'',responseText:'',responseXML:'',status:403,statusText:'Forbidden'} ); }; return; }
if(obj.headers){ for(name in obj.headers){ request.setRequestHeader(name,obj.headers[name]); } }
request.send(obj.data); return request;
}; } }
}
GM_ApiBrowserCheck();
if(gvar.isGreaseMonkey) var $ = unsafeWindow.jQuery;
function receiver(e){
//{"source":"mwap.me.uk","version":"1240","allowAll":"true","key":"mwapProKey"}
var messageSource = e.origin;
var messageContent = e.data;
//for testing purposes only
//messageContent = "myStringisnotbase64";
if(messageSource == 'http://mwap.me.uk'){
GM_setValue('checkMWAPString', messageContent);
var dataString = decode64(messageContent);
if(IsJsonString(dataString)){
var dataCollector = JSON.parse(dataString);
var strMWAPSource = dataCollector.source;
var strMWAPVersion = dataCollector.version;
var strMWAPPermissions = dataCollector.allowAll;
var strMWAPKey = dataCollector.key;
if(strMWAPKey == 'mwapProKey' && messageSource.indexOf(strMWAPSource) !=-1){
//colorDEBUG('valid eData: '+dataString+' from '+messageSource);
GM_setValue('checkMWAP', strMWAPKey);
GM_setValue('checkMWAPPermissions', (strMWAPPermissions=="true"?1:0));
GM_setValue('checkMWAPVersion', strMWAPVersion);
GM_setValue('checkMWAPOK', 1);
GM_setValue('checkMWAPSum', parseInt(strMWAPVersion));
}
} else {
GM_setValue('checkMWAPString', 'invalidmessage');
//colorDEBUG('invalid eData: '+dataString+' from '+messageSource, cre);
GM_setValue('checkMWAP', 'rubbish');
GM_setValue('checkMWAPPermissions', 0);
GM_setValue('checkMWAPVersion', 'rubbish');
GM_setValue('checkMWAPOK', 0);
GM_setValue('checkMWAPSum', 9999-parseInt(strMWAPVersion));
}
}
}
function mwapValidation(){
//for testing purposes : return 0 -> returns always invalid
// return 0;
//
if(IsJsonString(decode64(GM_getValue('checkMWAPString', '')))){
var checkMWAP = JSON.parse(decode64(GM_getValue('checkMWAPString', '')));
//colorDEBUG(JSON.stringify(checkMWAP));
var strMWAPKey = GM_getValue('checkMWAP', '');
var strMWAPPermissions = GM_getValue('checkMWAPPermissions', 0);
var strMWAPVersion = GM_getValue('checkMWAPVersion', '');
var checkMWAPOK = GM_getValue('checkMWAPOK', 0);
//colorDEBUG('mwapValidation: '+checkMWAP.key+'-'+strMWAPKey+' / '+ (checkMWAP.allowAll=="true"?1:0)+'-'+strMWAPPermissions+' / '+ checkMWAPOK);
if(checkMWAP.key==strMWAPKey && (checkMWAP.allowAll=="true"?1:0)==strMWAPPermissions && strMWAPPermissions && checkMWAPOK){
//colorDEBUG('mwapValidation check: OK', cli);
return parseInt(strMWAPVersion);
}
}
//colorDEBUG('mwapValidation check: NOK', cre);
return 0;
}
window.addEventListener('message', receiver, false);
function postSize(e){
if(!gvar.isGreaseMonkey) return;
try{
var target = parent.postMessage ? parent : (parent.document.postMessage ? parent.document : undefined);
if(typeof target != "undefined" && document.getElementById("mainDiv")) {
var divSize = parseInt(document.getElementById("mainDiv").offsetHeight)+200;
target.postMessage(divSize, "*"); //change this star to your domain for more security
}
} catch (postError){ alert('Yeah, we already know by now you hate chrome !'); }
}
function track_Analytics(){
var newScript = 'try { var pageTracker = _gat._getTracker("UA-3078135-23"); pageTracker._trackPageview(); } catch(err){ }';
makeElement('script', document.getElementsByTagName('head')[0], {'type':'text/javascript'}).appendChild(document.createTextNode(newScript));
}
function build_Analytics(){
function GM_wait(){
if(typeof unsafeWindow._gat == 'undefined'){ window.setTimeout(GM_wait,350); }
else { track_Analytics(); }
}
if(!document.getElementById('mwapAnalytics')){
var gaJsHost = (('https:' == document.location.protocol) ? 'https://ssl.' : 'http://www.');
var newScript = gaJsHost+'google-analytics.com/ga.js';
var extElt = makeElement('script', document.getElementsByTagName('head')[0], {'id':'mwapAnalytics', 'type':'text/javascript'});
extElt.src = newScript;
extElt.id = 'mwapAnalytics';
GM_wait();
}
}
build_Analytics();
// Handle Publishing (check for FB publishing)
function checkInPublishPopup(){
if(xpathFirst('//div[contains(@class,"aid_'+ SCRIPT.appNo +'")]') &&
(/connect\/uiserver/.test(window.location.href) || /dialog\/apprequests/.test(window.location.href) || /dialog\/feed/.test(window.location.href))
){
setGMTime('postTimer', '00:00:06');
window.setTimeout(handlePublishing, 2500);
return true;
}
return false;
}
function fetchPubOptions(){
copyMWValues(['isRunning','autoGlobalPublishing','autoIcePublish']);
}
// Handle Free Gift Requests (check for Free Gift Page)
function checkInRequestsPopup(){
if(xpathFirst('//div[@id="mfs_container"]'))
{
setGMTime('requestTimer', '00:15');
window.setTimeout(handleRequests, 2500);
return true;
}
return false;
}
function checkLoadIframe(){
if(/apps.facebook.com.inthemafia$/.test(document.URL)){ window.location.href = 'http://facebook.mafiawars.com/mwfb/index.php?skip_req_frame=1&mwcom=1';
} else if(/apps.facebook.com.inthemafia/.test(document.URL)){
for(var i=0;i
1){ addToLog('info Icon', this.icon+' '+ this.name+' is set to keep above '+ this.floor+'.'); }
}
// Log any change to the ceiling.
if(this.ceiling != GM_getValue(this.lastCeiling)){
GM_setValue(this.lastCeiling, this.ceiling);
if(this.ceiling > this.floor){ addToLog('info Icon', this.icon+' '+ this.name+' refill level set to '+ this.ceiling+'.'); }
}
// Determine whether spending needs to start or stop.
if(curVal >= this.ceiling && !GM_getValue(this.startFlag)){ GM_setValue(this.startFlag, true); }
else if(curVal <= this.floor && this.ceiling > this.floor && GM_getValue(this.startFlag)){
GM_setValue(this.startFlag, false);
addToLog('info Icon', this.icon+' Refilling '+ this.name+' to '+ this.ceiling+'.');
}
};
//
// Define Player object and methods.
//
// Determine whether two player objects refer to the same player.
Player.prototype.match = function(player){
if(!player) return false;
if(this.id && player.id) return (this.id == player.id);
if(this.profile && this.profile == player.profile) return true;
if(this.profileAttack && this.profileAttack == player.profileAttack) return true;
if(this.attack && this.attack == player.attack) return true;
return false;
};
// Update this player object's properties with the properties of another.
Player.prototype.update = function(player){
if(!this.match(player)) return false;
for (var prop in player){ this[prop] = player[prop]; }
return true;
};
// Constructor for Player objects.
function Player(name){
}
// Get this player list's array of player objects.
PlayerList.prototype.get = function(forceRefresh){
if(this.name && (forceRefresh || !this.list.length)){
// Load the list from storage.
var ids = getSavedList(this.name);
// Convert the ID list (strings) into a player list (objects).
this.list = [];
for (var i = 0, l=ids.length; i < l; ++i){
var p = new Player();
p.id = ids[i];
this.list.push(p);
}
}
return this.list;
};
PlayerList.prototype.set = function(list){
if(list){ this.list = list; }
if(this.name){
// Build an array of player ID's.
var a = [];
for (var i = 0, l=this.list.length; i < l; ++i){
var player = this.list[i];
if(player && player.id){ a.push(player.id); }
}
// Store the list.
setSavedList(this.name, a);
}
};
PlayerList.prototype.add = function(player, max){
if(!player) return false;
// If the player is already in the list, just update it.
var l = this.list.length;
for (var i = 0; i < l; ++i){ if(this.list[i].update(player)){ return false; } }
// No match. Just push it into the array.
this.list.push(player);
// Shorten the array if it has become too large.
if(max > 0){ while (max < this.list.length){ var playerItem = this.list.shift(); } }
return true;
};
PlayerList.prototype.remove = function(player){
if(!player) return false;
// If the player is in the list, remove it.
var l = this.list.length;
for (var i = 0; i < l; ++i){
if(this.list[i].match(player)){
this.list.splice(i, 1);
return true;
}
}
// No match.
return false;
};
PlayerList.prototype.indexOf = function(player){
var l = this.list.length;
for (var i = 0; i < l; i++){ if(this.list[i].match(player)) return i; }
return -1;
};
PlayerList.prototype.debug = function(){
var l = this.list.length;
var str = 'PlayerList name='+ this.name+', length='+ l+'\n';
for (var i = 0; i < l; ++i){
var p = this.list[i];
str += i+': ';
if(p.name) str += ', name='+ p.name;
if(p.level) str += ', level='+ p.level;
if(p.mafia) str += ', mafia='+ p.mafia;
str += '\n';
}
return str;
};
// Constructor for PlayerList objects.
function PlayerList(name){
this.name = name;
this.list = [];
this.get();
}
var lootbagIcon = '
';
var attackIcon = '
';
var defenseIcon = '
';
var omgIcon = '
';
var staminaIcon = '
';
var energyIcon = '
';
var yeahIcon = '
';
var plussignIcon = '
';
var cashIcon = '
';
var cashCubaIcon = '
';
var cashMoscowIcon = '
';
var cashBangkokIcon = '
';
var cashVegasIcon = '
';
var cashItalyIcon = '
';
var cashBrazilIcon = '
';
var mini_Epak_ready = '
';
var mini_Epak_wait = '
';
var healthIcon = '
';
var healOnIcon = '
';
var healOnHoldIcon = '
';
var healOffIcon = '
';
var warningIcon = '
';
var debugIcon = '
';
var chickenIcon = '
';
var hideIcon = '
';
var checkedIcon = '
';
var unCheckedIcon = '
';
var winW = 630, winH = 460;
var bgTabImage = '
';
var noDelay = 0; // No delay on commands
var minDelay = 1000; // Minimum delay on commands
var running; // Is the autoplayer running?
var innerPageElt; // The currently visible inner page
var questBarElt; // The currently visible quest page
var appLayoutElt; // The currently visible content page
var mastheadElt; // Masthead content
var statsrowElt; // statsrow content
var menubarElt; // menubar content
var popupfodderElt; // popupfodder Element
var cashElt; // Cash array of values by city
var healthElt, health; // Health DOM element and value
var maxHealthElt, maxHealth; // Maximum health DOM element and value
var energyElt, energy; // Energy DOM element and value
var maxEnergyElt, maxEnergy; // Maximum energy DOM element and value
var staminaElt, stamina; // Stamina DOM element and value
var maxStaminaElt, maxStamina; // Maximum stamina DOM element and value
var levelElt, level; // Level DOM element and value
var curAttack; // Current Attack stat value
var curDefense; // Current Defense stat value
var curAttackEquip; // Current Attack equip value
var curDefenseEquip; // Current Defense equip value
var prevAttackEquip; // Previous Attack equip value
var prevDefenseEquip; // Previous Defense equip value
var curExpElt, curExp; // Experience DOM element and value
var lvlExpElt, lvlExp; // Level up experience DOM element and value
var energyPackElt, energyPack; // Is an energy pack waiting?
var ptsToNextLevel; // Experience to next level up
var mafia; // Mafia size
var stats; // Skill points
var city; // Current city (0=New York, 1=Cuba, 2=Moscow)
var skipStaminaSpend = false; // Skip stamina actions for now?
var Miss_Name; // mission Name holder
var Miss_Name_is;
var Miss_ID; // a holder to move the mission tag around
var Miss_Slot; // a holder to move around the mission slot 0-3
var MyMafiaJobs; // name to use in misssions
var Miss_Energy;
var Miss_Nrg_Req = 0;
var Miss_Stamina;
var Miss_Stam_Req = 0;
var Miss_Pay_Exp;
var Miss_Pay_Cash;
var missionsDelays = 2500;
var clickAction; // Action being attempted with click simulation
var clickContext; // Context for clickAction
var modificationTimer; // Timer used to wait for content changes
var ajaxAction; // Action being attempted with do_ajax (asynchronous)
var ajaxContext; // Context for ajaxContext
var ajaxHandling = false;
var popupTimer; // setInterval timer for handlePopups()
var helpWar = false; // Helping a friend's war?
var idle = true; // Is the script currently idle?
var lastOpponent; // Last opponent fought (object)
var suspendBank = false; // Suspend banking for a while
var skipJobs = false; // Skip doing jobs for a while
var jobOptimizeOn = false; // Is job optimizing flag
var newStaminaMode; // New stamina mode for random fighting
var jobid;
var mmis_time = '00:00:30';
var endBoss;
var xw_sig;
var xw_user;
var xw_user_id;
var cbr = '#FF800D'; // Brown
var cye = '#FFD700'; // Yellow Gold
var cy = '#FFFF00'; // Yellow
var cfu = '#FF00FF'; // Fuchsia
var cre = '#FF0000'; // Red
var csi = '#C0C0C0'; // Silver
var cds = '#808080'; // Dark Silver - Gray
var cov = '#808000'; // Olive
var cpu = '#800080'; // Purple
var cma = '#800000'; // Maroon
var caq = '#00FFFF'; // Aqua
var cli = '#00FF00'; // Lime
var cte = '#008080'; // Teal
var cgr = '#008000'; // Green
var cbl = '#6495ED'; // Blue
var can = '#000080'; // Navy
var cbk = '#000000'; // Black
var cwt = '#FFFFFF'; // White
var color;
var line;
var new_header = xpathFirst('//div[@class="header_top_row"]') ? true : false; // checks for new header
var currentBrazilDistrict = 0;
var oldBrazilDistrict = 0 ;
var previousBrazilJob = null;
var previousBrazilJobMastery = null;
var boardLastStamina = 0;
var boardLastPtsToNextLevel = 0;
var claimLevelUpBonus = true;
var inClanBattle = false;
var inSafehouse = false;
var slotSpins = 0; // Number of remaining slot spins..
var slotBonus = 0; // Bonus level for slots..
var isBossRunning = false;
var current_boss_id = 0; //Current BossID for family Boss Fights
var current_boss_index = 0;
var current_boss_name = '';
var clicks = 1;
var isProfileSearching = false;
var profileCount=0;
var searchTimer;
if(!initialized && !checkInPublishPopup() && !checkInRequestsPopup() && !checkLoadIframe() &&
( (/inthemafia/.test(document.referrer) || /facebook\.mafiawars\.com/.test(window.location.href) || /facebook\.mafiawars\.zynga\.com/.test(window.location.href)) ||
(/m\.mafiawars\.com/.test(document.referrer) || /iframe/.test(window.location.href) )
)
){
setFBParams();
var settingsOpen = false;
var statsOpen = false;
var scratchpad = document.createElement('textarea');
var defaultClans = ['{', '[', '(', '<', '\u25C4', '?', '\u2122', '\u03A8', '\u039E'];
var defaultPassPatterns = ['LOST', 'punched', 'Whacked', 'you were robbed', 'ticket'];
var defaultFailPatterns = ['WON','heal','help','properties','upgraded'];
var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
var debug = isGMChecked('enableDebug');
var filter = isGMChecked('filterLog');
// Regular expression for cash matching.
var REGEX_CASH = /([A-Z]*?\$|\u00A2)([\d,]*\d)/;
// Define how stamina can be used.
var STAMINA_HOW_FIGHT_RANDOM = 0; // Random fighting.
var STAMINA_HOW_FIGHT_LIST = 1; // List fighting.
var STAMINA_HOW_HITMAN = 2; // Hitman.
var STAMINA_HOW_ROBBING = 3; // Robbing
var STAMINA_HOW_AUTOHITLIST = 4; // Place bounties.
var STAMINA_HOW_RANDOM = 5; // Random spending of stamina in random cities.
var STAMINA_HOW_FIGHTROB = 6; // Fight then Rob random opponents.
var STAMINA_HOW_ROBFIGHT = 7; // Rob then fight, switch to fighting when falls below robFightStaminaFloor.
// var STAMINA_HOW_LVJOBFIGHT = 8; // do lv job Fights.
var STAMINA_HOW_BATTLE = 99;
var staminaSpendChoices = [];
staminaSpendChoices[STAMINA_HOW_FIGHT_RANDOM] = 'Fight random opponents';
staminaSpendChoices[STAMINA_HOW_FIGHT_LIST] = 'Fight specific opponents';
staminaSpendChoices[STAMINA_HOW_HITMAN] = 'Collect hitlist bounties';
staminaSpendChoices[STAMINA_HOW_ROBBING] = 'Rob random opponents';
staminaSpendChoices[STAMINA_HOW_AUTOHITLIST] = 'Place hitlist bounties';
staminaSpendChoices[STAMINA_HOW_RANDOM] = 'Spend stamina randomly';
staminaSpendChoices[STAMINA_HOW_FIGHTROB] = 'Fight then Rob';
staminaSpendChoices[STAMINA_HOW_ROBFIGHT] = 'Rob then Fight';
// staminaSpendChoices[STAMINA_HOW_LVJOBFIGHT] = 'Do LV Job Fights';
var randomSpendChoices = [];
randomSpendChoices[STAMINA_HOW_FIGHT_RANDOM] = 'Fight random';
randomSpendChoices[STAMINA_HOW_FIGHT_LIST] = 'Fight specific';
randomSpendChoices[STAMINA_HOW_HITMAN] = 'Collect bounties';
randomSpendChoices[STAMINA_HOW_ROBBING] = 'Rob random';
// Rivals Lists
var fightRivalsModes = ['Random Opponents','Mafia You Attacked','Your Attackers','Your Rivals','Family Rivals'];
// Define Bounty Selection options
var BOUNTY_SHORTEST_TIME = 0; // Select qualified bounties with shortest time.
var BOUNTY_LONGEST_TIME = 1; // Select qualified bounties with longest time on the hitlist.
var BOUNTY_HIGHEST_BOUNTY = 2; // Select qualified bounties with the highest bounty.
var BOUNTY_EXACT_AMOUNT = 3; // Select qualified bounties with exact dollar amount.
var BOUNTY_RANDOM = 4; // Select random qualified bounty.
var bountySelectionChoices = [];
bountySelectionChoices[BOUNTY_SHORTEST_TIME] = 'Shortest time';
bountySelectionChoices[BOUNTY_LONGEST_TIME] = 'Longest time';
bountySelectionChoices[BOUNTY_HIGHEST_BOUNTY] = 'Highest bounty';
bountySelectionChoices[BOUNTY_EXACT_AMOUNT] = 'Exact dollar amount';
bountySelectionChoices[BOUNTY_RANDOM] = 'No preference (random)';
// Define war modes
var WAR_HOW_RANDOM = 0; // Random war.
var WAR_HOW_LIST = 1; // List warring
var warModeChoices = ['War a random Enemy', 'War Enemies from a list'];
// Define AutoStat allocation mode
var AUTOSTAT_TARGET = 0;
var AUTOSTAT_RATIO_LEVEL = 1;
var AUTOSTAT_RATIO_ATTACK = 2;
var AUTOSTAT_RATIO_DEFENSE = 3;
var AUTOSTAT_RATIO_HEALTH = 4;
var AUTOSTAT_RATIO_ENERGY = 5;
var AUTOSTAT_RATIO_STAMINA = 6;
// Auto Stat mode arrays
var autoStatDescrips = ['Level', 'Attack', 'Defense', 'Health', 'Energy', 'Stamina'];
var autoStatModes = ['autoStatAttackMode', 'autoStatDefenseMode', 'autoStatHealthMode', 'autoStatEnergyMode', 'autoStatStaminaMode'];
var autoStatPrios = ['autoStatAttackPrio', 'autoStatDefensePrio', 'autoStatHealthPrio', 'autoStatEnergyPrio', 'autoStatStaminaPrio'];
var autoStatFallbacks = ['autoStatAttackFallback', 'autoStatDefenseFallback', 'autoStatHealthFallback', 'autoStatEnergyFallback', 'autoStatStaminaFallback'];
var autoStatBases = ['autoStatAttackBase', 'autoStatDefenseBase', 'autoStatHealthBase', 'autoStatEnergyBase', 'autoStatStaminaBase'];
var autoStatRatios = ['autoStatAttackRatio', 'autoStatDefenseRatio', 'autoStatHealthRatio', 'autoStatEnergyRatio', 'autoStatStaminaRatio'];
// Number Scheme
var SCHEME_PERCENT = 0;
var SCHEME_POINTS = 1;
var numberSchemes = ['percent','points'];
// Burn constants
var BURN_ENERGY = 0;
var BURN_STAMINA = 1;
var burnModes = ['Energy','Stamina'];
var fastRobModes = ['crawling','slow','normal','fast','rx6'];
// Array of lottery bonus items
var autoLottoBonusList = ['A random collection item', 'A free ticket', '+5 stamina points', 'two free lotto tickets', '+20 energy points', '20 Loyalty points'];
// Stat Ordinal constants
var ATTACK_STAT = 0;
var DEFENSE_STAT = 1;
var HEALTH_STAT = 2;
var ENERGY_STAT = 3;
var STAMINA_STAT = 4;
// Define city variables.
var NY = 0;
var CUBA = 1;
var MOSCOW = 2;
var BANGKOK = 3;
var LV = 4;
var ITALY = 5;
var BRAZIL = 6;
var CHICAGO = 7;
var ACTIVE_CITY = 8;
var RANDOM_CITY = 9;
// Constants to access city attributes
var CITY_NAME = 0;
var CITY_ALIAS = 1;
var CITY_SIDES = 2;
var CITY_SIDE_NAME = 3;
var CITY_CASH = 4;
var CITY_LEVEL = 5;
var CITY_CASH_ICON = 6;
var CITY_CASH_CSS = 7;
var CITY_AUTOBANK = 8;
var CITY_BANKCONFG = 9;
var CITY_CASH_SYMBOL = 10;
var CITY_ALLIANCE = 11;
var CITY_NUMBER = 12;
// Constants for accessing mission array
var MISSION_NAME = 0; // 7
var MISSION_ENERGY = 1; // 5
var MISSION_NUMBER = 2; // 4
var MISSION_TAB = 3; // 2
var MISSION_CITY = 4; // 1
var MISSION_XP = 5; // 6
var MISSION_TABPATH = 6; // 3 // (0 energy,1 stamina,2 Social)
var MISSION_NODE_LV = 7; // 0 // Mini map, Node number for new cities
var MISSION_RATIO = 8; // 8
var MISSION_EOL = 9; // 9
// Constants for accessing mafia mission array
var MMiss_ID = 0; //
var Mmiss_Slot = 1; //
var Mmiss_Percent_Fin = 2; //
var Mmiss_Nrg_Use = 3; //
var Mmiss_Stam_Use = 4; //
var Mmiss_XP = 5; //
var Mmiss_Pays = 6; //
var Mmiss_Ratio = 7; //
var Mmiss_Onr = 8; //
var Mmiss_Onr_ID = 9; //
var Mmiss_ONR_FB = 10; //
var Mmiss_Timer = 11; //
var Mmiss_Name = 12; //
// NY Boss Fights
var boss_AGOSTINO = 4
// Define city variables.
var AllowNY = true ;
var AllowCuba = false;
var AllowMoscow = false;
var AllowBangkok = false;
var AllowLV = true ;
var AllowItaly = true ;
var AllowBrazil = true ;
var AllowChicago = true;
// for mafia missions
var MMiss = new Array ();
if(AllowNY) var cityNY = 'New York'; else var cityNY = 'Closed';
if(AllowCuba) var cityCuba = 'Cuba'; else var cityCuba = 'Closed';
if(AllowMoscow) var cityMoscow = 'Moscow'; else var cityMoscow = 'Closed';
if(AllowBangkok) var cityBangkok = 'Bangkok'; else var cityBangkok = 'Closed';
if(AllowLV) var cityLV = 'Las Vegas'; else var cityLV = 'Closed';
if(AllowItaly) var cityItaly = 'Italy'; else var cityItaly = 'Closed';
if(AllowBrazil) var cityBrazil = 'Brazil'; else var cityBrazil = 'Closed';
if(AllowChicago) var cityChicago = 'Chicago'; else var cityChicago = 'Closed';
// Add city variables in this format
// Name, Alias, Sides (if any), Cash, Level Req, Icon, Icon CSS, Autobank config, Min cash config, Sell Crates config, Cash Symbol, Alliance Point Threshold, MW City Number
var cities = new Array(
[ cityNY , 'nyc' , [], 'sideNY', undefined, 0, cashIcon, 'cash Icon', 'autoBank', 'bankConfig', '$', 0, 1]
,[ cityCuba , 'cuba' , [], 'sideCuba', undefined, 35, cashCubaIcon, 'cashCuba Icon', 'autoBankCuba', 'bankConfigCuba', 'C$', 0, 2]
,[ cityMoscow , 'moscow' , [], 'sideMoscow', undefined, 70, cashMoscowIcon, 'cashMoscow Icon', 'autoBankMoscow', 'bankConfigMoscow', 'R$', 0, 3]
,[ cityBangkok , 'bangkok' , ['Yakuza','Triad'], 'sideBangkok', undefined, 15, cashBangkokIcon, 'cashBangkok Icon', 'autoBankBangkok', 'bankConfigBangkok', 'B$', 50, 4]
,[ cityLV , 'vegas' , [], 'sideVegas', undefined, 18, cashVegasIcon, 'cashVegas Icon', 'autoBankVegas', 'bankConfigVegas', 'V$', 0, 5]
,[ cityItaly , 'italy' , [], 'sideItaly', undefined, 5, cashItalyIcon, 'cashItaly Icon', 'autoBankItaly', 'bankConfigItaly', 'L$', 0, 6]
,[ cityBrazil , 'brazil' , [], 'sideBrazil', undefined, 5, cashBrazilIcon, 'cashBrazil Icon', 'autoBankBrazil', 'bankConfigBrazil', 'BRL$', 0, 7]
,[ cityChicago , 'chicago' , [], 'sideChicago', undefined, 5, cashIcon, 'cash Icon', 'autoBankChicago', 'bankConfigChicago', '\u00A2', 0, 8]
);
var fightExp=0;
var fightWins=1;
var cashWins=2;
var fightLosses=3;
var cashLosses=4;
var passivecashWins=5;
var passivecashLosses=6;
var cityStats = new Array(
['fightExpNY','fightWinsNY','cashWinsNY','fightLossesNY','fightLoss$NY','passivecashWinsNY','passivecashLossesNY'],
['fightExpCuba','fightWinsCuba','cashWinsCuba','fightLossesCuba','fightLoss$Cuba','passivecashWinsCuba','passivecashLossesCuba'],
['fightExpMoscow','fightWinsMoscow','cashWinsMoscow','fightLossesMoscow','fightLoss$Moscow','passivecashWinsMoscow','passivecashLossesMoscow'],
['fightExpBangkok','fightWinsBangkok','cashWinsBangkok','fightLossesBangkok','fightLoss$Bangkok','passivecashWinsBangkok','passivecashLossesBangkok'],
['fightExpVegas','fightWinsVegas','cashWinsVegas','fightLossesVegas','fightLoss$Vegas','passivecashWinsVegas','passivecashLossesVegas'],
['fightExpItaly','fightWinsItaly','cashWinsItaly','fightLossesItaly','fightLoss$Italy','passivecashWinsVegas','passivecashLossesVegas'],
['fightExpBrazil','fightWinsBrazil','cashWinsBrazil','fightLossesBrazil','fightLoss$Brazil','passivecashWinsBrazil','passivecashLossesBrazil'],
['fightExpChicago','fightWinsChicago','cashWinsChicago','fightLossesChicago','fightLoss$Chicago','passivecashWinsChicago','passivecashLossesChicago']
);
if(!AllowNY) cities[NY][CITY_LEVEL] = 32500;
if(!AllowCuba) cities[CUBA][CITY_LEVEL] = 32500;
if(!AllowMoscow) cities[MOSCOW][CITY_LEVEL] = 32500;
if(!AllowBangkok) cities[BANGKOK][CITY_LEVEL] = 32500;
if(!AllowLV) cities[LV][CITY_LEVEL] = 32500;
if(!AllowItaly) cities[ITALY][CITY_LEVEL] = 32500;
if(!AllowBrazil) cities[BRAZIL][CITY_LEVEL] = 32500;
if(!AllowChicago) cities[CHICAGO][CITY_LEVEL] = 32500;
var locations = [cityNY, cityCuba, cityMoscow, cityBangkok, cityLV, cityItaly, cityBrazil, cityChicago, 'Active City'];
var fightLocations = [cityNY, cityCuba, cityMoscow, cityBangkok, cityLV, cityItaly, cityBrazil, cityChicago, 'Active City', 'Random City'];
var randomLocations = [cityNY, cityCuba, cityMoscow, cityBangkok, cityLV, cityItaly, cityBrazil, cityChicago ];
//autoUpgrade NY Buildings
var autoUpgradeNYBuildings = new Array(
['Flophouse', 2],['Pawnshop', 3],['Tenement', 4],['Warehouse', 5],['Restaurant', 6],['Dockyard', 7],['Office Park', 8],['Uptown Hotel', 9],['Mega Casino',10]);
//autoUpgrade NY Choices
var autoUpgradeNYChoices = new Array(
['Don\'t Upgrade' , 0]
, ['Upgrade to Level 25', 25]
, ['Upgrade to Level 50', 50]
, ['Upgrade to Level 75', 75]
, ['Upgrade to Level 100', 100]
, ['Upgrade to Level 150', 150]
, ['Upgrade to Level 200', 200]
, ['Upgrade to Level 250', 250]
, ['Upgrade to Level 500', 500]
, ['Upgrade to Level 750', 750]
, ['Upgrade to Level 1000', 1000]
, ['Upgrade to Level 1250', 1250]
, ['Upgrade to Level 1500', 1500]
, ['Upgrade to Level 1750', 1750]
, ['Upgrade to Level 2000', 2000]
, ['Upgrade to Level 2250', 2250]
, ['Upgrade to Level 2500', 2500]
, ['Upgrade to Level 2750', 2750]
, ['Upgrade to Level 3000', 3000]
, ['Upgrade to Level 3500', 3500]
, ['Upgrade to Level 4000', 4000]
, ['Upgrade to Level 4500', 4500]
, ['Upgrade to Level 5000', 5000]
, ['Upgrade to Level 10000', 10000]
, ['Upgrade to Level 15000', 15000]
, ['Upgrade to Level 20000', 20000]
);
//var allyFaction = '';
var quickBankFail = false;
var ctTitle = 0;
var ctGMId = 1;
var ctText = 2;
var ctArray = 3;
var ctPropType = 4;
var ctPropId = 5;
var ctPropTimer = 6;
var ctPropCity = 7;
var ctPropName = 8;
var ctPropNamePlus = 9;
var cityProperties = new Array(
// Chop Shop
['Check this to build a car every 18 hours','buildCar','Build Car',
[
['Random Common Car', 1, 'Requires 10 car parts'],
['Sonic Five', 25, 'Requires 12 car parts | 32 attack, 30 defense'],
['Midnight', 39, 'Requires 10 car parts, 1 special part | 28 attack, 33 defense, +1 defense'],
['Random Rare Car', 2, 'Requires 25 car parts'],
['General Ulysses', 26, 'Requires 28 car parts| 38 attack, 28 defense'],
['Palermo Luxury', 40, 'Requires 20 car parts, 2 special parts | 36 attack, 35 defense, +5 health'],
['Tasmanian', 3, 'Requires 30 car parts | 36 attack, 34 defense'],
['Sleek', 41, 'Requires 30 car parts, 3 special parts | 35 attack, 37 defense, +1 attack'],
['CM Santiago R10', 4, 'Requires 30 car parts, 2 cuban car parts | 42 attack, 30 defense'],
['Rebel 2', 5, 'Requires 45 car parts, 1 bulletproof glass | 40 attack, 45 defense, +6 stamina'],
['Sirroco 9Z', 11, 'Requires 48 car parts | 46 attack, 15 defense'],
['Russian Dazatz 45', 6, 'Requires 50 car parts, 2 russian car parts | 18 attack, 46 defense'],
['Solar Flare', 7, 'Requires 65 car parts, 1 solar panel | 34 attack, 34 defense, +6 energy'],
['Andresen 420si', 12, 'Requires 68 car parts | 41 attack, 43 defense'],
['Thai XS Max', 8, 'Requires 75 car parts, 2 thai car parts | 45 attack, 35 defense'],
['Trio Napoli', 9, 'Requires 95 car parts | 47 attack, 23 defense'],
['Red Angel', 10, 'Requires 115 car parts | 16 attack, 49 defense'],
['Mugati Sport', 13, 'Requires 135 car parts, 1 high tech car part | 35 attack, 51 defense, +3 attack'],
['Hunter \'Spy\' XS', 14, 'Requires 155 car parts, 2 high tech car parts | 52 attack, 29 defense, +3 defense'],
['Day Rider 2K', 27, 'Requires 175 car parts, 1 suspension coil | 45 attack, 50 defense, +1 attack, +1 defense'],
['Sportster', 42, 'Requires 185 car parts, 10 special parts | 52 attack, 46 defense, +3 energy, +3 stamina'],
['Extended Cab 640', 43, 'Requires 200 car parts, 15 special parts | 53 attack, 55 defense, +3 skill points']
], 1, 11, 'buildCarTimer', NY, 'Chop Shop', 'Chop+Shop'
]
// Weapons Depot
,['Check this to build a weapon every 18 hours','buildWeapon','Build Weapon',
[
['Blazing Santoku', 49, 'Requires 3 weapon parts and 1 special part | 35 attack, 18 defense, +1 attack'],
['Random Common Weapon', 15, 'Requires 3 weapon parts'],
['Double Dare', 50, 'Requires 10 weapon parts and 1 special part | 20 attack, 36 defense, +1 defense'],
['Random Uncommon Weapon', 16, 'Requires 9 weapon parts'],
['Random Rare Weapon', 17, 'Requires 15 weapon parts'],
['"Need a Jump?"', 51, 'Requires 18 weapon parts and 2 special part | 38 attack, 38 defense, +1 energy'],
['Ninja Sai', 18, 'Requires 24 weapon parts | 30 attack, 40 defense'],
['First Blood', 19, 'Requires 30 weapon parts and 1 explosive arrow | 49 attack, 13 defense'],
['Ultrasonic Gun', 20, 'Requires 36 weapon parts and 1 sonic emitter | 22 attack, 48 defense'],
['Lazer Guided RPG', 21, 'Requires 63 weapon parts and 1 laser rangefinder | 37 attack, 42 defense'],
['Robber\'s Utility Belt', 22, 'Requires 72 weapon parts, 1 boomerang and 1 grapple | 33 attack, 41 defense, +6 stamina'],
['Railgun', 23, 'Requires 81 weapon parts and 1 railgun barrel | 51 attack, 24 defense, +5 attack'],
['Plasma Rifle', 24, 'Requires 105 weapon parts and 1 portable fusion reactor | 40 attack, 47 defense, +5 defense'],
['Dirty Trick', 44, 'Requires 110 weapon parts and 3 special parts | 45 attack, 49 defense, +5 health, +2 stamina'],
['Electric Prod', 45, 'Requires 115 weapon parts and 6 special parts | 50 attack, 50 defense, +5 health, +2 energy'],
['Hack Blade', 46, 'Requires 120 weapon parts and 9 special parts | 45 attack, 51 defense, +6 defense'],
['Stun Knuckles', 47, 'Requires 125 weapon parts and 12 special parts | 52 attack, 48 defense, +6 attack'],
['Wasper Knife', 48, 'Requires 130 weapon parts and 15 special parts | 51 attack, 51 defense, +4 skill points']
], 1, 12, 'buildWeaponTimer', NY, 'Weapons Depot', 'Weapons+Depot'
]
// Armory
,['Check this to build an Armor every 18 hours','buildArmor','Build Armor',
[
['Welding Mask', 54, 'Requires 2 armor parts and 1 special part | 30 attack, 25 defense, +1 attack'],
['Random Common Armor', 29, 'Requires 2 armor parts'],
['Random Uncommon Armor', 30, 'Requires 5 armor parts'],
['Sprinting Shoes', 55, 'Requires 6 armor parts and 1 special part | 25 attack, 32 defense, +1 defense'],
['Random Rare Armor', 31, 'Requires 14 armor parts'],
['Forearm Guard', 56, 'Requires 12 armor parts and 2 special part | 38 attack, 30 defense, +1 stamina'],
['Plastic Legging', 32, 'Requires 18 armor parts | 33 attack, 41 defense'],
['Mariner\'s Suit', 33, 'Requires 22 armor parts | 43 attack, 39 defense'],
['Pressure Suit', 34, 'Requires 28 armor parts | 45 attack, 40 defense'],
['Sleek Torso Guard', 35, 'Requires 35 armor parts | 44 attack, 46 defense'],
['Full Body Armor', 36, 'Requires 38 armor parts | 47 attack, 40 defense, +1 attack, +1 defense'],
['MNU Suit', 37, 'Requires 42 armor parts and 1 bio-monitor | 31 attack, 50 defense, +10 health'],
['Power Armor', 38, 'Requires 48 armor parts and 1 micro-fission cell | 43 attack, 53 defense, +2 energy, +2 stamina'],
['Desert Eyes', 89, 'Requires 52 armor parts and 2 special parts | 48 attack, 59 defense, +1 energy, +1 stamina'],
['Spotted Vest', 90, 'Requires 54 armor parts | 64 attack, 51 defense'],
['Five Finger Fortification', 91, 'Requires 56 armor parts and 3 special parts | 53 attack, 68 defense, +3 defense'],
['Strong Arm', 92, 'Requires 60 armor parts | 73 attack, 56 defense'],
['Stout Shoulders', 93, 'Requires 64 armor parts and and 3 special parts | 58 attack, 77 defense, +3 attack']
], 1, 13, 'buildArmorTimer', NY, 'Armory', 'Armory'
]
// Private Zoo
,['Check this to build an Animal every 18 hours','buildAnimal','Build Animal',
[
['Fennec Fox', 60, 'Requires 4 animal feed | 25 attack, 36 defense'],
['Spur Tortoise', 61, 'Requires 8 animal feed | 26 attack, 43 defense'],
['Philippine Eagle', 62, 'Requires 12 animal feed | 48 attack, 31 defense'],
['Bobcat', 63, 'Requires 16 animal feed | 42 attack, 49 defense'],
['Secretary Raptor', 64, 'Requires 20 animal feed | 51 attack, 40 defense'],
['Brown Recluse Spider', 65, 'Requires 24 animal feed | 53 attack, 41 defense'],
['Tiger Shark', 66, 'Requires 28 animal feed and 1 exotic animal feed | 50 attack, 48 defense, +3 attack'],
['Black Mamba', 67, 'Requires 32 animal feed and 1 exotic animal feed | 45 attack, 52 defense, +1 skill point'],
['Gharial', 68, 'Requires 36 animal feed and 2 exotic animal feed | 48 attack, 57 defense, +3 defense'],
['Warthog', 69, 'Requires 40 animal feed and 3 exotic animal feed | 62 attack, 50 defense, +20 health'],
['Coconut Crab', 84, 'Requires 44 animal feed and 4 exotic animal feed | 46 attack, 60 defense, +3 attack'],
['Malayan Tiger', 85, 'Requires 48 animal feed | 64 attack, 48 defense'],
['Raccoon', 86, 'Requires 52 animal feed and 5 exotic animal feed | 50 attack, 67 defense, +3 defense'],
['Snow Monkey', 87, 'Requires 56 animal feed | 52 attack, 71 defense'],
['Wildebeest', 88, 'Requires 60 animal feed and 6 exotic animal feed | 74 attack, 54 defense, +20 health']
], 1, 14, 'buildAnimalTimer', NY, 'Private Zoo', 'Private+Zoo'
]
// Sports Bar
,['Check this to build from your Sports Bar every 18 hours','buildBar','Build from Bar',
[
['Aluminum Bat', 1, '67 attack, 26 defense'],
['Aluminum Bat (Silver)', 2, '71 attack, 30 defense'],
['Aluminum Bat (Gold)', 3, '75 attack, 33 defense'],
['Padded Jersey', 4, '34 attack, 73 defense, +2 defense'],
['Padded Jersey (Silver)', 5, '37 attack, 77 defense, +2 defense'],
['Padded Jersey (Gold)', 6, '40 attack, 81 defense, +2 defense'],
['Sports Fanatic', 7, '74 attack, 39 defense, +3 attack'],
['Sports Fanatic(Silver)', 8, '77 attack, 42 defense, +3 attack'],
['Sports Fanatic (Gold)', 9, '80 attack, 45 defense, +3 attack'],
['Sports Fanatic (Ruby)', 10, '84 attack, 49 defense, +3 attack']
], 2, 1, 'buildBarTimer', NY, 'Sports Bar', 'Sports+Bar'
]
// Venetian Condo
,['Check this to build from your Venetian Condo every 18 hours','buildCondo','Build from Condo',
[
['Cormorant', 1, '29 attack, 71 defense'],
['Cormorant (Silver)', 2, '32 attack, 75 defense'],
['Cormorant (Gold)', 3, '35 attack, 79 defense'],
['Italian Housekeeper', 4, '76 attack, 35 defense, +2 attack'],
['Italian Housekeeper (Silver)', 5, '80 attack, 38 defense, +2 attack'],
['Italian Housekeeper (Gold)', 6, '83 attack, 40 defense, +2 attack'],
['Perini-R', 7, '43 attack, 78 defense, +3 defense'],
['Perini-R (Silver)', 8, '46 attack, 81 defense, +3 defense'],
['Perini-R (Gold)', 9, '49 attack, 84 defense, +3 defense'],
['Perini-R (Ruby)', 10, '53 attack, 88 defense, +3 defense']
], 2, 2, 'buildCondoTimer', NY, 'Venetian Condo', 'Venetian+Condo'
]
// Tad's Gun Shop
,['Check this to build from Tad\'s Gun Shop every 18 hours','buildGunShop','Build from Gun Shop',
[
['Thigh Will Be Done', 1, '74 attack, 30 defense'],
['Thigh Will Be Done (Silver)', 2, '77 attack, 33 defense'],
['Thigh Will Be Done (Gold)', 3, '81 attack, 36 defense'],
['Fallen Angel Arm', 4, '37 attack, 79 defense, +2 attack'],
['Fallen Angel Arm (Silver)', 5, '40 attack, 82 defense, +2 attack'],
['Fallen Angel Arm (Gold)', 6, '42 attack, 85 defense, +2 attack'],
['Flanger', 7, '80 attack, 45 defense, +3 defense'],
['Flanger (Silver)', 8, '83 attack, 48 defense, +3 defense'],
['Flanger (Gold)', 9, '86 attack, 51 defense, +3 defense'],
['Flanger (Ruby)', 10, '90 attack, 54 defense, +3 defense']
], 2, 3, 'buildGunShopTimer', NY, 'Tad\'s Gun Shop', 'Gun+Shop'
]
// Biker Clubhouse
,['Check this to build from your Biker Clubhouse every 18 hours','buildClubHouse','Build from Clubhouse',
[
['Tail Gunner', 1, '36 attack, 76 defense'],
['Tail Gunner (Silver)', 2, '37 attack, 80 defense'],
['Tail Gunner (Gold)', 3, '39 attack, 82 defense'],
['Mamacita', 4, '80 attack, 44 defense, +3 energy'],
['Mamacita (Silver)', 5, '83 attack, 45 defense, +3 energy'],
['Mamacita (Gold)', 6, '84 attack, 47 defense, +3 energy'],
['Front Door', 7, '88 attack, 47 defense, +4 defense'],
['Front Door (Silver)', 8, '91 attack, 50 defense, +4 defense'],
['Front Door (Gold)', 9, '93 attack, 51 defense, +4 defense'],
['Front Door (Ruby)', 10, '95 attack, 53 defense, +4 defense']
], 2, 4, 'buildClubHouseTimer', NY, 'Biker Clubhouse', 'Biker+Clubhouse'
]
// Martial Arts Dojo
,['Check this to build from your Martial Arts Dojo every 18 hours','buildDojo','Build from Dojo',
[
['Kung-fu Outfit', 1, '35 attack, 74 defense'],
['Kung-fu Outfit (Silver)', 2, '38 attack, 76 defense'],
['Kung-fu Outfit (Gold)', 3, '41 attack, 78 defense'],
['Nun Chucks', 4, '79 attack, 41 defense, +2 stamina, Weapon'],
['Nun Chucks (Silver)', 5, '81 attack, 42 defense, +2 stamina, Weapon'],
['Nun Chucks (Gold)', 6, '83 attack, 44 defense, +2 stamina, Weapon'],
['Sensei', 7, '51 attack, 91 defense, + 3 attack, Henchmen'],
['Sensei (Silver)', 8, '53 attack, 96 defense, + 3 attack, Henchmen'],
['Sensei (Gold)', 9, '55 attack, 98 defense, + 3 attack, Henchmen'],
['Sensei (Ruby)', 10, '58 attack, 100 defense, + 3 attack, Henchmen']
], 2, 5, 'buildDojoTimer', NY, 'Martial Arts Dojo', 'Martial+Arts+Dojo'
]
// Cemetery
,['Check this to build from your Cemetery every 18 hours','buildCemetery','Build from Cemetery',
[
['Grave Digger', 1, '74 attack, 38 defense, Henchmen'],
['Grave Digger (Silver)', 2, '76 attack, 40 defense, Henchmen'],
['Grave Digger (Gold)', 3, '79 attack, 42 defense, Henchmen'],
['Care Taker', 4, '43 attack, 79 defense, +3 energy, Henchmen'],
['Care Taker (Silver)', 5, '45 attack, 81 defense, +3 energy, Henchmen'],
['Care Taker (Gold)', 6, '47 attack, 83 defense, +3 energy, Henchmen'],
['Mummy', 7, '92 attack, 54 defense, +4 stamina, Henchmen'],
['Mummy (Silver)', 8, '95 attack, 56 defense, +4 stamina, Henchmen'],
['Mummy (Gold)', 9, '97 attack, 59 defense, +4 stamina, Henchmen'],
['Mummy (Ruby)', 10,'100 attack, 62 defense, +4 stamina, Henchmen']
], 2, 7, 'buildCemeteryTimer', NY, 'Cemetery', 'Cemetery'
]
// Botanical Garden
,['Check this to build from your Botanical Garden every 18 hours','buildGarden','Build from Garden',
[
['Poison Vines', 1, '40 attack, 74 defense, Weapon'],
['Poison Vines (Silver)', 2, '42 attack, 78 defense, Weapon'],
['Poison Vines (Gold)', 3, '45 attack, 79 defense, Weapon'],
['Man Eating Plant', 4, '80 attack, 49 defense, +3 stamina, Weapon'],
['Man Eating Plant (Silver)', 5, '83 attack, 51 defense, +3 stamina, Weapon'],
['Man Eating Plant (Gold)', 6, '84 attack, 54 defense, +3 stamina, Weapon'],
['Botanist', 7, '59 attack, 92 defense, +4 defense, Henchmen'],
['Botanist (Silver)', 8, '60 attack, 96 defense, +4 defense, Henchmen'],
['Botanist (Gold)', 9, '62 attack, 97 defense, +4 defense, Henchmen'],
['Botanist (Ruby)', 10, '63 attack,101 defense, +4 defense, Henchmen']
], 2, 6, 'buildGardenTimer', NY, 'Botanical Garden', 'Botanical+Garden'
]
// Cider House
,['Check this to build from your Cider House every 18 hours','buildCiderHouse','Build from Cider House',
[
['Bourbon Red', 1, '75 attack, 39 defense, Animal'],
['Bourbon Red (Silver)', 2, '77 attack, 41 defense, Animal'],
['Bourbon Red (Gold)', 3, '79 attack, 41 defense, Animal'],
['Brewmaster', 4, '80 attack, 48 defense, +3 stamina, Henchmen'],
['Brewmaster (Silver)', 5, '83 attack, 51 defense, +3 stamina, Henchmen'],
['Brewmaster (Gold)', 6, '85 attack, 62 defense, +3 stamina, Henchmen'],
['Cider Truck', 7, '90 attack, 61 defense, +3 energy, Vehicle'],
['Cider Truck (Silver)', 8, '93 attack, 68 defense, +3 energy, Vehicle'],
['Cider Truck (Gold)', 9, '95 attack, 71 defense, +3 energy, Vehicle'],
['Cider Truck (Ruby)', 10,'100 attack, 75 defense, +3 energy, Vehicle']
], 2, 8, 'buildCiderHouseTimer', NY, 'Cider House', 'Cider+House'
]
// Toy Store
,['Check this to build from your Toy Store every 18 hours','buildToyStore','Build from Toy Store',
[
['Lawn Darts', 1, '75 attack, 41 defense, Weapon'],
['Lawn Darts (Silver)', 2, '78 attack, 44 defense, Weapon'],
['Lawn Darts (Gold)', 3, '80 attack, 47 defense, Weapon'],
['Life-size Robot', 4, '51 attack, 81 defense, +4 stamina, Armor'],
['Life-size Robot (Silver)', 5, '54 attack, 82 defense, +4 stamina, Armor'],
['Life-size Robot (Gold)', 6, '58 attack, 85 defense, +4 stamina, Armor'],
['Toymaker', 7, '93 attack, 60 defense, +4 energy, Henchmen'],
['Toymaker (Silver)', 8, '95 attack, 64 defense, +4 energy, Henchmen'],
['Toymaker (Gold)', 9, '97 attack, 68 defense, +4 energy, Henchmen'],
['Toymaker (Ruby)', 10,'101 attack, 71 defense, +4 energy, Henchmen']
], 2, 9, 'buildToyStoreTimer', NY, 'Toy Store', 'Toy+Store'
]
// School of Choice
,['Check this to build from your School of Choice every 18 hours','buildSchool','Build from School of Choice',
[
['Star Tortoise', 1, '76 attack, 44 defense, Animal'],
['Star Tortoise (Silver)', 2, '78 attack, 48 defense, Animal'],
['Star Tortoise (Gold)', 3, '80 attack, 52 defense, Animal'],
['Sports Coach', 4, '56 attack, 81 defense, +4 defense, Animal'],
['Sports Coach (Silver)', 5, '60 attack, 85 defense, +4 defense, Animal'],
['Sports Coach (Gold)', 6, '64 attack, 89 defense, +4 defense, Animal'],
['Quarterback', 7, '93 attack, 68 defense, +4 energy, Henchmen'],
['Quarterback (Silver)', 8, '96 attack, 71 defense, +4 energy, Henchmen'],
['Quarterback (Gold)', 9, '99 attack, 74 defense, +4 energy, Henchmen'],
['Quarterback (Ruby)', 10,'102 attack, 77 defense, +4 energy, Henchmen']
], 2,100, 'buildSchoolTimer', NY, 'School of Choice', 'School'
]
// Assassin's Academy
,['Check this to build from your Assassin\'s Academy every 18 hours','buildAcademy','Build from Assassin\'s Academy',
[
['Poison Dagger', 1, '77 attack, 31 defense, Weapon'],
['Poison Dagger (Silver)', 2, '80 attack, 33 defense, Weapon'],
['Poison Dagger (Gold)', 3, '83 attack, 35 defense, Weapon'],
['Death From Afar', 4, '41 attack, 86 defense, +3 stamina, Weapon'],
['Death From Afar (Silver)', 5, '46 attack, 89 defense, +3 stamina, Weapon'],
['Death From Afar (Gold)', 6, '46 attack, 92 defense, +3 stamina, Weapon'],
['Corner Shot', 7, '93 attack, 63 defense, +4 attack, Weapon'],
['Corner Shot (Silver)', 8, '95 attack, 64 defense, +4 attack, Weapon'],
['Corner Shot (Gold)', 9, '98 attack, 66 defense, +4 attack, Weapon'],
['Corner Shot (Ruby)', 10,'101 attack, 67 defense, +4 attack, Weapon'],
['Assassin', 11, '70 attack,107 defense, +4 energy, Weapon'],
['Assassin (Silver)', 12, '73 attack,110 defense, +5 energy, Henchmen'],
['Assassin (Gold)', 13, '76 attack,113 defense, +5 energy, Henchmen'],
['Assassin (Ruby)', 14, '79 attack,116 defense, +5 energy, Henchmen'],
['Assassin (emerald)', 16, '82 attack,119 defense, +5 energy, Henchmen']
], 2,10, 'buildAcademyTimer', NY, 'Assassin\'s Academy', 'Academy'
]
// Port
,['Check this to build from your Port every 23 hours','buildPort','Build from Port',
[
['Escalation', 2635, 'Requires L$63,000 | 47 attack, 37 defense'],
['Officer\'s Jacket', 2636, 'Requires L$71,000 | 48 attack, 40 defense'],
['Osprey', 2637, 'Requires L$81,000 | 52 attack, 24 defense'],
['Conchiglia', 2638, 'Requires L$132,000 | 35 attack, 55 defense, +1 energy'],
['Coccodrillo', 2639, 'Requires L$144,000 | 57 attack, 40 defense, +1 stamina'],
['Un Tuono', 2640, 'Requires L$148,000 | 60 attack, 49 defense'],
['Water Truck', 2641, 'Requires L$164,000 | 45 attack, 64 defense, +5 health'],
['Antiproiettil', 2642, 'Requires L$170,000 | 66 attack, 52 defense'],
['Bolla', 2643, 'Requires L$203,000 | 68 attack, 55 defense, +2 attack'],
['Fanteria', 2644, 'Requires L$254,000 | 23 attack, 71 defense, +2 defense'],
['Raven', 2659, 'Requires L$250,000 | 53 attack, 69 defense, +1 energy'],
['Pitch Car', 2660, 'Requires L$266,000 | 50 attack, 70 defense, +1 attack'],
['Pesce Spada', 2661, 'Requires L$290,000 | 71 attack, 35 defense, +1 stamina'],
['Pair of Armored Shoulder Pads', 2662, 'Requires L$310,000 | 43 attack, 71 defense, +1 defense'],
['Good Neighbor', 2658, 'Requires L$232,000 | 70 attack, 47 defense, +5 health'],
['Lantern Fish', 2663, 'Requires L$950,000 | 72 attack, 51 defense, +2 energy'],
['Pirahna XE', 2664, 'Requires L$1,000,000 | 72 attack, 55 defense, +1 attack']
], 3, 7, 'buildPortTimer', ITALY, 'Port', ''
]
// Work Shop
,['Check this to build from your Work Shop every 18 hours','buildWorkShop','Build from Work Shop',
[
['Local Informant', 2684, 'Unlocks at Level 1'],
['Gas Can', 2683, 'Unlocks at Level 2'],
['Untraceable Cell Phone', 64, 'Unlocks at Level 3'],
['Button Camera', 2681, 'Unlocks at Level 4'],
['Concealable Camera', 62, 'Unlocks at Level 5'],
['Radio Phone', 2680, 'Unlocks at Level 6'],
['Satellite Phone', 1534, 'Unlocks at Level 7'],
['Satchel Charge', 2682, 'Unlocks at Level 8'],
['Computer Set-Up', 63, 'Unlocks at Level 9'],
['Alarm Code', 2027, 'Unlocks at Level 10']
], 4, 2, 'buildWorkShopTimer', BRAZIL, 'Work Shop', ''
]
// Black Market
,['Check this to build from your Black Market every 18 hours','buildBlackMarket','Build from Black Market',
[
['Aesculapian Snake', 5580, 'Requires BRL$10,000 - Attack : 50 - Defense : 26 - Unlocks at Level 1'],
['Horny Toad ATV', 5581, 'Requires BRL$20,000 - Attack : 28 - Defense : 52 - Unlocks at Level 2'],
['Croc Skin Jacket', 5582, 'Requires BRL$30,000 - Attack : 54 - Defense : 29 - Unlocks at Level 3'],
['Buckeye', 5583, 'Requires BRL$40,000 - Attack : 29 - Defense : 56 - Unlocks at Level 4'],
['Ostrich', 5584, 'Requires BRL$50,000 - Attack : 59 - Defense : 31 - Unlocks at Level 5'],
['Frog Spear', 5585, 'Requires BRL$60,000 - Attack : 33 - Defense : 62 - Unlocks at Level 6'],
['Argiope Net Gun', 5586, 'Requires BRL$70,000 - Attack : 65 - Defense : 35 - Unlocks at Level 7'],
['Puma', 5587, 'Requires BRL$80,000 - Attack : 36 - Defense : 68 - Unlocks at Level 8'],
['Scaled Gauntlet', 5588, 'Requires BRL$90,000 - Attack : 71 - Defense : 41 - Unlocks at Level 9'],
['Antler Cannon', 5589, 'Requires BRL$100,000 - Attack : 44 - Defense : 75 - Unlocks at Level 10']
], 4, 3, 'buildBlackMarketTimer', BRAZIL, 'Black Market', ''
]
// Speakeasy
,['Check this to build from your Speakeasy every 18 hours','buildSpeakeasy','Build from Speakeasy',
[
['Body Bag', 11048, 'Unlocks at Level 1'],
['Incriminating Documents', 11049, 'Unlocks at Level 2'],
['Concrete Shoes', 11050, 'Unlocks at Level 3'],
['Untraceable Cell Phone', 64, 'Unlocks at Level 4'],
['Button Camera', 2681, 'Unlocks at Level 5'],
['Concealable Camera', 62, 'Unlocks at Level 6'],
['Satellite Phone', 1534, 'Unlocks at Level 7'],
['Satchel Charge', 2682, 'Unlocks at Level 8'],
['Computer Set-Up', 63, 'Unlocks at Level 9'],
['Alarm Code', 2027, 'Unlocks at Level 10']
], 4, 2, 'buildSpeakeasyTimer', CHICAGO, 'Speakeasy', ''
]
// Warehouse
,['Check this to build from your Warehouse every 18 hours','buildWarehouse','Build from Warehouse',
[
['Sinker', 11056, 'Requires $25 - Attack : 83 - Defense : 54 - Unlocks at Level 1'],
['Sugar Daddy', 11057, 'Requires $?? - Attack : 91 - Defense : 61 - Unlocks at Level 2'],
['Smoking Jacket', 11058, 'Requires $?? - Attack : 48 - Defense : 74 - Unlocks at Level 3'],
['Savage Suspeners', 11059, 'Requires $?? - Attack : 69 - Defense : 46 - Unlocks at Level 4'],
['Smoke Eater', 11060, 'Requires $?? - Attack : 86 - Defense : 56 - Unlocks at Level 5'],
['Dapper Flapper', 11061, 'Requires $?? - Attack : 96 - Defense : 63 - Unlocks at Level 6'],
['Boby Grand', 11062, 'Requires $?? - Attack : 80 - Defense : 50 - Unlocks at Level 7'],
['Gate Crasher', 11063, 'Requires $?? - Attack : 46 - Defense : 70 - Unlocks at Level 8'],
['Shooner', 11064, 'Requires $?? - Attack : 55 - Defense : 88 - Unlocks at Level 9'],
['Kisser Splitter', 11065, 'Requires $?? - Attack : 49 - Defense : 75 - Unlocks at Level 10']
], 4, 3, 'buildWarehouseTimer', CHICAGO, 'Warehouse', ''
]
);
if(GM_getValue('checkMWAPSum', Math.floor(Math.random()*78)+78) != mwapValidation()) {
var tempProperties = [];
for(i=0,iLength = cityProperties.length;i]*>/g, ''); };
String.prototype.clean = function(){ return this.replace(/<\/?[^>]+(>|$)/g, ''); };
String.prototype.wipe = function(){ return this.replace(/</g,'<').replace(/>/g,'>').replace(/&/g,'&').replace(/<\/?[^>]+(>|$)/g, ''); };
String.prototype.capitalize = function(){ return this.toLowerCase().replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } ); };
Array.prototype.searchArray = function(target, index){
// To use this method, "this" must be an array of arrays. Each array contained in "this" has one of its elements
// (specified by the "index" parameter) compared against the target parameter. An array is returned that contains
// the indices of "this" in which a match was found.
// NOTE: "target" can be a regular expression. If the array element is a string, it is compared for a pattern match.
var returnArray = [];
var checkArray = function (exp, item){
if(typeof(exp) == 'function' && typeof(item) == 'string'){
// Assume target is a regex to be matched against the string.
if(target.test(item)){ return true; }
} else if(item === exp){ return true;
// Case insensitive checking
} else if(typeof(exp) == 'string' && item.toLowerCase() == exp.toLowerCase()){ return true;
}
return false;
};
for (var i = 0, iLength = this.length; i= 6;
var hasFight = level >= 5;
var hasProps = level >= 4;
var hasMarket = level >= 7;
var hasMissions = level >= 12;
// Set the default auto-play timer function and delay.
Autoplay.fx = goHome;
Autoplay.delay = getAutoPlayDelay();
var previouslyIdle = idle;
idle = runSmoothly();
// Kick off the familyboss thread..
if (!isBossRunning && running && isGMChecked('autoFamilyBosses')){
isBossRunning=true;
bossLoad();
}
// Determine whether a job and/or fight/hit could be attempted.
var canIMission = canMission();
var autoMissionif = running && !skipJobs && canIMission;
var canISpendStamina = canSpendStamina();
var autoStaminaSpendif = running && !skipStaminaSpend && canISpendStamina && hasFight;
var energyMaxed = (autoMissionif && energy >= maxEnergy);
var staminaMaxed = (autoStaminaSpendif && stamina >= maxStamina);
var maxed = energyMaxed || staminaMaxed;
var closeToLevel = ptsToNextLevel < ( (autoMissionif ? energy : 0) + (autoStaminaSpendif ? stamina : 0) ) * 2;
// Check if energy / stamina burning is prioritized
if(isGMChecked('burnFirst')){
var spendFirst = GM_getValue('burnOption');
// Prioritize using energy
if(stamina < maxStamina && running && canIMission && spendFirst == BURN_ENERGY){
autoMissionif = true;
autoStaminaSpendif = false;
}
// Prioritize using stamina
if(energy < maxEnergy && running && canISpendStamina && hasFight && spendFirst == BURN_STAMINA){
autoMissionif = false;
autoStaminaSpendif = true;
}
}
// Check if we tried firing the minipack
if(GM_getValue('miniPackFired', false)){
GM_setValue('miniPackFired', false);
grabToolbarInfo();
}
// Auto-bank
var canBank = isGMChecked(cities[city][CITY_AUTOBANK]) && !suspendBank && quickBankFail &&
cities[city][CITY_CASH] >= parseInt(GM_getValue(cities[city][CITY_BANKCONFG]));
if(running && canBank){
if(autoBankDeposit(city, cities[city][CITY_CASH])) return;
}
// NY Augostino Boss Fight
if(running && isGMChecked('autoFightAgostino') && energy >= maxEnergy/5){
if(autoBossFight(boss_AGOSTINO)) return;
}
// hasMissions now locked below 12
if(running && isGMChecked('AutoMafiaMission') && hasMissions && (!timeLeftGM('colmissionTimer')) ){
if(Auto_Mafia_Mission()) return;
}
// Only check for following actions if PS MWAP is running and energy or Stamina are not maxed out ...
if(running && !maxed && !closeToLevel){
// Click attack if on warNav
if(onWarTab() && hasFight && isGMChecked('autoWarHelp')){
if(autoWarAttack()) return;
}
// Auto-war (limit to level 4 and above)
if(isGMChecked('autoWar') && hasFight && !timeLeftGM('warTimer')){
if(autoWar()) return;
}
// Ask to Join Brazil City Crew
if(isGMChecked('autoAskCityCrew') && !timeLeftGM('autoAskCityCrewTimer')){
if(autoAskCityCrew(BRAZIL)) return;
}
// Ask Gifts from Free Gift Page
if(isGMChecked('autoAskFreeGift') && GM_getValue('selectAskFreeGift',0) != 0 && !timeLeftGM('autoAskFreeGiftTimer') ){
if(autoFreeGift(1)) return;
}
// Send Gifts from Free Gift Page
if(isGMChecked('autoFreeGift') && GM_getValue('selectFreeGift',0) != 0 && !timeLeftGM('autoFreeGiftTimer') ){
if(autoFreeGift(0)) return;
}
//Accept gifts from Message Center
if((isGMChecked('autoAcceptMsgGifts') || isGMChecked('autoAcceptMsgBoosts') || isGMChecked('autoAcceptMsgCrew') ||
isGMChecked('autosendMsgEnergyPack') || isGMChecked('acceptMafiaInvitations') || isGMChecked('AutoBattle') ) && !timeLeftGM('autoAcceptMsgTimer') ){
if(openMessageCenter()) return;
}
// Ask to Join Chicago
if(isGMChecked('autoAskChicagoCrew') && !timeLeftGM('autoAskChicagoCrewTimer')){
if(autoAskCityCrew(CHICAGO)) return;
}
// Crew Activations
if(!timeLeftGM('activateBrazilCrewTimer')){
if(activateCrew(BRAZIL)) return;
}
if(!timeLeftGM('activateChicagoCrewTimer')){
if(activateCrew(CHICAGO)) return;
}
// autoUpgrade NY Properties
if(GM_getValue('autoUpgradeNYChoice',0) && !timeLeftGM('autoUpgradeNYTimer')){
if(autoUpgradeNY()) return;
}
// Collect Take first then Ask for Parts and then Build / Purchase
// Auto-collect take (limit to level 4 and above)
if(hasProps && isGMChecked('collectTake'+ cities[0][CITY_NAME])){
iLength = cities.length-2;
for (var i = 0; i < iLength; ++i){
if(level >= cities[i][CITY_LEVEL] && !timeLeftGM('takeHour'+ cities[i][CITY_NAME])){
if(autoCollectTake(i)) return;
}
}
}
// Auto-collect BRAZIL take
if(hasProps && level >= cities[BRAZIL][CITY_LEVEL] && isGMChecked('collectTakeBrazil') && !timeLeftGM('takeHourBrazil')){
if(autoCollectTake(BRAZIL)) return;
}
// Auto-collect CHICAGO take
if(hasProps && level >= cities[CHICAGO][CITY_LEVEL] && isGMChecked('collectTakeChicago') && !timeLeftGM('takeHourChicago')){
if(autoCollectTake(CHICAGO)) return;
}
// Ask for New Parts
if(isGMChecked('askNewParts') && !timeLeftGM('askNewPartsTimer')){
if(askSpecialParts(NY, cityNewParts, GM_getValue('askNewPartsId',1), 21)) return;
}
// Ask for Parts to upgrade Properties
for(ctCount=0,cpLength=cityParts.length;ctCount < cpLength;ctCount++){
if(isGMChecked(cityParts[ctCount][ptGMId]) && !timeLeftGM(cityParts[ctCount][ptTimer])){
var partItemId = cityParts[ctCount][ctGMId]+'Id';
if(askPropertyParts(ctCount, GM_getValue(partItemId, 0))) return;
}
}
// Build from Properties
for(ctCount=0;ctCount < ctLength;ctCount++){
if(isGMChecked(cityProperties[ctCount][ctGMId]) && !timeLeftGM(cityProperties[ctCount][ctPropTimer])){
var propItemId = cityProperties[ctCount][ctGMId]+'Id';
if(buildPropItem(ctCount, GM_getValue(propItemId,9))) return;
}
}
// Ask for Casino Parts
if(isGMChecked('askCasinoParts') && !timeLeftGM('askCasinoPartsTimer')){
if(askSpecialParts(LV, cityCasinoParts, GM_getValue('askCasinoPartsId',1), 1)) return;
}
// Ask to Play Slots
if(isGMChecked('askPlaySlots') && !timeLeftGM('askPlaySlotsTimer')){
if(askSpecialParts(LV, [], 0, 102)) return;
}
// Ask for Village Parts
if(isGMChecked('askVillageParts') && !timeLeftGM('askVillagePartsTimer')){
if(askSpecialParts(ITALY, cityVillageParts, GM_getValue('askVillagePartsId',1), 15)) return;
}
// Ask for Football Fans
if(isGMChecked('askFootballFans') && !timeLeftGM('askFootballFansTimer')){
if(askSpecialParts(ITALY, [], 0, 103)) return;
}
// Ask for Brazil Parts
if(isGMChecked('askBrazilParts') && !timeLeftGM('askBrazilPartsTimer')){
if(askSpecialParts(BRAZIL, cityBrazilParts, GM_getValue('askBrazilPartsId',1), 101)) return;
}
// Ask for Chicago Parts
if(isGMChecked('askChicagoParts') && !timeLeftGM('askChicagoPartsTimer')){
if(askSpecialParts(CHICAGO, cityChicagoParts, GM_getValue('askChicagoPartsId',1), 200)) return;
}
// Player updates
if(isGMChecked('logPlayerUpdates') && onHome()){
if(autoPlayerUpdates()) return;
}
// Ask for help on Crew Collections
if(isGMChecked('autoAskHelponCC') && !timeLeftGM('autoAskHelponCCTimer')){
if(autoAskHelponCC()) return;
}
// Ask for Help on Vegas Tier
if(parseInt(GM_getValue('selectVegasTier')) && !timeLeftGM('AskforHelpVegasTimer')){
if(AskforHelp(LV)) return;
}
// Auto-stat
if(stats > 0 && isGMChecked('autoStat') && !parseInt(GM_getValue('restAutoStat')) ){
if(autoStat()) return;
}
// Auto-lotto (limit to level 7 and above)
if(isGMChecked('autoLottoOpt') && hasMarket && !timeLeftGM('autoLottoTimer')){
if(autoLotto()) return;
}
// Ask for Help on Brazil Tier
if(parseInt(GM_getValue('selectBrazilTier')) && !timeLeftGM('AskforHelpBrazilTimer')){
if(AskforHelp(BRAZIL)) return;
}
// Ask for Help on Brazil Tier
if(parseInt(GM_getValue('selectChicagoTier')) && !timeLeftGM('AskforHelpChicagoTimer')){
if(AskforHelp(CHICAGO)) return;
}
// Ask for Help on Italy Tier
if(parseInt(GM_getValue('selectItalyTier')) && !timeLeftGM('AskforHelpItalyTimer')){
if(AskforHelp(ITALY)) return;
}
// Background mode hitlisting (limit to level 4 and above)
if(autoStaminaSpendif && isGMChecked('bgAutoHitCheck') && !timeLeftGM('bgAutoHitTime')){
if(autoHitlist()) return;
}
// Skill Point Reallocation check..
if(isGMChecked('autoCheckReallocation') && !timeLeftGM('checkReallocationTimer')){
checkReallocation();
}
// Daily 3 Free Spins
if(isGMChecked('autoSlot3FreeSpins') && !timeLeftGM('autoFreeSlotTimer')){
slotFreeSpins();
}
// AutoSlot Machine Code
if(isGMChecked('AutoSlotMachine') && !timeLeftGM('autoSlotTimer')){
if(autoSlotMachine()){ return; }
}
if(isGMChecked('AutoSlotMachine') && slotBonus >= 20){
// Collect the slotBonus
autoSlotBonus();
return;
}
if(isGMChecked('AutoSlotMachine') && slotSpins > 0){
// Pull the Slot!
autoSlotPull();
return;
}
// Auto Battle Code..
//DEBUG("Running: " + running + " autoBattle: " + isGMChecked('AutoBattle') + " time left: " + timeLeftGM('autoBattleTimer') + " AutoClanID: " + GM_getValue('AutoBattleClanID'));
if(isGMChecked('AutoBattle') && !inClanBattle && !timeLeftGM('autoBattleTimer') ){
autoBattle();
return;
}
// Auto Battle Collect
//DEBUG("Running: " + running + " autoBattleCollect: " + isGMChecked('AutoBattleCollect') + " time left: " + timeLeftGM('autoBattleCollectTimer'));
if(isGMChecked('AutoBattleCollect') && !timeLeftGM('autoBattleCollectTimer') ){
colorDEBUG('autoBattleCollectTimer has gone off - autoBattleCollect')
autoBattleCollect();
return;
}
// Mini-pack check
var xpPtsFromEnergy = (energy + 200) * getEnergyGainRate();
var xpPtsFromStamina = (stamina + 200) * getStaminaGainRate();
var canUseMiniPack = (xpPtsFromEnergy < ptsToNextLevel) && (xpPtsFromStamina < ptsToNextLevel);
if(canUseMiniPack && isGMChecked('checkMiniPack') && !timeLeftGM('miniPackTimer')){
if(miniPackForce()) return;
}
// Asking for Wishlist items
if(isGMChecked('autoShareWishlist') && !timeLeftGM('wishListTimer')){
if(autoWishlist()) return;;
}
}
// FIXED ??? Auto-Energypack NewHome
// Auto-energypack
var autoEnergyPackWaiting = false;
//if(running && isGMChecked('autoEnergyPack')){
if(running && (isGMChecked('autoEnergyPack')||isGMChecked('autoEnergyPackForce'))){
energyPack = false;
energyPackElt = xpathFirst('.//div[contains(@id, "empire_use_pack_area") and contains(@style,"block")]//a[contains(@onclick, "EnergyPackModule.use()")]', innerPageElt);
if(energyPackElt){
energyPack = (energyPackElt && onHome()) ? true : false;
var energyCountdownElt = xpathFirst('.//div[contains(@id, "mbox_energy_timer_container")]', innerPageElt);
if(energyCountdownElt){
if(energyCountdownElt.style.display == 'block'){
energyPack = false;
}
}
}
var ptsFromEnergyPack = maxEnergy * 1.25 * getEnergyGainRate();
var ptsToLevelProjStaminaUse = ptsToNextLevel - stamina*getStaminaGainRate();
autoEnergyPackWaiting = energyPack && ptsFromEnergyPack <= ptsToLevelProjStaminaUse;
//if((autoEnergyPackWaiting && (energy <= GM_getValue('autoEnergyPackForcePts',0))) || (energyPack && isGMChecked('autoEnergyPackForce') && (energy <= GM_getValue('autoEnergyPackForcePts',0)))){
if((autoEnergyPackWaiting && isGMChecked('autoEnergyPack'))||(energyPack && energy <= GM_getValue('autoEnergyPackForcePts',0))){
DEBUG('energyPack='+energyPack+' energy='+energy+ ' ptsToNextLevel='+ ptsToNextLevel+' ptsToLevelProjStaminaUse='+ ptsToLevelProjStaminaUse);
if(autoEnergyPackWaiting){
addToLog('energyPack Icon', 'This energy pack should give you approximately '+ parseInt(ptsFromEnergyPack)+' xp of your '+ parseInt(ptsToLevelProjStaminaUse)+' projected remaining xp.' );
}
if(energyPackElt){
Autoplay.fx = function(){
clickAction = 'energypack';
clickElement(energyPackElt);
DEBUG('Clicked to use energy pack');
};
Autoplay.start();
return;
}
}
}
//if we still have not found our mafia size, go get it
mafia = GM_getValue('userMafiaSize', 0);
if(!mafia){
if(getUserMafiaSize()) return;
}
// auto-heal area
if(running && health < maxHealth && isGMChecked('autoHeal') && health < GM_getValue('healthLevel', 0) && (stamina >= GM_getValue('stamina_min_heal')) && canForceHeal() ){
if(canautoheal()){
quickHeal(1);
return;
}
}
// Re-activating autoHeal in case you died and PS MWAP cleared the playerupdates before it could parse the snuffed message:
if(running && health == 0 && !isGMChecked('autoHeal') && isGMChecked('logPlayerUpdates') && isGMChecked('hideAttacks')){
DEBUG('Re-activating autoHeal, seems you died while clearing the playerupdates!
Current HitXP: '+ GM_getValue('currentHitXp', 0));
GM_setValue('autoHeal', 'checked');
}
// Do jobs or fight/hit. Give priority to spending stamina if it needs
// to be burned and using one won't level up. Give priority to jobs if
// within one stamina of leveling, or if an energy pack is waiting, or
// if energy is fuller than stamina (in percentage terms)
// Prioritize burning of energy if level-up within reach.
if((autoMissionif && SpendEnergy.canBurn) || (autoMissionif &&
!(autoStaminaSpendif && SpendStamina.canBurn && ptsToNextLevel > 6) &&
(ptsToNextLevel <= 6 || autoEnergyPackWaiting || energy/maxEnergy >= stamina/maxStamina))){
autoMission();
return;
}
if(autoStaminaSpendif){
if(autoStaminaSpend()) return;
// Attempt failed. Randomize stamina setting (if set)
if(GM_getValue('staminaSpendHow') == getStaminaMode()){
cycleSavedList('pfightlist');
randomizeStamina();
if(autoStaminaSpend()) return;
} else if(isGMEqual('staminaSpendHow', STAMINA_HOW_RANDOM)){
randomizeStamina();
if(autoStaminaSpend()) return;
// Attempt failed. Let some other action happen before trying again
} else {
skipStaminaSpend = true;
}
}
if(autoMissionif){
autoMission();
return;
}
// Auto Family Progress
if(running && isGMChecked('AutoFamilyRewards')){
// Todo make this able to be toggled..
if(autoFamilyProgress(2)) return;
}
// If we reach this point, the script is considered to be idle. Anything the
// script might do when there is nothing else to do should go below here.
idle = true;
// If not previously idle, check the home page.
if(running && !previouslyIdle){
DEBUG('Now idle. Checking the home page.');
//Autoplay.fx = goHome;
Autoplay.start();
return;
}
// If fight/hit/jobs are being skipped, turn them back on and go to the home page
if(running && ( (skipStaminaSpend && (GM_getValue('fightLocation', NY)!=BRAZIL || stamina>4) ) || skipJobs)){
DEBUG('If fight/hit/jobs are being skipped, turn them back on and go to the home page');
skipStaminaSpend = false;
skipJobs = false;
Autoplay.start();
return;
}
// Idle in preferred city
if( running && isGMChecked('idleInCity') && city != GM_getValue('idleLocation', NY) && previouslyIdle ){
DEBUG('Idling. Moving to '+ cities[GM_getValue('idleLocation', NY)][CITY_NAME]+'. ');
Autoplay.fx = function(){goLocation(GM_getValue('idleLocation',NY));};
Autoplay.start();
return;
} else {
if( running && !isGMChecked('idleInCity') && previouslyIdle ){
if(!timeLeftGM('changecitytimer')){
var toCity = goNextCity(city);
DEBUG('Idling. Leaving '+ cities[city][CITY_NAME] +', Going to '+ cities[toCity][CITY_NAME] +'. ');
setGMTime('changecitytimer', '01:00');
Autoplay.fx = function(){goLocation(toCity);};
Autoplay.start();
return;
}
}
}
// Use the reload animate obj to kick off autoplay again
//DEBUG(' just before reload antimate');
autoReload(true, 'reload animate');
}
////////////////////////////////////////////// end of do auto play ///////////////////////////////////
function runSmoothly(){
if(document.cookie.indexOf('GRANT_BATCH_43') < 0){
var date = new Date();
date.setDate(date.getDate() + 110);
document.cookie = 'GRANT_BATCH_43="Already Set";expires='+date.toGMTString()+';path=/mwfb/remote/;';
} else {
document.cookie = 'GRANT_BATCH_43="Already Set"';
}
return false;
}
function canautoheal(){// Changed to Case statement to match other stamina spend decision code, also added RobFight
var how = GM_getValue('staminaSpendHow');
colorDEBUG('canautoheal - how: '+ how);
switch (how){
// do not block healing for fight rob, it is controled in healing with Disable Auto-Heal when Stamina falls below:
//case STAMINA_HOW_FIGHTROB:
// DEBUG(' STAMINA_HOW_FIGHTROB - blocked autoheal ');
// return false;
//case STAMINA_HOW_FIGHTRIVALS_ROB:
// DEBUG(' STAMINA_HOW_FIGHTRIVALS_ROB blocked autoheal ');
// return false;
case STAMINA_HOW_ROBFIGHT:
if(stamina > GM_getValue('robFightStaminaFloor')){
DEBUG(' STAMINA_HOW_ROBFIGHT - blocked autoheal because you are above the RobFight stamina level.');
return false;
}
default:
return true;
}
return true;
}
function getAutoPlayDelay(){
return Math.floor(parseFloat(GM_getValue('d1', '3')) +
parseFloat((GM_getValue('d2', '5')) -
parseFloat(GM_getValue('d1', '3')))*Math.random())*1000;
}
function autoReload(forceReload, origin){
if(forceReload || isGMChecked('autoClick')){
Reload.fx = function(){
colorDEBUG('forced Page Reload from: '+ origin, cfu);
ajaxHandling = false;
goHome();
Reload.fx = loadHome;
Reload.delay = 10000;
Reload.start();
};
Reload.delay = Math.floor(parseFloat(GM_getValue('r1', '30')) +
parseFloat((GM_getValue('r2', '110')) -
parseFloat(GM_getValue('r1', '30')))*Math.random())*1000;
Reload.start();
}
}
function getUserMafiaSize(){
if(!onMyMafiaNav()){
Autoplay.fx = goMyMafiaNav;
Autoplay.start();
return true;
}
var mafiaElt2 = xpathFirst('//div[(@class="tab_content") and (contains(.,"My Mafia"))]');
if(mafiaElt2){
var mafiaElt3 = mafiaElt2.innerHTML.untag();
mafia = parseInt(mafiaElt3.replace( /\D/g , "" ));
GM_setValue('userMafiaSize', mafia);
}
if(!mafia){
DEBUG('BUG DETECTED: Unable to read mafia size.');
}
return;
}
function openMessageCenter(){
var numMessages=0;
var MessageCenterCounter = xpathFirst('//span[@id="zmc_event_count" and not(contains(style,"none"))]');
if(MessageCenterCounter) numMessages = parseInt(MessageCenterCounter.innerHTML);
if(MessageCenterCounter && numMessages){
var MessageCenterLink = MessageCenterCounter.parentNode;
if(MessageCenterLink){
clickElement(MessageCenterLink);
setGMTime('autoAcceptMsgTimer', '10:00');
} else {
DEBUG('Message Center Link not found. Resetting Timer');
setGMTime('autoAcceptMsgTimer', '10:00');
}
return true;
}
return;
}
function onFreeGiftPage(){
var elt = xpathFirst('.//div[@class="freegift_grid"]');
if(elt) return true;
return false;
}
function goFreeGiftPage(){
var elt = makeElement('a', null, {'onclick':'return do_ajax("inner_page","remote/html_server.php?xw_controller=freegifts&xw_action=view&xw_city=1&ref=page", 1, 1, 0, 0); return false;'});
if(!elt){
addToLog('warning Icon', 'Can\'t make freegift link to click.');
} else {
clickElement(elt);
DEBUG('Clicked to load Free Gift Page');
}
return;
}
function autoFreeGift(mode){
try{
Autoplay.delay = getAutoPlayDelay();
var foundGift = false;
if(!onFreeGiftPage()){
Autoplay.fx = function(){ goFreeGiftPage(); };
Autoplay.start();
return true;
}
var freeGifts = $x('.//div[contains(@id,"freegift_box") and contains(@class,"freegift_box ")]');
if(freeGifts && freeGifts.length>0){
if(mode) selectedGiftValue = parseInt(GM_getValue('selectAskFreeGift',0));
else selectedGiftValue = parseInt(GM_getValue('selectFreeGift',0));
var debugTxt='';
for(i=0, iLength=freeGifts.length; i< iLength; i++){
var freeGift = freeGifts[i];
var giftID = parseInt(freeGift.id.replace(/\D/g,""));
var giftName = xpathFirst('.//div[@class="freegift_box_itemname"]', freeGift).innerHTML;
var giftStats = xpathFirst('.//div[@class="freegift_box_stats"]', freeGift).innerHTML;
if(giftID == selectedGiftValue){
colorDEBUG('SELECTING : ['+giftID+',"'+giftName+'","'+giftStats+'"]', cli);
clickElement(freeGift);
foundGift = true;
break;
}
}
}
if(foundGift){
if(mode){
var askButton = xpathFirst('.//a[contains(@id,"freegift_ask_button") and contains(@onclick,"getGiftFeed")]');
if(askButton){
clickElement(askButton);
colorDEBUG('Clicked to ask free gift');
} //else { colorDEBUG('freegift_ask_button NOT FOUND', cre); }
} else {
var sendButton = xpathFirst('.//a[contains(@class,"freegift_send_button") and contains(@onclick,"showGiftFriendSelector")]');
if(sendButton){
clickElement(sendButton);
setGMTime('requestTimer', '00:15');
colorDEBUG('Clicked to open showGiftFriendSelector - setting requestTimer to 15 secs');
} //else { colorDEBUG('freegift_send_button NOT FOUND', cre); }
}
} else {
GM_setValue('autoFreeGift',0);
GM_setValue('autoAskFreeGift',0);
colorDEBUG('The selected Free Gift could not be found, disabling ...', cre);
}
if(mode) setGMTime('autoAskFreeGiftTimer', '8 hours');
else setGMTime('autoFreeGiftTimer', '2 hours');
return false;
} catch (giftError){
colorDEBUG(giftError, cre);
}
}
function autoAskCityCrew(askCity){
Autoplay.delay = getAutoPlayDelay()
var cityName = cities[askCity][CITY_NAME];
var timerName = 'autoAskCityCrewTimer';
if(askCity==CHICAGO){ var timerName = 'autoAskChicagoCrewTimer'; }
if(city != askCity){
Autoplay.fx = function(){ goLocation(askCity) };;
Autoplay.start();
return true;
}
var tabno = 1;
if(!onJobTab(tabno)){
Autoplay.fx = function(){ goJobTab(tabno); };
Autoplay.start();
return true;
}
colorDEBUG('autoAskCityCrew - ON to '+cityName+'\'s Job Tab', cte);
var crewCount = 0;
var crewElt = xpathFirst('.//a[@id="btn_queue"]',innerPageElt);
if(crewElt){
crewCount = parseCash(crewElt.innerHTML.untag());
colorDEBUG("activateCrew - We have the following count for crew members: " + crewCount);
if(crewCount>15){
colorDEBUG("activateCrew - We have the following count for crew members: " + crewCount+ ' crew list FULL', cre);
setGMTime(timerName, '1 hour');
return false;
}
}
var askCityCrewButton = xpathFirst('.//a[@id="btn_crew_recruit" and not(contains(@style,"none"))]', innerPageElt);
if(askCityCrewButton){
colorDEBUG('autoAskCityCrew - Clicking btn_crew_recruit');
clickElement(askCityCrewButton);
}
askCityCrewButton = xpathFirst('.//a[@class="sexy_button_new sexy_button_new medium white mw_new_ajax" and contains(.,"Ask")]', innerPageElt);
if(askCityCrewButton){
colorDEBUG('autoAskCityCrew - Clicking Crew Ask button');
clickElement(askCityCrewButton);
setGMTime(timerName, '4 hours');
} else {
setGMTime(timerName, '1 hour');
}
return false;
}
function autoAskHelponCC(){
// Common function
var doAskFunction = function (askResult){
if(!askResult){
addToLog('warning Icon', 'Unable to Ask for Help on Crew Collections. Resetting Timer for 4 hours.');
setGMTime('autoAskHelponCCTimer', '4 hours');
}
};
// Go to the Inventory tab.
if(!onInventoryTab() && !onCollectionsTab()){
Autoplay.fx = function(){ doAskFunction(goInventoryNav()); };
Autoplay.start();
return true;
}
checkUserMafiaSize();
// Go to the Collections tab.
if(!onCollectionsTab()){
Autoplay.fx = function(){ doAskFunction(goCollectionsNav()); };
Autoplay.start();
return true;
}
var helpButtons;
var numButtons;
var timerLow = 999999;
var helpTimer = 0;
helpButtons = $x('.//a[@class="sexy_button_new short white sexy_call_new" and contains(@onclick, "SocialCollectionFeed")]', innerPageElt);
numButtons = helpButtons.length;
if(numButtons>0){
var askHelpFriends = xpathFirst('.//a[@class="sexy_button_new short white sexy_call_new" and contains(@onclick, "SocialCollectionFeed")]', innerPageElt);
if(askHelpFriends){
DEBUG('Clicked to Ask for Help on Crew Collection.');
clickAction = 'crew collection';
clickElement(askHelpFriends);
return true;
}
} else {
DEBUG('No Help on Crew Collection buttons found. Looking for Timers.');
helpButtons = $x('.//span[contains(@id, "soc_cal_timer")]', innerPageElt);
numButtons = helpButtons.length;
for(i=0;i';
var gmParamName = 'NYProperty'+building_type;
currentLevel = parseInt(GM_getValue(gmParamName, 999));
if(response[flashCount].level > currentLevel) GM_setValue(gmParamName, response[flashCount].level);
} else {
flashTxt += 'Reading Data for '+flashCount+ ' - ' +response[flashCount].name+'( type:'+building_type+' ) - level: '+ response[flashCount].level+', maxlevel: '+ response[flashCount].maxlevel+'
';
}
}
DEBUG(flashTxt);
var userBankBalance = parseFloat(GM_getValue('userBankBalance'));
if(isNaN(userBankBalance) || userBankBalance==0){
var ajaxID = createAjaxPage(true);
elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","remote/html_server.php?xw_controller=propertyV2&xw_action=buy&xw_city=1' +
'&building_type=2&requesttype=json", 1, 0, 0, 0); return false;'});
if(elt){
clickAction = 'autoUpgradeNY_getBalance';
clickElement(elt);
DEBUG('Clicked to get User Bank Balance');
return true;
}
}
for(var flashCount=0,iLength=response.length;flashCount=userMinBalance){
var ajaxID = createAjaxPage(true);
elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","remote/html_server.php?xw_controller=propertyV2&xw_action=buy&xw_city=1' +
'&building_type='+building_type+'&requesttype=json&fundtype=bank", 1, 0, 0, 0); return false;'});
if(elt){
clickAction = 'autoUpgradeNY';
clickContext = gmParamName;
clickElement(elt);
DEBUG('Clicked to upgrade '+flashCount+ ' - ' +response[flashCount].name);
return true;
}
} else {
if(currentLevel >= targetLevel){
addToLog('updateGood Icon', flashCount+ ' - ' +response[flashCount].name+' upgraded to selected maximum level. Disabling');
GM_setValue(gmAutoParamName,0);
} else {
addToLog('warning Icon', 'Insufficient funds ('+userBankBalance+' vs '+userMinBalance+') to upgrade '+flashCount+ ' - ' +response[flashCount].name+'.');
}
}
}
}
}
setGMTime('autoUpgradeNYTimer', '24 hours');
return false;
}
function askPropertyParts(partCount, partItem){
var partTitle = cityParts[partCount][ptTitle];
var partProp = cityParts[partCount][ptProp];
var partPropId = parseInt(cityParts[partCount][ptPropId]);
var partPropType = parseInt(cityParts[partCount][ptPropType]);
var partCity = cityParts[partCount][ptCity];
var partArray = cityParts[partCount][ptArray];
var partGMId = cityParts[partCount][ptGMId];
var partTimer = cityParts[partCount][ptTimer];
var timerReset = '12 hours';
var partItemName = partArray[partItem][0];
var partItemId = partArray[partItem][1];
if(partArray[partItem][3]) var partItemProp = partArray[partItem][3][0];
Autoplay.delay = 3000;
if(city != partCity){
Autoplay.fx = function(){ goLocation(partCity); };
Autoplay.start();
return true;
}
if(!onPropertyNav()){
Autoplay.fx = goPropertyNav;
Autoplay.start();
return true;
}
var elt;
switch(partPropType){
//format : /mwfb/remote/html_server.php?xw_controller=propertyV2&xw_action=sendItemFeedNews&xw_city=1&item=2184&building_type=13&xw_client_id=8
case 1 :
var flashCount = partPropId-1;
var flashvars = xpathFirst('//object[@id="properties_div"]/param[@name="flashvars"]');
if(flashvars && flashvars.value && flashCount<20){
var response = JSON.parse(unescape(flashvars.value).match(/&mw_data=(\[.+\])/)[1]);
colorDEBUG(response[flashCount].name+' - level: '+ response[flashCount].level+', maxlevel: '+ response[flashCount].maxlevel);
if(response[flashCount].level >= response[flashCount].maxlevel){
DEBUG(response[flashCount].name+' fully upgraded. No need to ask for parts. Disabling this setting.');
GM_setValue(partGMId, 'unchecked');
return false;
}
}
elt = makeElement('a', null, {'onclick':'return do_ajax("inner_page",'+
'"remote/html_server.php?xw_controller=propertyV2&' +
'xw_action=sendItemFeedNews&xw_city=1&item='+partItemId+'&building_type='+partPropType+'", 1, 0, 0, 0); return false;'});
Autoplay.fx = function(){
clickElement(elt);
addToLog('info Icon', 'Clicked to ask your Mafia to send you '+partItemName+'.');
};
break;
case 2 :
elt = makeElement('a', null, {'onclick':'return do_ajax("inner_page",'+
'"remote/html_server.php?xw_controller=propertyV2&' +
'xw_action=cs_special_item_feed_update_timestamp&xw_city=1", 1, 0, 0, 0); return false;'});
Autoplay.fx = function(){
clickElement(elt);
addToLog('info Icon', 'Clicked to ask your Mafia to send you '+partItemName+'.');
};
break;
}
if(elt){
Autoplay.start();
DEBUG('Ask for Parts - Ask for '+partItemName+' - '+partItemId+' success. Timer Reset : '+timerReset);
if(partTimer) setGMTime(partTimer, timerReset);
return true;
}
return false;
}
function askSpecialParts(itemCity, itemArray, itemIndex, buildType){
Autoplay.delay = 3000;
if(city != itemCity){
Autoplay.fx = function(){ goLocation(itemCity); };
Autoplay.start();
return true;
}
if(!onPropertyNav()){
Autoplay.fx = goPropertyNav;
Autoplay.start();
return true;
}
var elt;
var timerName;
var timerReset = '12 hours';
var buildSetting;
var buildItem;
switch(buildType){
case 1 : timerName = 'askCasinoPartsTimer'; buildSetting='askCasinoParts'; buildItem =itemArray[itemIndex][0]; break;
case 5 : timerName = 'askSpecialPartsTimer'; buildSetting='askSpecialParts'; buildItem =itemArray[itemIndex][0]; break;
case 11 : timerName = 'askShopPartsTimer'; buildSetting='askShopParts'; buildItem =itemArray[itemIndex][0]; break;
case 12 : timerName = 'askDepotPartsTimer'; buildSetting='askDepotParts'; buildItem =itemArray[itemIndex][0]; break;
case 13 : timerName = 'askArmorPartsTimer'; buildSetting='askArmorParts'; buildItem =itemArray[itemIndex][0]; break;
case 14 : timerName = 'askZooPartsTimer'; buildSetting='askZooParts'; buildItem =itemArray[itemIndex][0]; break;
case 15 : timerName = 'askVillagePartsTimer'; buildSetting='askVillageParts'; buildItem =itemArray[itemIndex][0]; break;
case 21 : timerName = 'askNewPartsTimer'; buildSetting='askNewParts'; buildItem =itemArray[itemIndex][0]; break;
case 101 : timerName = 'askBrazilPartsTimer'; buildSetting='askBrazilParts'; buildItem =itemArray[itemIndex][0]; break;
case 102 : timerName = 'askPlaySlotsTimer'; buildSetting='askPlaySlots'; buildItem ='Play Slots' ; break;
case 103 : timerName = 'askFootballFansTimer'; buildSetting='askFootballFans'; buildItem ='Football Fans' ; break;
case 200 : timerName = 'askChicagoPartsTimer'; buildSetting='askChicagoParts'; buildItem =itemArray[itemIndex][0]; break;
}
if(itemCity == NY){
if(buildType){
if(buildType==5){
elt = makeElement('a', null, {'onclick':'return do_ajax("inner_page",'+
'"remote/html_server.php?xw_controller=propertyV2&' +
'xw_action=cs_special_item_feed_update_timestamp&xw_city=1", 1, 0, 0, 0); return false;'});
} else if(buildType==21){
var propId=1;
var buildItemId = parseInt(itemArray[itemIndex][1])
if(buildItemId>=1792){
propId=2;
}
var ajaxID = createAjaxPage(true);
//format: html_server.php?xw_controller=LimitedTimeProperty&xw_action=postedPropertyFeed&xw_city=8&xw_person=42849033&target_id=p%7C42849033&tid=1317645268&part_id=1793&prop_id=4&key=26cd2fe84ee4425e2894ed50c652e777&xw_client_id=8 HTTP/1.1
elt = makeElement('a', null, {'onclick':'return do_ajax("'+ajaxID+'","'+SCRIPT.controller+'LimitedTimeProperty'+SCRIPT.action+'postedPropertyFeed'+SCRIPT.city+'1&city=1&prop_id='+propId+'&part_id='+buildItemId+'", 1, 0, 0, 0); return false;'});
Autoplay.fx = function(){
clickAction = 'new parts';
clickContext = itemCity;
clickElement(elt);
DEBUG('Clicked to ask for '+buildItem+' for '+propId+' (action: '+clickAction+' - context: '+clickContext);
};
Autoplay.start();
return true;
} else {
var flashCount = buildType-1;
// Chop Shop, Weapons Depot, Armory Parts and Private Zoo Parts
var flashvars = xpathFirst('//object[@id="properties_div"]/param[@name="flashvars"]');
if(flashvars && flashvars.value && flashCount<20){
var response = JSON.parse(unescape(flashvars.value).match(/&mw_data=(\[.+\])/)[1]);
if(response[flashCount].level < response[flashCount].maxlevel){
//DEBUG(response[flashCount].name+' - level: '+ response[flashCount].level+', maxlevel: '+ response[flashCount].maxlevel);
//format : /mwfb/remote/html_server.php?xw_controller=propertyV2&xw_action=sendItemFeedNews&xw_city=1&item=2184&building_type=13&xw_client_id=8 HTTP/1.1
elt = makeElement('a', null, {'onclick':'return do_ajax("inner_page",'+
'"remote/html_server.php?xw_controller=propertyV2&' +
'xw_action=sendItemFeedNews&xw_city=1&item='+itemArray[itemIndex][1]+'&building_type='+buildType+'", 1, 0, 0, 0); return false;'});
} else {
DEBUG(response[flashCount].name+' fully upgraded. No need to ask for parts. Disabling this setting.');
GM_setValue(buildSetting, 'unchecked');
}
} else {
//DEBUG('Ask for NY Parts - Flash seems disabled : Building Status not available');
elt = makeElement('a', null, {'onclick':'return do_ajax("inner_page",'+
'"remote/html_server.php?xw_controller=propertyV2&' +
'xw_action=sendItemFeedNews&xw_city=1&item='+itemArray[itemIndex][1]+'&building_type='+buildType+'", 1, 0, 0, 0); return false;'});
}
}
}
if(elt){
Autoplay.fx = function(){
clickElement(elt);
addToLog('info Icon', 'Clicked to ask your Mafia to send you '+buildItem+'.');
};
Autoplay.start();
DEBUG('Ask for Parts - Ask for '+buildType +' - '+buildItem+' success. Timer Reset : '+timerReset);
if(timerName) setGMTime(timerName, timerReset);
return true;
}
DEBUG('Ask for Parts - Failed to ask for '+buildType +' - '+buildItem+'. Timer Reset : 2 Hours.');
if(timerName) setGMTime(timerName, '2 hours');
return false;
}
if(itemCity == BRAZIL || itemCity == CHICAGO){
checkPropertyStatus(itemCity);
if(itemCity==BRAZIL){
var brazilReport = GM_getValue('brazilReport');
var itemTimer = 'askBrazilPartsTimer';
} else {
var brazilReport = GM_getValue('chicagoReport');
var itemTimer = 'askChicagoPartsTimer';
}
var linkCity = itemCity+1;
if(brazilReport){
brazilReport = brazilReport.replace(/\\/g, "");
var searchItem='"id":'+itemArray[itemIndex][1];
if(brazilReport.indexOf(searchItem) != -1){
// Parts Required format : {\"id\":1575,\"type\":1,\"quantity\":7}
var partsRequiredTxt = new RegExp(searchItem+',"type":1,"quantity":(.+?)}','gi');
var totalRequired=0, totalNeeded=0, totalOwned=0;
while(match = partsRequiredTxt.exec(brazilReport)){
totalRequired += parseInt(match[1]);
}
// Parts Owned format : {\"id\":1575,\"type\":1,\"name\":\"Cinder Block\",\"num_owned\":17,\"image_url\":\"http:\\\/\\\/mwfb.static.zynga.com\\\/mwfb\\\/graphics\\\/item_Cinderblock_01.gif\"}
var partsOwnedTxt = new RegExp(searchItem+',"type":1,"name":"'+buildItem+'","num_owned":(.+?),"image_url"','gi');
if(match = partsOwnedTxt.exec(brazilReport)){
totalOwned = parseInt(match[1]);
}
totalNeeded = totalRequired - totalOwned;
if(totalNeeded<=0){
addToLog('warning Icon','Asking for '+buildItem+' (Total Required: '+totalRequired+' - Already Owned: '+totalOwned+').');
} else {
addToLog('info Icon','Asking for '+buildItem+', still needing '+ totalNeeded+' (Total Required: '+totalRequired+' - Already Owned: '+totalOwned+').');
}
buildType = itemArray[itemIndex][2];
var ajaxID = createAjaxPage(true);
//format: html_server.php?xw_controller=propertyV2&xw_action=getAskForHelpFeed&xw_city=8&xw_person=43398787&city=8&building_type=2&item_type=1&item_id=11052&xw_client_id=8
//format: html_server.php?xw_controller=propertyV2&xw_action=getAskForHelpFeed&xw_city=7&xw_person=42849033&city=7&building_type=4&item_type=1&item_id=2678&xw_client_id=8
elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","'+ SCRIPT.controller+'propertyV2'+ SCRIPT.action+'getAskForHelpFeed'+ SCRIPT.city + linkCity+'&city='+linkCity+'&building_type='+ buildType+'&item_type=1&item_id='+ itemArray[itemIndex][1] +'", 1, 0, 0, 0); return false;'});
Autoplay.fx = function(){
clickAction = cities[itemCity][CITY_ALIAS]+' parts';
clickContext = itemCity;
clickElement(elt);
DEBUG('Clicked to ask for '+buildItem+' for '+buildType +' (action: '+clickAction+' - context: '+clickContext);
};
Autoplay.start();
return true;
}
}
DEBUG('Ask for '+cities[itemCity][CITY_NAME]+' Parts - Failed to ask for '+buildType +' - '+buildItem+'. Timer Reset : 2 hours.');
setGMTime(itemTimer, '2 hours');
return false;
}
if(itemCity == LV){
if(buildType==102){
var ajaxID = createAjaxPage(true);
elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","'+ SCRIPT.controller+'propertyV2'+ SCRIPT.action+'vslot_feed'+ SCRIPT.city+'5", 1, 0, 0, 0); return false;'});
Autoplay.fx = function(){
clickAction = 'play slots';
clickContext = itemCity;
clickElement(elt);
DEBUG('Clicked to ask for '+buildItem+' for '+buildType +' (action: '+clickAction+' - context: '+clickContext);
};
Autoplay.start();
return true;
} else {
checkPropertyStatus(LV);
var casinoReport = GM_getValue('casinoReport');
if(casinoReport){
casinoReport = casinoReport.replace(/\\/g, "");
//DEBUG('casinoReport: '+casinoReport);
var searchItem='"id":'+itemArray[itemIndex][1];
if(casinoReport.indexOf(searchItem) != -1){
// Parts Required format : {\"id\":1575,\"type\":1,\"quantity\":7}
var partsRequiredTxt = new RegExp(searchItem+',"type":1,"quantity":(.+?)}','gi');
var totalRequired=0, totalNeeded=0, totalOwned=0;
while(match = partsRequiredTxt.exec(casinoReport)){
totalRequired += parseInt(match[1]);
}
// Parts Owned format : {\"id\":1575,\"type\":1,\"name\":\"Cinder Block\",\"num_owned\":17,\"image_url\":\"http:\\\/\\\/mwfb.static.zynga.com\\\/mwfb\\\/graphics\\\/item_Cinderblock_01.gif\"}
var partsOwnedTxt = new RegExp(searchItem+',"type":1,"name":"'+buildItem+'","num_owned":(.+?),"image_url"','gi');
if(match = partsOwnedTxt.exec(casinoReport)){
totalOwned = parseInt(match[1]);
}
totalNeeded = totalRequired - totalOwned;
if(totalNeeded<=0){
addToLog('warning Icon','Asking for '+buildItem+' (Total Required: '+totalRequired+' - Already Owned: '+totalOwned+').');
} else {
addToLog('info Icon','Asking for '+buildItem+', still needing '+ totalNeeded+' (Total Required: '+totalRequired+' - Already Owned: '+totalOwned+').');
}
buildType = itemArray[itemIndex][2];
var ajaxID = createAjaxPage(true);
//format: html_server.php?xw_controller=propertyV2&xw_action=getAskForHelpFeed&xw_city=5&city=5&building_type=1&item_type=1&item_id=1575&xw_client_id=8
elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","'+ SCRIPT.controller+'propertyV2'+ SCRIPT.action+'getAskForHelpFeed'+ SCRIPT.city+'5&city=5&building_type='+ buildType+'&item_type=1&item_id='+ itemArray[itemIndex][1] +'", 1, 0, 0, 0); return false;'});
Autoplay.fx = function(){
clickAction = 'casino parts';
clickContext = itemCity;
clickElement(elt);
DEBUG('Clicked to ask for '+buildItem+' for '+buildType +' (action: '+clickAction+' - context: '+clickContext);
};
Autoplay.start();
return true;
}
}
DEBUG('Ask for Casino Parts - Failed to ask for '+buildType +' - '+buildItem+'. Timer Reset : 2 hours.');
setGMTime('askCasinoPartsTimer', '2 hours');
return false;
}
}
if(itemCity == ITALY){
if(buildType==103){
var ajaxID = createAjaxPage(true);
elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","'+ SCRIPT.controller+'propertyV2'+ SCRIPT.action+'customerFeed'+ SCRIPT.city+'6&city=6&prop=5", 1, 0, 0, 0); return false;'});
Autoplay.fx = function(){
clickAction = 'football fans';
clickContext = itemCity;
clickElement(elt);
DEBUG('Clicked to ask for '+buildItem+' for '+buildType +' (action: '+clickAction+' - context: '+clickContext);
};
Autoplay.start();
return true;
} else {
checkPropertyStatus(ITALY);
var villageReport = GM_getValue('villageReport');
if(villageReport){
villageReport = villageReport.replace(/\\/g, "");
var searchItem='"id":'+itemArray[itemIndex][1];
if(villageReport.indexOf(searchItem) != -1){
// Parts Required format : {\"id\":1575,\"type\":1,\"quantity\":7}
var partsRequiredTxt = new RegExp(searchItem+',"type":1,"quantity":(.+?)}','gi');
var totalRequired=0, totalNeeded=0, totalOwned=0;
while(match = partsRequiredTxt.exec(villageReport)){
totalRequired += parseInt(match[1]);
}
// Parts Owned format : {\"id\":1575,\"type\":1,\"name\":\"Cinder Block\",\"num_owned\":17,\"image_url\":\"http:\\\/\\\/mwfb.static.zynga.com\\\/mwfb\\\/graphics\\\/item_Cinderblock_01.gif\"}
var partsOwnedTxt = new RegExp(searchItem+',"type":1,"name":"'+buildItem+'","num_owned":(.+?),"image_url"','gi');
if(match = partsOwnedTxt.exec(villageReport)){
totalOwned = parseInt(match[1]);
}
totalNeeded = totalRequired - totalOwned;
if(totalNeeded<=0){
addToLog('warning Icon','Asking for '+buildItem+' (Total Required: '+totalRequired+' - Already Owned: '+totalOwned+').');
} else {
addToLog('info Icon','Asking for '+buildItem+', still needing '+ totalNeeded+' (Total Required: '+totalRequired+' - Already Owned: '+totalOwned+').');
}
buildType = itemArray[itemIndex][2];
var ajaxID = createAjaxPage(true);
//format: html_server.php?xw_controller=propertyV2&xw_action=getAskForHelpFeed&xw_city=5&city=5&building_type=1&item_type=1&item_id=1575&xw_client_id=8
elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","'+ SCRIPT.controller+'propertyV2'+ SCRIPT.action+'getAskForHelpFeed'+ SCRIPT.city+'6&city=6&building_type='+ buildType+'&item_type=1&item_id='+ itemArray[itemIndex][1] +'", 1, 0, 0, 0); return false;'});
Autoplay.fx = function(){
clickAction = 'village parts';
clickContext = itemCity;
clickElement(elt);
DEBUG('Clicked to ask for '+buildItem+' for '+buildType +' (action: '+clickAction+' - context: '+clickContext);
};
Autoplay.start();
return true;
}
}
DEBUG('Ask for Village Parts - Failed to ask for '+buildType +' - '+buildItem+'. Timer Reset : 2 hours.');
setGMTime('askVillagePartsTimer', '2 hours');
return false;
}
}
}
// Pass the item array and item id
function buildPropItem(propCount, propItem){
var propTitle = cityProperties[propCount][ctTitle];
var propGMId = cityProperties[propCount][ctGMId];
var propItemGMId = cityProperties[propCount][ctGMId]+'id';
var propText = cityProperties[propCount][ctText];
var propArray = cityProperties[propCount][ctArray];
var propType = cityProperties[propCount][ctPropType];
var propId = cityProperties[propCount][ctPropId];
var propTimer = cityProperties[propCount][ctPropTimer];
var propCity = cityProperties[propCount][ctPropCity];
var propName = cityProperties[propCount][ctPropName];
var propNamePlus = cityProperties[propCount][ctPropNamePlus];
Autoplay.delay = 3000;
if(city != propCity){
Autoplay.fx = function(){ goLocation(propCity); };
Autoplay.start();
return true;
}
if(!onPropertyNav()){
Autoplay.fx = goPropertyNav;
Autoplay.start();
return true;
}
switch(propType){
case 1:
// Build Chop Shop, Weapons Depot, Armory and Private Zoo Items
var elt = makeElement('a', null, {'onclick':'return do_ajax("inner_page",'+
'"remote/html_server.php?xw_controller=propertyV2&' +
'xw_action=craft&xw_city=1&recipe='+propArray[propItem][1]+'&building_type='+propId+'", 1, 0, 0, 0); return false;'});
if(elt){
Autoplay.fx = function(){
clickAction = 'build item';
clickContext = {itemName: propArray[propItem][0], buildType: propId, propCount: propCount};
clickElement(elt);
DEBUG('Clicked to build '+ clickContext.itemName+'.');
};
Autoplay.start();
return true;
}
break;
case 2:
// Active check
var flashvars = xpathFirst('//object[@id="properties_div"]/param[@name="flashvars"]');
if(flashvars && flashvars.value){
propValue = JSON.stringify(JSON.parse(unescape(flashvars.value).match(/&mw_data=(\[.+\])/)[1]));
if(propValue.indexOf(propNamePlus)!=-1){
colorDEBUG('propId: '+propId+' - '+propName+' already active.');
} else {
// Save changes to make property active
// form : html_server.php?xw_controller=LimitedTimeProperty&xw_action=saveProperties&xw_city=1&properties=weapons_depot,armory,private_zoo,chop_shop,2&xw_client_id=8
var saveString = 'armory,chop_shop,private_zoo,weapons_depot,'+propId;
var ajaxID = createAjaxPage(true);
var elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","'+ SCRIPT.controller+'LimitedTimeProperty'+ SCRIPT.action+'saveProperties'+ SCRIPT.city+'1&city=1&properties='+saveString+'", 1, 0, 0, 0); return false;'});
if(elt){
Autoplay.fx = function(){
clickAction = 'save properties';
clickContext = saveString;
clickElement(elt);
DEBUG('Clicked to save '+ saveString+'.');
};
Autoplay.start();
return true;
}
}
} else {
colorDEBUG('flashvars NOT FOUND');
}
// Build Sports Bar, Venetian Condo, Gun Shop, ClubHouse, Martial Arts, Cemetery, Garden, Cider House Items
// form: html_server.php?xw_controller=limitedTimeProperty&xw_action=build&xw_city=1&rec_id=1&prop_id=3&xw_client_id=8
var ajaxID = createAjaxPage(true);
var elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","'+ SCRIPT.controller+'limitedTimeProperty'+ SCRIPT.action+'build'+ SCRIPT.city+'1&city=1&prop_id='+propId+'&rec_id='+propArray[propItem][1]+'", 1, 0, 0, 0); return false;'});
if(elt){
Autoplay.fx = function(){
clickAction = 'build limited';
clickContext = {itemName: propArray[propItem][0], buildType: propId, propCount: propCount};
clickElement(elt);
DEBUG('Clicked to build '+ clickContext.itemName+' from '+clickContext.buildType+' = '+propId+'.');
};
Autoplay.start();
return true;
}
break;
case 3 :
case 4 :
case 5 :
var buildCity = propCity+1;
var ajaxID = createAjaxPage(true);
var elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","'+ SCRIPT.controller+'propertyV2'+ SCRIPT.action+'portBuyItem'+ SCRIPT.city + buildCity+'&city='+buildCity+'&building_type='+propId+'&id='+propArray[propItem][1]+'", 1, 1, 0, 0); return false;'});
if(elt){
Autoplay.fx = function(){
clickAction = 'build other';
clickContext = {itemName: propArray[propItem][0], buildType: propId, propCount: propCount};
clickElement(elt);
DEBUG('Clicked to build '+ clickContext.itemName+' from '+clickContext.buildType+' = '+propId+'.');
};
Autoplay.start();
return true;
}
break;
default :
return false;
break;
}
return false;
}
function checkPropertyStatus(propCity){
if(!propCity) return;
colorDEBUG('Checking Property Status for: '+cities[propCity][CITY_NAME]);
var linkCity = propCity+1;
var ajaxID = createAjaxPage(true);
var elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","'+ SCRIPT.controller+'propertyV2'+ SCRIPT.action+'createData'+ SCRIPT.city +linkCity+ '&city='+linkCity+'", 1, 1, 0, 0); return false;'});
Autoplay.fx = function(){
clickAction = 'check property';
clickContext = propCity;
clickElement(elt);
};
Autoplay.start();
return true;
}
function autoBossFight(theBoss){
Autoplay.delay = getAutoPlayDelay()
if(city != NY){
Autoplay.fx = function(){ goLocation(NY); };
Autoplay.start();
return true;
}
var fightTable = xpathFirst('.//table[@class="boss_fight"]');
if(!fightTable){
var tabno = theBoss;
if(!onJobTab(tabno)){
Autoplay.fx = function(){ goJobTab(tabno); };
Autoplay.start();
return true;
}
if(health < maxHealth){
Autoplay.fx = quickHeal();
clickAction = 'quick heal';
Autoplay.start();
return true;
}
var bossAttackButton = xpathFirst('.//a[contains(@href,"xw_controller=bossfight") and contains(@href,"boss='+theBoss+'")]');
if(bossAttackButton){
//colorDEBUG('autoBossFight - AttackButton FOUND');
clickElement(bossAttackButton);
return true;
}
} else {
Autoplay.delay = noDelay;
var bossAttackButton = xpathFirst('.//a[contains(@href,"xw_controller=bossfight") and contains(@href,"boss='+theBoss+'")]', fightTable);
if(bossAttackButton){
//colorDEBUG('autoBossFight - AttackButton FOUND - Attack');
clickElement(bossAttackButton);
return true;
} else {
var bossAttackButton = xpathFirst('.//a[contains(@href,"xw_controller=job") and contains(.,"Back to Jobs")]', fightTable);
if(bossAttackButton){
//colorDEBUG('autoBossFight - Back to Jobs');
var bossResult = bossAttackButton.parentNode.innerHTML;
if(bossResult.match(/(.+)
/,'')
bossResult = bossResult.replace(/
/g,'
')
addToLog('yeah Icon', bossResult)
clickElement(bossAttackButton);
}
}
}
return false;
}
function activateCrew(cityno){
if(city != cityno){
Autoplay.fx = function(){ goLocation(cityno); };
Autoplay.start();
return true;
}
var tabno = 1;
if(!onJobTab(tabno)){
Autoplay.fx = function(){ goJobTab(tabno); };
Autoplay.start();
return true;
}
// Do we have crew to allocate
var crewCount = 0;
var crewElt = xpathFirst('.//a[@id="btn_queue"]',innerPageElt);
if(crewElt){
crewCount = parseCash(crewElt.innerHTML.untag());
colorDEBUG("activateCrew - We have the following count for crew members: " + crewCount);
}
var j = 0;
if(crewCount){
for(i=1;i<=8;i++){
if(j>crewCount) break;
if(cityno==BRAZIL) selectCrewValue = 'selectBrazilCrew'+i;
else selectCrewValue = 'selectChicagoCrew'+i;
var selectCrewSlot = parseInt(GM_getValue(selectCrewValue,0));
if(selectCrewSlot){
colorDEBUG('activateCrew - Activate Slot: '+i+' - crew_type '+cityCrewTitles[selectCrewSlot][3]+' - crew_slot '+cityCrewTitles[selectCrewSlot][4]);
var taskmasterElt = xpathFirst('.//a[contains(@href,"crew_type='+cityCrewTitles[selectCrewSlot][3]+'") and contains(@href,"crew_slot='+cityCrewTitles[selectCrewSlot][4]+'")]', innerPageElt);
if(taskmasterElt){
colorDEBUG('activateCrew - Clicking Slot: '+i+' - '+GM_getValue(selectCrewValue,0));
clickElement(taskmasterElt);
j++;
} else {
colorDEBUG('activateCrew - Slot: '+i+' - '+GM_getValue(selectCrewValue,0)+' already active');
}
} else {
colorDEBUG('activateCrew - Skipping: '+i+' - '+GM_getValue(selectCrewValue,0));
}
}
} else { colorDEBUG('activateCrew - No Crew members available'); }
if(cityno==BRAZIL) setGMTime('activateBrazilCrewTimer', '1 hour');
else setGMTime('activateChicagoCrewTimer', '1 hour');
return false;
}
function autoSlotMachine(){
setGMTime('autoSlotTimer', '4 hours');
var myParams = 'ajax=1&liteload=1&clicks=1';
myParams += '&sf_xw_user_id='+ xw_user_id+'&sf_xw_sig='+ xw_sig;
ts = parseInt(new Date().getTime().toString().substring(0, 10));
cb = xw_user+ts;
GM_xmlhttpRequest({
method: 'POST',
url: document.location.protocol+'//facebook.mafiawars.zynga.com/mwfb/'+ SCRIPT.controller+'slotmachine'+ SCRIPT.action+'view'+ SCRIPT.city+'&xw_person='+ xw_user+'&xw_client_id=8&cb='+cb+'&ts='+ts ,
data: myParams,
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
onload: function(_responseDetails){
var i1, i2, flashvars;
var tmp = _responseDetails.responseText;
i1 = tmp.indexOf('flashvars = {');
if(i1!=-1){
i2 = tmp.indexOf('};',i1);
tmp = tmp.slice(i1,i2+2);
eval(tmp);
if(flashvars && flashvars.freeSpins){
slotSpins = flashvars.freeSpins;
slotBonus = flashvars.bonusMeter;
addToLog('info Icon', 'Slot Spins Remaining: ' + slotSpins+' Bonus Level: '+ slotBonus);
}
}
}
});
return false;
//if(xpathFirst('.//div[@id="slots_icon_cover" and contains(@onclick, "xw_controller=slotmachine&xw_action=view")]', mastheadElt)){
// var elt = xpathFirst('.//div[@id="slots_icon_cover" and contains(@onclick, "xw_controller=slotmachine&xw_action=view")]', mastheadElt);
// clickElement(elt);
// return true;
//} else {
// return false;
//}
}
function autoSlotBonus(){
// Collect the bonus..
var i1, i2, slotVars, flashvars;
if(slotBonus >= 20){
slotBonus = 0; // Just in case..
var ajaxID = createAjaxPage(true);
var elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","'+ SCRIPT.controller+'slotmachine'+ SCRIPT.action+'award_bonus", 1, 1, 0, 0); return false;'});
Autoplay.fx = function(){
clickAction = 'collect slotbonus';
clickElement(elt);
};
Autoplay.start();
return true;
} else {
DEBUG('Not at the correct bonus level');
}
return false;
}
function autoSlotPull(){
// This is called to start off the slot machine process..
var i1, i2, slotVars, flashvars;
if(slotSpins > 0){
slotSpins--; // Just in case..
var ajaxID = createAjaxPage(true);
var elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","'+ SCRIPT.controller+'slotmachine'+ SCRIPT.action+'spin&betAmt=1&friend_id=none", 1, 1, 0, 0); return false;'});
Autoplay.fx = function(){
clickAction = 'collect slot';
clickElement(elt);
};
Autoplay.start();
return true;
} else {
DEBUG('No spins left on the slot machine');
}
return false;
}
function autoBattleCollect(){
if(!onBattlePage(1)){
colorDEBUG('NOT on Battle Collect Page - going there');
// Go Battle Collect Page
goBattlePage(1);
} else {
colorDEBUG('Already on Battle Collect Page');
}
}
function autoBattle(){
// Are we on the clan page?
var clanId = GM_getValue('AutoBattleClanID',0);
if(clanId > 0 && !onClanNav(clanId)){
DEBUG("Not on Clan Page, go there");
goClanPage(clanId);
return;
}
if(clanId == 0){
DEBUG("No clan specified for AutoBattle");
return;
}
DEBUG("We passed going to the clan page");
}
function goBattlePage(battletype){
// 1 = Collect Page
// 2 = Default Page
var battleAction = (battletype==1)?'view_no_battle':'view';
var elt = makeElement('a', null, {'onclick':'return do_ajax("inner_page","remote/html_server.php?xw_controller=EpicBattle&xw_action='+battleAction+'", 1, 1, 0, 0); return false;'});
if(!elt){
addToLog('warning Icon', 'Can\'t make battle link to click.');
} else {
if(battletype==1){clickAction = 'load battlecollect';} else {clickAction = 'load battlepage';}
clickElement(elt);
DEBUG('Clicked to load Battle Page.');
}
return;
}
function onBattlePage(battletype){
// 1 = Collect Page
// 2 = Default Page
var battleAction = (battletype==1)?'battle_history':'battle_target_list';
DEBUG('Looking for:'+ battleAction);
if(xpathFirst('.//div[@id="'+battleAction+'"]', innerPageElt)){ DEBUG('Element :'+ battleAction+ ' found'); return true; }
DEBUG('Element :'+ battleAction+ ' NOT FOUND');
return false;
}
function goClanPage(clanID){
// Go to the clan page of the clan we want to start the battle for..
// Base64 the ID
clanID = btoa(clanID);
var elt = makeElement('a', null, {'onclick':'return do_ajax("inner_page","remote/html_server.php?xw_controller=clan&xw_action=view&id='+clanID+'", 1, 1, 0, 0); return false;'});
if(!elt){
addToLog('warning Icon', 'Can\'t make Clan link to click.');
} else {
clickAction = 'load clan';
clickElement(elt);
DEBUG('Clicked to load Clan Page.');
}
return;
}
function onClanNav(clanID){
// Return true if we're on the clan tab, false otherwise.
// If we pass a specific clanID, verify we are on that clan page
if(!clanID){
if(xpathFirst('.//div[@id="clan_main"]', innerPageElt)){ return true; }
} else {
if(xpathFirst('.//div[@id="clan_main"]', innerPageElt)){
//elt = xpathFirst('.//strong[@id="profile_link"]', innerPageElt);
if($('#profile_link').length){
DEBUG("On this clan page: " + $('#profile_link').text().replace(/"/g, '').trim());
//DEBUG("On this clan page: " + elt.innerHTML().replace(/"/g, '').trim());
} else {
DEBUG("On the wrong clan page?");
return false;
}
// On the clan page.. are we on the "right" clan page? Don't want to send the challenge to the wrong clan ;-)
return true;
}
}
return false;
}
function autoFamilyProgress(type){
// type = 1 is get the total experience we currently can see..
// type = 2 = click the smallest link higher than the exp needed to level.. or if we can't level, the largest link
if(!running) return 0;
var totalExp = 0;
var selectedExp = 0;
var currentExp = 0
// Grab the exp per level..
var rewardExp = [];
//var eltRewards = xpathFirst('.//div[@id=clan_xp_meter]//li[contains(@class, "quest_reward experience")]', questBarElt);
var eltRewards = xpathFirst('.//li[contains(@class, "quest_reward experience") and contains(., "Experience")]//dd', questBarElt);
if(eltRewards){
rewardExp = eltRewards.innerHTML.untag().replace('"','').trim().split(/\s+/);
//rewardExp.shift(); // Remove the Experience element
//for (var i = 0, iLength=rewardExp.length; i < iLength; ++i){
// DEBUG('Reward Amount: '+ rewardExp[i]);
//}
} else {
//DEBUG('Unable to locate rewards experience levels');
//if(type == 1){
return 0;
//}
}
// Grab what elements we can click.. //div[@id=clan_xp_meter]
var eltComplete = $x('.//li[contains(@class, "box_middle") and contains(@class, "complete") and not (contains(@class, "mastered")) and contains (., "Collect")]', questBarElt);
if(eltComplete){
var clickElt;
if(type == 2){DEBUG('We have '+ eltComplete.length+' complete family progressions');}
for (var i = 0, iLength=eltComplete.length; i < iLength; ++i){
var eltLevel = xpathFirst('.//span[contains(@class, "_star")]', eltComplete[i]);
if(eltLevel){
var mastery_level = eltLevel.getAttribute('class');
if(/bronze/.test(mastery_level)){
currentExp = parseInt(rewardExp[0]);
} else if(/silver/.test(mastery_level)){
currentExp = parseInt(rewardExp[1]);
} else if(/gold/.test(mastery_level)){
currentExp = parseInt(rewardExp[2]);
} else {
DEBUG('Unknown mastery family experience level: '+ mastery_level);
currentExp = 0;
}
//DEBUG('Level: '+ eltLevel.getAttribute('class'));
}
totalExp += currentExp; //Running total
//DEBUG('Current Exp: '+ currentExp+' Totel Exp: '+ totalExp);
var tmpElt = xpathFirst('.//a[contains(@href, "xw_action=collectProgress") and contains (., "Collect")]', eltComplete[i]);
if(tmpElt && type == 2){
//DEBUG('ptsToNextLevel:'+ ptsToNextLevel+' currentExp:'+ currentExp+' selectedExp'+ selectedExp);
if(
selectedExp == 0 || // We have't set another one yet
(ptsToNextLevel <= currentExp && selectedExp > currentExp) ||// We have a selection that will level us, but takes less exp than a previous selection
(ptsToNextLevel > currentExp && currentExp > selectedExp) // We don't have a selection that will level us, so take the largest exp gain.
){
// This is the element we want to click..
selectedExp = currentExp;
clickElt = tmpElt;
}
}
}
// Loop to determine which element to click is done..
if(type == 2 && clickElt && selectedExp > 0){
addToLog('info Icon', 'Collecting Family Experience: '+ selectedExp);
clickElement(clickElt);
return true;
}
} else {
if(type == 1){ return 0;}
}
if(type==1){ return totalExp;}
}
function autoCollectTake(takeCity){
if(isGMUndefined('collectCityAttempt')) GM_setValue ('collectCityAttempt', false);
if(isGMUndefined('propertyNavAttempt')) GM_setValue ('propertyNavAttempt', false);
// Go to the correct city.
if(city != takeCity){
if(GM_getValue('collectCityAttempt',false)){ //Tried to go to city, but failed. Reset and continue.
if(takeCity != 0){ // if New York, do not reset clock. Everyone SHOULD be able to collect from NY.
setGMTime('takeHour'+ cities[takeCity][CITY_NAME], '1 hour'); // reset clock to try again later.
}
GM_setValue ('collectCityAttempt', false);
return false;
}
GM_setValue ('collectCityAttempt', true);
Autoplay.fx = function(){goLocation(takeCity);};
Autoplay.start();
return true;
}
GM_setValue ('collectCityAttempt', false);
// Visit the property Nav
if(!onPropertyNav()){
if(GM_getValue('propertyNavAttempt',false)){ //Tried to go to properties, but failed. Reset and continue.
if(takeCity != 0){ // if New York, do not reset clock. Everyone SHOULD be able to collect from NY.
setGMTime('takeHour'+ cities[takeCity][CITY_NAME], '8 hours'); // reset clock to try again a day later.
}
GM_setValue ('propertyNavAttempt', false);
return false;
}
GM_setValue ('propertyNavAttempt', true);
Autoplay.fx = goPropertyNav;
Autoplay.start();
return true;
}
GM_setValue ('propertyNavAttempt', false);
var ajaxID = createAjaxPage(true);
var elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","'+ SCRIPT.controller+'propertyV2'+ SCRIPT.action+'collectall'+ SCRIPT.city + (takeCity+1)+'&requesttype=json", 1, 1, 0, 0); return false;'});
Autoplay.fx = function(){
clickAction = 'collect take';
clickContext = takeCity;
clickElement(elt);
};
Autoplay.start();
return true;
}
function autoPlayerUpdates(){
// Get the updates.
var pUpdates = xpath('.//div[@id="player_updates_all"]/div[@class="update_item"]', innerPageElt);
var pUpdatesLen = pUpdates.snapshotLength;
var logPlayerUpdatesCount = GM_getValue('logPlayerUpdatesCount');
if(isUndefined(logPlayerUpdatesCount)){
logPlayerUpdatesCount = pUpdatesLen;
GM_setValue('logPlayerUpdatesCount', logPlayerUpdatesCount);
}
if((pUpdatesLen > 0 && logPlayerUpdatesCount > pUpdatesLen) ||
(pUpdatesLen == 0 && logPlayerUpdatesCount > 0)){
if(pUpdatesLen > 0 && logPlayerUpdatesCount > pUpdatesLen){
DEBUG('Discrepancy in player updates; new count: '+ pUpdatesLen+', old count: '+ logPlayerUpdatesCount);
}
else { DEBUG('Player updates were cleared.'); }
logPlayerUpdatesCount = 0;
GM_setValue('logPlayerUpdatesCount', 0);
}
if(logPlayerUpdatesCount < pUpdatesLen){
DEBUG('Parsing new player updates.');
for (var i = pUpdatesLen - logPlayerUpdatesCount - 1; i >= 0; i--){
if(!parsePlayerUpdates(pUpdates.snapshotItem(i))) return true;
GM_setValue('logPlayerUpdatesCount', ++logPlayerUpdatesCount);
}
}
if(pUpdatesLen > GM_getValue('logPlayerUpdatesMax', 25) &&
logPlayerUpdatesCount == pUpdatesLen){
Autoplay.fx = goDeleteNews;
Autoplay.start();
return true;
}
return false;
}
function miniPackForce(){
if(!timeLeftGM('miniPackTimer')) setGMTime('miniPackTimer', '1 hour');
GM_setValue('miniPackFired', true);
DEBUG('Redirecting to use mini pack...');
GM_xmlhttpRequest({
method: 'GET',
url: 'http://toolbar.zynga.com/game_iframe_proxy.php?playing=true',
onload: function(_tbresponse){
if(_tbresponse.status == 200){
// Good to go.. now go to next step..
GM_xmlhttpRequest({
method: 'HEAD',
url: 'http://toolbar.zynga.com/click.php?to=mwgamestatsplaynow',
onload: function(_mwresponse){
if(_mwresponse.status == 302){
var loc = /Location: ([^\n]*)\n/.exec(response.responseHeaders)[1];
if(loc){
document.location.href = loc;
}
}
}
});
}
}
});
//window.location.replace('http://toolbar.zynga.com/click.php?to=mwgamestatsplaynow');
//window.location.href('http://toolbar.zynga.com/click.php?to=mwgamestatsplaynow');
//location.replace('http://toolbar.zynga.com/click.php?to=mwgamestatsplaynow');
return false;
}
function autoStatVars(){
var autoStatValues = new Array();
var upgradeKey='';
var upgradeAmt = 0;
var curStats = [curAttack,curDefense,maxHealth,maxEnergy,maxStamina];
var modeStats = [level,curAttack,curDefense,maxHealth,maxEnergy,maxStamina];
var statFallbacks = new Array(curStats.length);
var maxPtDiff = 0;
var statIndex = 0;
var statPrio = autoStatPrios.length;
for (var i = 0, iLength = curStats.length; i < iLength; ++i){
// Calculate the Points needed to reach target stat
var ratio = new Number(GM_getValue(autoStatRatios[i]));
var base = new Number(GM_getValue(autoStatBases[i]));
var curStatPrio = new Number(GM_getValue(autoStatPrios[i]));
var curStatDiff = Math.max (0, ratio * modeStats[GM_getValue(autoStatModes[i])] + base - curStats[i]);
// Account for priority
if((curStatDiff > 0 && curStatPrio < statPrio) || (curStatDiff > maxPtDiff && curStatPrio <= statPrio)){
maxPtDiff = curStatDiff;
statIndex = i;
statPrio = curStatPrio;
}
// Fallback method
statFallbacks[i] = isGMChecked(autoStatFallbacks[i]) ? i : '';
}
if(maxPtDiff <= 0 && isGMChecked('autoStatDisable')){
addToLog('info Icon', 'All status goals met, please update your goals.');
GM_setValue('autoStat', 0);
}
// Increment the status corresponding to the nextStat variable (fallback)
if(maxPtDiff <= 0){
if(statFallbacks.join('') != ''){
DEBUG('Status GOALS reached, using fallback method.', 10);
var nextStat = parseInt(GM_getValue('nextStat', ATTACK_STAT));
// Search for next Stat to increment
while (statFallbacks.indexOf(nextStat) == -1){ nextStat = (nextStat + 1) % curStats.length; }
statIndex = nextStat;
} else {
DEBUG('Status GOALS reached, waiting till next level up.');
GM_setValue('restAutoStat', 1);
}
} else {
DEBUG('Next stat to increment : '+ autoStatDescrips[statIndex + 1]+' ('+ maxPtDiff+' points to goal) ');
GM_setValue('restAutoStat', 0);
}
// Add stats to the attribute farthest from the goal (or the nextStat if fallback kicked in)
switch (statIndex){
case ATTACK_STAT : upgradeKey = 'attack'; break;
case DEFENSE_STAT : upgradeKey = 'defense'; break;
case HEALTH_STAT : upgradeKey = 'max_health'; break;
case ENERGY_STAT : upgradeKey = 'max_energy'; break;
case STAMINA_STAT : upgradeKey = 'max_stamina'; break;
}
upgradeAmt = (stats > 4 && (maxPtDiff > 4 || maxPtDiff <= 0))? 5 : 1;
autoStatValues[0] = upgradeKey;
autoStatValues[1] = upgradeAmt;
return autoStatValues;
}
function autoStat(){
if(!onProfileNav() || isUndefined(curAttack)){
Autoplay.fx = goMyProfile;
Autoplay.start();
return true;
}
if(onProfileNav()){
var autoStatValues = new Array;
autoStatValues = autoStatVars();
DEBUG('AutoStat upgrading '+autoStatValues[0]+ ' - '+autoStatValues[1]);
if(autoStatValues[0]!='' && autoStatValues[1]!=0){
var upgradeElt = xpathFirst('.//a[contains(@onclick,"upgrade_key='+autoStatValues[0]+'") and contains(@onclick,"upgrade_amt='+autoStatValues[1]+'")]', innerPageElt);
// Try to fallback to 1 skill point button
if(!upgradeElt){
upgradeElt = xpathFirst('.//a[contains(@onclick,"upgrade_key='+autoStatValues[0]+'")]', innerPageElt);
}
if(!upgradeElt){
DEBUG('Couldn\'t find link to upgrade stat.');
return false;
}
Autoplay.fx = function(){
clickAction = 'stats';
clickElement(upgradeElt);
DEBUG('Clicked to upgrade: '+ autoStatDescrips[statIndex + 1]);
};
Autoplay.delay = getAutoPlayDelay()
Autoplay.start();
return true;
} else {
return false;
}
} else {
GM_setValue('autoStat', 0);
colorDEBUG('BUG DETECTED: Unable to load Profile page, autostat disabled.');
return false;
}
}
// Get reward to cost ratio:
function calcJobratio(job){
var ratio = Math.round(missions[job][MISSION_XP] / missions[job][MISSION_ENERGY] * 100) / 100;
ratio = isNaN(ratio) ? 0 : ratio;
missions[job][MISSION_RATIO] = ratio;
GM_setValue('missions', JSON.stringify(missions));
return ratio;
}
// Retrieve if and how much energy can be salvaged for the next level (eg after spending an energy pack)
function canSalvageEnergy(job){
if(energy <= maxEnergy) return false;
var amount = energy - (Math.ceil((ptsToNextLevel) / missions[job][MISSION_XP]) * missions[job][MISSION_ENERGY]) - maxEnergy;
if(amount > 0) return amount;
else return false;
}
function canSalvageStamina(job){
if(stamina <= maxStamina) return false;
var amount = stamina - (Math.ceil((ptsToNextLevel) / missions[job][MISSION_XP]) * missions[job][MISSION_ENERGY]) - maxStamina;
if(amount > 0) return amount;
else return false;
}
function canMission(){
if(!energy) return false;
if(!isGMChecked('autoMission')) return false;
var i, job;
if(getSavedList('jobsToDo').length == 0){
var availableJobs = eval('('+ GM_getValue('availableJobs', '({0:{},1:{},2:{},3:{},4:{},5:{},6:{},7:{},8:{}})')+')');
var masteredJobs = eval('('+ GM_getValue('masteredJobs', '({0:{},1:{},2:{},3:{},4:{},5:{},6:{},7:{},8:{}})')+')');
var expLeft = ptsToNextLevel;
var ratio = Math.ceil(expLeft / energy * 100) / 100;
var multiple_jobs_list = getSavedList('selectMissionMultiple');
var multiple_jobs_ratio_sorted = [];
var jobs_selection = [];
var singleJobLevelUp = [];
var enoughEnergy = false;
var canSalvage = false;
function canMissionJobCheck(canMissionJobArray){
for (i = 0, iLength= canMissionJobArray.length; i < iLength; ++i){
job = canMissionJobArray[i];
var mission = missions[job];
if(!mission) continue;
// This should enable us to use mastery jobs for single job level ups
var singleJobLevelUpPossible = false;
// Ignore jobs that are not yet available
if(availableJobs[mission[MISSION_CITY]][mission[MISSION_TAB]] != null &&
availableJobs[mission[MISSION_CITY]][mission[MISSION_TAB]].indexOf(parseInt(job)) == -1){
continue;
}
// Determine the job's experience-to-energy ratio.
if(isNaN(mission[MISSION_RATIO]) || !mission[MISSION_RATIO]) mission[MISSION_RATIO] = calcJobratio(job);
if(mission[MISSION_ENERGY] <= energy){
enoughEnergy = true;
if(mission[MISSION_XP] >= expLeft){
var levelJob = [job, mission[MISSION_ENERGY], mission[MISSION_XP]];
singleJobLevelUp.push(levelJob);
singleJobLevelUpPossible = true;
}
}
if(!isGMChecked('repeatJob')){
// Ignore mastered jobs unless it can do a single job level up
if(masteredJobs[mission[MISSION_CITY]][mission[MISSION_TAB]] != null &&
masteredJobs[mission[MISSION_CITY]][mission[MISSION_TAB]].indexOf(parseInt(job)) != -1 &&
singleJobLevelUpPossible == false){
continue;
}
}
// Can salvage energy with this job
if(!canSalvage && canSalvageEnergy(job)) canSalvage = true;
multiple_jobs_ratio_sorted.push(job);
}
}
// mission mastery code
var mastery_jobs_list = getSavedList('masteryJobsList');
for (i = 0, iLength=mastery_jobs_list.length; i < iLength; ++i){
// Filters jobs on the ignorelist
job = mastery_jobs_list[i];
// Only push jobs that do not exist on the main list
if(multiple_jobs_list.indexOf(job) == -1) multiple_jobs_list.push(job);
}
canMissionJobCheck(multiple_jobs_list);
if(!enoughEnergy){
if(isGMChecked('endLevelOptimize') && ratio <= 2.2){
multiple_jobs_list = [];
for (i = 0, iLength=missions.length; i < iLength; ++i){
if(missions[i][MISSION_XP] > expLeft && missions[i][MISSION_ENERGY] < energy){
multiple_jobs_list.push(i);
}
}
canMissionJobCheck(multiple_jobs_list);
if(!enoughEnergy) return false;
} else return false;
}
var doJob;
multiple_jobs_ratio_sorted.sort(function(a, b){ return missions[b][MISSION_RATIO] - missions[a][MISSION_RATIO]; });
// Don't do expBurners or biggest exp job if energy can be salvaged
if(singleJobLevelUp.length > 0 && !canSalvage){
singleJobLevelUp.sort(function(a, b){ return b[2] - a[2]; });
// One job is enough to level up. Pick the one that pays the most.
doJob = singleJobLevelUp[0][0];
if(isGMChecked('endLevelOptimize')){
// Get the exp burner from the missions array
if(isGMChecked('endLevelNYOnly')) {
var expBurnFilter = function(v, i, a){ return (i > 6 && i < singleJobLevelUp[0][0] && a[i][MISSION_EOL] && a[i][MISSION_CITY] == NY && a[i][MISSION_ENERGY] < singleJobLevelUp[0][1] * 0.5) ? 1:0; };
}
else var expBurnFilter = function(v, i, a){ return (i > 6 && i < singleJobLevelUp[0][0] && a[i][MISSION_ENERGY] && a[i][1] < singleJobLevelUp[0][1] * 0.5) ? 1:0; };
var expBurners = missions.filter(expBurnFilter);
expBurners.sort(function(a, b){ return b[MISSION_XP] - a[MISSION_XP]; });
// Burn up exp before leveling up to maximize energy
for (var i = 0, iLength=expBurners.length; i < iLength; ++i){
var expBurner = expBurners[i];
if( (energy - singleJobLevelUp[0][1]) > expBurner[1] && expLeft >= (Math.floor(expBurner[5]) * 1.5)+1){
doJob = missions.searchArray(expBurner[0], 0)[0];
jobOptimizeOn = true;
break;
}
}
}
} else {
// Can't level up. Pick a job we can do whose ratio is high enough.
for (i = 0; i < multiple_jobs_ratio_sorted.length; i++){
if(energy >= missions[multiple_jobs_ratio_sorted[i]][MISSION_ENERGY] && ratio <= missions[multiple_jobs_ratio_sorted[i]][MISSION_RATIO]){
jobs_selection.push(multiple_jobs_ratio_sorted[i]);
}
}
if(jobs_selection.length == 0){
// No jobs meet the ratio necessary to level up. Go with the highest.
doJob = multiple_jobs_ratio_sorted[0];
} else {
// Pick the one with the lowest ratio.
if(!canSalvage) doJob = jobs_selection[jobs_selection.length-1];
// Energy can be salvaged, pick the one with the highest ratio
else doJob = jobs_selection[0];
}
}
if(GM_getValue('selectMission') != doJob){
if(isUndefined(doJob)){
colorDEBUG('No jobs selected.', cre);
return false;
} else {
addToLog('info Icon', 'Switching job to '+ missions[doJob][MISSION_NAME]+'. (canMission)');
GM_setValue('selectMission', doJob);
}
}
}
if(energy < missions[GM_getValue('selectMission', 1)][MISSION_ENERGY]){
DEBUG('Skipping jobs: energy='+ energy+', cost='+ missions[GM_getValue('selectMission', 1)][MISSION_ENERGY]);
return false;
}
// If spending energy will set energy below Energy floor, skip jobs
var nextJobEnergy = missions[GM_getValue('selectMission', 1)][MISSION_ENERGY];
//needchange
if(energy - nextJobEnergy < SpendEnergy.floor && !SpendEnergy.canBurn){
DEBUG('Not spending Job energy: energy='+ energy + ', floor='+ SpendEnergy.floor + ', nextJobEnergy='+ nextJobEnergy + ', burn='+ SpendEnergy.canBurn);
return false;
}
//needchange
if(energy < SpendEnergy.ceiling && !SpendEnergy.canBurn && !GM_getValue('useEnergyStarted')){
DEBUG('Rebuilding energy: energy='+ energy + ', ceiling='+ SpendEnergy.ceiling+', burn='+ SpendEnergy.canBurn);
return false;
}
return true;
}
function autoMission(){
Autoplay.delay = getAutoPlayDelay()
// Common function if job has failed
var doJobFunction = function (jobResult){
if(!jobResult){
addToLog('warning Icon', 'Unable to perform job '+ jobName+'.');
var jobs = getSavedList('jobsToDo', '');
if(jobs.length == 0){
// Skip jobs temporarily, and check the home page
DEBUG('No more jobs to perform.');
skipJobs = true;
goHome();
return;
} else {
// Else Get the next job to perform
DEBUG('Looking for the next job to perform.');
popJob();
return true;
}
}
};
jobid = GM_getValue('selectMission', 1);
var jobName = missions[jobid][MISSION_NAME];
var jobno = missions[jobid][MISSION_NUMBER];
var tabno = missions[jobid][MISSION_TAB];
var cityno = missions[jobid][MISSION_CITY];
var tabnopath = missions[jobid][MISSION_TABPATH];
var nodelv = missions[jobid][MISSION_NODE_LV];
if(!tabnopath) tabnopath = 0 ;
if(!nodelv) nodelv = '' ;
//colorDEBUG('AutoMission - '+ jobid+' - '+ jobName+' - '+ jobno+' (tabno: '+ tabno+', city: '+ cityno+', tabnopath '+ tabnopath +')', cte);
if(SpendEnergy.floor && isGMChecked('allowEnergyToLevelUp') && GM_getValue('autoEnergyBurn') !== SpendEnergy.canBurn){
GM_setValue('autoEnergyBurn', SpendEnergy.canBurn);
if(SpendEnergy.canBurn){
addToLog('process Icon', energyIcon+'Burning through energy reserve to level up.');
} else { DEBUG('Not within reach of a level up. Energy burning is off.'); }
}
if(city != cityno){
Autoplay.fx = function(){ goLocation(cityno); };
Autoplay.start();
return true;
}
var newtab = tabno;
if((city == BRAZIL||city==CHICAGO) && tabnopath){
newtab = tabnopath;
tabnopath=0;
}
if(!onJobTab(newtab)){
Autoplay.fx = function(){ goJobTab(newtab); };
Autoplay.start();
return true;
}
if(city == LV||city==ITALY){
if(!onJobTabpath(tabnopath)){
Autoplay.fx = function(){ goJobTabPath(tabnopath); };
Autoplay.start();
return true;
}
}
if(getJobRowItems(jobName)){
if(jobid != GM_getValue('selectMission', 1)) Autoplay.fx = autoMission;
Autoplay.start();
return;
}
DEBUG('City: '+ cities[cityno][CITY_NAME] +', District/Region :'+ missionTabs[cityno][tabno - 1] +', job type :'+ tabMode[tabnopath]+', Job Name :'+ jobName );
// Do the job
Autoplay.fx = function(){ doJobFunction(goJob(jobno)); };
Autoplay.start();
return true;
}
function getCurrentBrazilDistrict(){
currentBrazilDistrict = 0;
var jobContainer = xpathFirst('.//div[@id="brazil_jobs"]//div[@class="jobs" and not(contains(@style,"none"))]', innerPageElt);
if(jobContainer){
var jobContainerParent = jobContainer.parentNode;
if(jobContainerParent.hasAttribute('district_id')) currentBrazilDistrict = jobContainerParent.getAttribute('district_id');
}
if(!currentBrazilDistrict){
var districtElt = xpathFirst('.//div[@id="brazil_jobs"]/div[@class="districts"]', innerPageElt);
if(districtElt){
if(districtElt.hasAttribute('style')){
if(districtElt.getAttribute('style').match(/: -?(\d+)px/)){
var marginBot = RegExp.$2;
if(marginBot) currentBrazilDistrict = parseInt((RegExp.$1/54)+1)
}
}
}
}
return currentBrazilDistrict;
}
function currentJobTab(){
if(city==BRAZIL || city == CHICAGO){ return parseInt(getCurrentBrazilDistrict()); }
var elt = xpathFirst('.//li[contains(@class, "tab_on")]//a', innerPageElt);
if(elt && elt.getAttribute('onclick').match(/tab=(\d+)/)) return RegExp.$1;
return -1;
}
// current Job Tab path
function currentJobTabPath(){
var elt = xpathFirst('.//div[contains(@class, "path_on")]', innerPageElt);
if(elt && elt.id.match(/(\d+)/)) return RegExp.$1;
return -1;
}
function onJobTab(tabno){ return currentJobTab() == parseInt(tabno) ? true : false; }
function onJobTabpath(tabnopath){ return currentJobTabPath() == parseInt(tabnopath) ? true : false; }
function canForceHeal(){
if(!isGMChecked('hideInHospital')){ return true; }
// bypass all lower HiH settings and heal while health is above 19 and below 'need to heal minium'
if((health > 19) && isGMChecked('forceHealOpt7') ){
DEBUG( 'heal if above 19 is checked, and true, in canforceheal ');
return true;
}
// if able to level up on stamina and checked to do so, bypass HiH
if((SpendStamina.canBurn && stamina > 0) && isGMChecked('allowStaminaToLevelUp') ){
DEBUG( 'enough stamina left to level up, and burn to level up, checked in canforceheal ');
return true;
}
// Heal after 5 minutes
if(isGMChecked('forceHealOpt5') && GM_getValue('healWaitStarted') && timeLeftGM('healWaitTime')){
DEBUG( ' healing blocked '+ GM_getValue('healWaitStarted')+' due to 5 minute wait timer. remaining:'+ timeLeftGM('healWaitTime') );
return false;
} else {
if(isGMChecked('forceHealOpt5')){
DEBUG( '5 minute timer is up, Allowing Heal');
GM_setValue('healWaitStarted',false);
return true;
}
}
// Heal when stamina is full
if(isGMChecked('forceHealOpt4') && stamina >= maxStamina){ return true; }
// Heal when stamina can be spent
if(isGMChecked('forceHealOpt3') && canSpendStamina(0)){ return true; }
return false;
}
function canSpendStamina(minHealth){
if(!stamina) return false;
if(!isGMChecked('staminaSpend')) return false;
if(stamina < 5 && (GM_getValue('fightLocation', NY) == BRAZIL || GM_getValue('fightLocation', NY) == CHICAGO)){
DEBUG('Not spending stamina: stamina = '+ stamina+', fight city = '+ cities[BRAZIL][CITY_NAME]);
return false;
}
var stamMode = getStaminaMode();
//if(inClanBattle && isGMChecked('AutoBattleFight')) stamMode = STAMINA_HOW_BATTLE;
// Up to 28 damage can be received in a fight.
if(isNaN(minHealth)) {
minHealth = isGMChecked('attackCritical') ? 21 : 29; // 20 works on fight page, need 21 to hit from profile page.
switch (stamMode){
case STAMINA_HOW_AUTOHITLIST:
case STAMINA_HOW_ROBBING:
minHealth = 0;
break;
case STAMINA_HOW_FIGHTROB:
if(stamina > 25) minHealth = 0;
break;
case STAMINA_HOW_ROBFIGHT: //New stamina mode
if(stamina > GM_getValue('robFightStaminaFloor')) minHealth = 0;
break;
}
}
if(health < minHealth){
DEBUG('Not spending stamina: health='+ health+', minimum='+ minHealth);
return false;
}
if(stamina <= SpendStamina.floor && !SpendStamina.canBurn){
DEBUG('Not spending stamina: stamina='+ stamina+', floor='+ SpendStamina.floor+', burn='+ SpendStamina.canBurn);
return false;
}
if(stamina < SpendStamina.ceiling && !SpendStamina.canBurn && !GM_getValue('useStaminaStarted')){
DEBUG('Rebuilding stamina: stamina='+ stamina+', ceiling='+ SpendStamina.ceiling+', burn='+ SpendStamina.canBurn);
return false;
}
// Only spend if stamina >= 20
if(GM_getValue('staminaSpendHow') != STAMINA_HOW_RANDOM && (stamMode == STAMINA_HOW_ROBBING || stamMode == STAMINA_HOW_FIGHTROB) )
return (stamina >= 25);
else if(stamMode == STAMINA_HOW_ROBBING || stamMode == STAMINA_HOW_FIGHTROB){
if(stamina >= 25) return true;
else {
randomizeStamina();
return canSpendStamina();
}
}
return true;
}
function autoHitlist(){
var loc = GM_getValue('autoHitListLoc', NY);
if(loc <= cities.length-1 && city != loc){
Autoplay.fx = function(){ goLocation(loc); };
Autoplay.delay = getAutoPlayDelay();
Autoplay.start();
return true;
}
if(!onFightTab() && !autoHitlist.profileSearch && !autoHitlist.setBounty){
Autoplay.fx = goFightTab;
Autoplay.start();
return true;
}
checkUserMafiaSize();
// Go to the opponent's profile.
var id = parseInt(GM_getValue('pautoHitOpponentList', ''));
if(!id){
// If nothing is here, and fighting is "random", fight someone else
if(isGMEqual('staminaSpendHow', STAMINA_HOW_RANDOM)) return false;
// The user-specified list is empty or invalid.
addToLog('warning Icon', 'Can\'t autohit because the list of opponents is empty or invalid. Turning automatic hitlisting off.');
GM_setValue('staminaSpend', 0);
if(isGMChecked('bgAutoHitCheck')) GM_setValue('bgAutoHitCheck',0);
return false;
}
opponent = new Player();
opponent.id = String(id);
if(!onProfileNav() && !autoHitlist.setBounty){
autoHitlist.profileSearch = opponent;
Autoplay.fx = function(){ goProfileNav(opponent); };
Autoplay.start();
return true;
}
if(autoHitlist.profileSearch && onProfileNav()){
opponent = autoHitlist.profileSearch;
autoHitlist.profileSearch = undefined;
opponent.profileHitlist = xpathFirst('.//a[contains(., "Add to Hitlist")]', innerPageElt);
DEBUG('Hitlisting from profile');
var hitlistElt = opponent.profileHitlist;
autoHitlist.setBounty = true;
var elt = xpathFirst('.//a[contains(., "Add to Hitlist")]', innerPageElt);
if(elt){
Autoplay.fx = function(){
clickAction = 'autohit';
clickContext = opponent;
clickElement(elt);
DEBUG('Clicked "Add to Hitlist".');
};
Autoplay.start();
return true;
}
}
var cashDiff = parseCash(GM_getValue('autoHitListBounty', 0)) - cities[NY][CITY_CASH];
// Withdraw the amount we need
if(cashDiff > 0){
DEBUG('We need '+cashDiff+' for hitlisting. Going to the bank of '+cities[NY][CITY_NAME]);
suspendBank = true;
return (autoBankWithdraw(cashDiff));
}
if(autoHitlist.setBounty){
autoHitlist.setBounty = undefined;
var formElt = xpathFirst('.//form[@id="createhit"]', innerPageElt);
var amountElt = xpathFirst('.//input[@type="text"]', formElt);
if(!amountElt){
if(isGMChecked('bgAutoHitCheck')) setGMTime("bgAutoHitTime", "01:00");
return true;
}
if(isGMChecked('autoHitListRandom')){ amountElt.value = Math.pow(10, (Math.floor(Math.random()*4)+4)); }
else { amountElt.value = parseCash(GM_getValue('autoHitListBounty', 0)); }
var submitElt = xpathFirst('.//button[@type="submit"]', formElt);
if(!submitElt){
if(isGMChecked('bgAutoHitCheck')) setGMTime("bgAutoHitTime", "01:00");
return true;
}
Autoplay.fx = function(){
clickAction = 'autohit';
clickContext = opponent;
submitElt.click();
DEBUG('Clicked to Set Bounty');
};
Autoplay.start();
return true;
}
}
function checkUserMafiaSize(){
if(mafia) return;
if(!mafia){
mafia = GM_getValue('userMafiaSize', 0);
if(!mafia || mafia < 501){
var mafiaSizeElt = xpathFirst('//div[@class="fightbar_group_stat"]//img[@title="Mafia Size"]');
if(mafiaSizeElt){
mafiaSizeElt = mafiaSizeElt.parentNode;
var mafiaSize = parseInt(mafiaSizeElt.innerHTML.untag());
if(mafiaSize){
mafia = mafiaSize;
GM_setValue('userMafiaSize', mafia);
DEBUG('userMafiaSize updated to:'+mafia);
}
}
}
}
}
function autoFight(how){
Autoplay.delay = getAutoPlayDelay();
var loc = GM_getValue('fightLocation', NY);
if( loc == RANDOM_CITY){ loc = GM_getValue('fightNewLocation', NY); }
if(loc != ACTIVE_CITY && city != loc){
Autoplay.fx = function(){ goLocation(loc); };
Autoplay.start();
return true;
}
if(!onFightTab() && !autoFight.profileSearch && how != STAMINA_HOW_BATTLE){
Autoplay.fx = goFightTab;
Autoplay.start();
return true;
}
if(how==STAMINA_HOW_BATTLE && !onBattlePage(2)){
DEBUG('Battle Type, but not on battle page.. go there');
Autoplay.fx = goBattlePage(2);
Autoplay.start();
return true;
}
if(how==STAMINA_HOW_BATTLE && xpathFirst('//a[contains(@href,"xw_controller=epicBattle") and contains(@href,"xw_action=optIn")]',innerPageElt)){
// Opt-in To battle..
elt = xpathFirst('//a[contains(@href,"xw_controller=epicBattle") and contains(@href,"xw_action=optIn")]',innerPageElt);
clickElement(elt);
Autoplay.start();
return true;
}
checkUserMafiaSize();
// Now visit the Rivals tab if Fight Rivals is selected
var fightMode = GM_getValue('fightRivalsMode', 0)
if(onFightersTab() && !autoFight.profileSearch && fightMode && how != STAMINA_HOW_BATTLE){
Autoplay.fx = goRivalsTab;
Autoplay.start();
return true;
}
// Now visit the Fighters tab if Fight Random Opponents
if(onRivalsTab() && !autoFight.profileSearch && !fightMode && how != STAMINA_HOW_BATTLE){
Autoplay.fx = goFightersTab;
Autoplay.start();
return true;
}
var opponent;
if(autoFight.revengeTarget){
colorDEBUG('autoFight - We already have a target : revengeTarget');
opponent = autoFight.revengeTarget;
autoFight.revengeTarget = undefined;
lastOpponent = undefined;
} else if(autoFight.profileSearch && onProfileNav()){
opponent = autoFight.profileSearch;
colorDEBUG('autoFight - We already have a target : profileSearch - checking');
var removeElt = xpathFirst('.//a[contains(., "Remove from Mafia")]', innerPageElt);
if(removeElt){
colorDEBUG('Opponent in Mafia ... removing :'+opponent.id);
removeSavedListItem('pfightlist', opponent.id);
autoFight.profileSearch = undefined;
lastOpponent = undefined;
return false;
} else {
colorDEBUG('Opponent NOT in Mafia fighting :'+opponent.id);
autoFight.profileSearch = undefined;
lastOpponent = undefined;
if(isGMChecked('staminaPowerattack') && ((isGMChecked('stopPA') && health >= GM_getValue('stopPAHealth')) || !isGMChecked('stopPA')))
opponent.profileAttack = xpathFirst('.//a[(contains(@onclick,"xw_action=power_attack") or contains(@href,"xw_action=power_attack")) and contains(., "Power Attack")]', innerPageElt);
if(!opponent.profileAttack)
opponent.profileAttack = xpathFirst('.//a[(contains(@onclick,"xw_action=attack") or contains(@href,"xw_action=attack")) and contains(., "Attack")]', innerPageElt);
var titleElement = xpathFirst('//div[@class="stats_title_text"]');
if(titleElement){
if(titleElement.innerHTML.match(/[^"]"(.+)" level (\d+)/)){
opponent.name = RegExp.$1;
opponent.level = RegExp.$2;
}
}
opponent.mafia = 'unknown';
//opponent.faction = 'unknown';
}
} else if(how == STAMINA_HOW_FIGHT_LIST){
id = parseInt(GM_getValue('pfightlist', ''));
DEBUG('autoFight : Using pfightlist');
if(!id){
// If nothing is here, and fighting is "random", fight someone else
if(isGMEqual('staminaSpendHow', STAMINA_HOW_RANDOM)) return false;
// The user-specified list is empty or invalid.
addToLog('warning Icon', 'Can\'t fight because the list of opponents is empty or invalid. Turning automatic fighting off.');
GM_setValue('staminaSpend', 0);
return false;
}
opponent = new Player();
opponent.id = String(id);
} else {
// Check for any new opponents.
opponent = findFightOpponent(innerPageElt,how);
if(opponent === -1){
DEBUG('No opponents even after seeing the fight list.');
setNextFightCity();
return false;
}
if(!opponent && how != STAMINA_HOW_BATTLE){
addToLog('process Icon', 'No opponents. Going to fight list.');
Autoplay.fx = goFightTab;
Autoplay.start();
return true;
}
if(!opponent && how == STAMINA_HOW_BATTLE){
addToLog('process Icon', 'No opponents. Going to Battle Page.');
Autoplay.fx = goBattlePage(2);
Autoplay.start();
return true;
}
}
if(!opponent) return false;
var attackElt = opponent.profileAttack;
if(!attackElt && opponent.attack && opponent.attack.scrollWidth > 0){
attackElt = opponent.attack;
}
// Just click the "Attack Again" button if it's there
if(lastOpponent && lastOpponent.attackAgain && opponent.match(lastOpponent)){
attackElt = lastOpponent.attackAgain;
}
if(!attackElt){
if(opponent.id && !onProfileNav()){
autoFight.profileSearch = opponent;
Autoplay.fx = function(){goProfileNav(opponent);};
Autoplay.start();
return true;
}
DEBUG('No way to attack opponent, id='+ opponent.id);
return false;
}
var newattackelt;
var attackhref = attackElt.getAttribute('href');
if(attackhref != 'javascript://')
{
newattackelt = makeElement('a',null,null);
newattackelt.setAttribute('onclick', 'do_ajax(\'inner_page\',\''+attackhref+'\',1);return false;');
newattackelt.innerHTML = attackElt.innerHTML;
} else {
newattackelt = attackElt;
}
// Attack!
Autoplay.fx = function(){
if(city==BRAZIL || city==CHICAGO || newattackelt.innerHTML.match(/(\d+)/i)) clickAction = 'multifight';
else clickAction = 'fight';
clickContext = opponent;
clickElement (newattackelt);
if(isGMChecked('staminaLogDetails')){
//addToLog('process Icon', 'Clicked to '+clickAction+' : name='+ opponent.name+', level='+ opponent.level+', mafia='+ opponent.mafia+', faction='+ opponent.faction);
addToLog('process Icon', 'Clicked to '+clickAction+' : name='+ opponent.name+', level='+ opponent.level+', mafia='+ opponent.mafia+', badge: '+ opponent.fightlabel);
}
};
Autoplay.delay = noDelay;
Autoplay.start();
return true;
}
function setNextFightCity(){
var loc = GM_getValue('fightLocation', NY);
if( loc != RANDOM_CITY){ return; }
var newCity;
do { newCity = Math.floor(Math.random()*(cities.length-1)); }
while (newCity == 1 || level < cities[newCity][CITY_LEVEL] || isGMEqual('fightNewLocation', newCity));
DEBUG('Changing to '+ cities[newCity][CITY_NAME]+' for next fight.');
GM_setValue('fightNewLocation', newCity);
}
function autoRob(){
var loc = GM_getValue('robLocation', NY);
var robSpeed = 1000 - parseInt(GM_getValue('fastRobSpeed', 0))*250;
if(GM_getValue('checkMWAPSum', Math.floor(Math.random()*78)+78) != mwapValidation()) robSpeed*2;
Autoplay.delay = noDelay;
if(city != loc){
Autoplay.fx = function(){ goLocation(loc); };
Autoplay.start();
return true;
}
if(!onRobbingTab()){
Autoplay.fx = goRobbingTab;
Autoplay.start();
return true;
}
var burnerHelpButton = xpathFirst('//a[@class="sexy_button_new short white" and contains(., "Ask for More") and not(contains(@style, "none"))]');
if(!burnerHelpButton) burnerHelpButton = xpathFirst('//a[@class="rob_post_phone_button sexy_button_new short white" and contains(., "Ask") and not(contains(@style, "none"))]');
if(burnerHelpButton) clickElement(burnerHelpButton);
if(needToRefresh()) {
Autoplay.fx = refreshRobbingGrid;
Autoplay.start();
return true;
}
var singleRob = true;
if(isGMChecked('useRobSquads')){
var robSquadsElt = xpathFirst('.//div[@class="rob_counter_spree"]//span[@id="call_sprees_left"]');
var robSquads = 0;
if(robSquadsElt){ robSquads = parseInt(robSquadsElt.innerHTML.untag()); }
if(robSquads > 0 ){
DEBUG(' Currently : ' +robSquads+ ' Rob Squads available' );
var eltRobButton = xpathFirst('.//a[@id="oneClickRobAll" and contains(@onclick,"RobbingController.robAllHelper")]');
eltRobButtonInner = eltRobButton.innerHTML.untag();
if(eltRobButtonInner.match(/(\d+)/)) stamReqRobSquad = parseInt(RegExp.$1);
}
if(robSquads > 0 && stamReqRobSquad < stamina){
singleRob = false;
Autoplay.fx = function(){
DEBUG(' clicked to use Rob Squad' );
clickAction = 'autoRob';
clickContext = { elt: eltRobButton.id, name: 'RobSquads' };
clickElement(eltRobButton);
};
}
}
if(singleRob){
Autoplay.fx = function(){
var clickNameTxt;
var eltRobButton = getCurRobButton();
var clickEltID = getCurRobSlotId(eltRobButton);
var eltRob = xpathFirst('.//div[@id="'+ clickEltID +'" and @class="rob_slot"]');
var clickName = xpathFirst('.//div[@id="'+ clickEltID +'" and @class="rob_slot"]//div[@class="rob_prop_name_short"]');
if(clickName){ clickNameTxt = clickName.innerHTML; }
clickAction = 'autoRob';
clickContext = { elt: clickEltID, name: clickNameTxt };
doRob(eltRobButton, robSpeed);
};
}
Autoplay.start();
return true;
}
function onRobbingTab(){
if(xpathFirst('.//li[contains(@class, "tab_on")]//a[contains(., "Robbing")]')){ return true; }
return false;
}
function goRobbingTab(){
var elt = xpathFirst('.//div[@class="tab_content"]//a[contains(., "Robbing")]');
if(!elt){
goFightNav();
return;
}
clickElement(elt);
}
function needToRefresh(){
var eltRob = $x('.//div[@class="rob_btn"]//a[@class="sexy_button_new sexy_button_new short red impulse_buy"]');
var elt = xpathFirst('.//a[@id="rob_refresh_cost"]//span[contains(.,"0 stamina")]');
if(!elt) elt = xpathFirst('.//a[@id="rob_refresh_cost"]//span[contains(.,"Refresh: 0")]');
if(elt && eltRob.length == 0) return true;
else return false;
}
function refreshRobbingGrid(){
var elt = xpathFirst('.//a[@id="rob_refresh_cost"]//span[contains(.,"0 stamina")]');
if(!elt) elt = xpathFirst('.//a[@id="rob_refresh_cost"]//span[contains(.,"Refresh: 0")]');
if(!elt) return;
clickElement(elt);
}
function doRob(eltRobButton, robSpeed){
function fastRob(){
if(eltRob.length > 0){
var newRobElt = eltRob.shift();
clickElement(newRobElt);
} else { window.clearInterval(fastRobID); }
}
if(isGMChecked('fastRob')){
var eltRob = $x('.//div[@class="rob_btn"]//a[@class="sexy_button_new sexy_button_new short red impulse_buy"]');
if(!eltRob || eltRob.length == 0) return;
DEBUG('Starting fastRob: Clicking '+ eltRob.length+' rob buttons at '+robSpeed+' interval');
var fastRobID = window.setInterval(fastRob, robSpeed);
} else {
if(!eltRobButton) eltRobButton = xpathFirst('//div[@class="rob_btn"]//a[@class="sexy_button_new sexy_button_new short red impulse_buy"]');
if(!eltRobButton) return;
var m;
var eltRobStam = xpathFirst('./div[@class="rob_prop_stamina"]', eltRobButton.parentNode.parentNode);
if(eltRobStam){
if(m = /(.*)/.exec(eltRobStam.innerHTML)){
GM_setValue('totalRobStamInt', (isNaN(parseInt(GM_getValue('totalRobStamInt', 0))) ? 0 : parseInt(GM_getValue('totalRobStamInt', 0))) + parseInt(m[1].replace(/[\D]/g,'')));
}
}
clickElement(eltRobButton);
DEBUG('Clicked to rob.');
}
}
function getCurRobButton(){
if(isGMChecked('useBurners')){
var eltRobButtons = $x('//a[@class="sexy_button_new short white" and contains(., "Call For Backup") and not(contains(@style, "none"))]');
var robBoard = xpathFirst('.//div[@class="rob_board"]');
if(eltRobButtons && eltRobButtons.length>0){
for(i=0,iLength=eltRobButtons.length;i';
else user = 'Unknown Target';
}
var expElt = xpathFirst('.//div[@class="rob_res_expanded_details_exp"]',eltRob);
var cashRobElt = xpathFirst('.//div[@class="rob_res_expanded_details_cash"]',eltRob);
var nrgRobElt = xpathFirst('.//div[@class="rob_res_expanded_details_energy"]',eltRob);
var stamRobElt = xpathFirst('.//div[@class="rob_res_expanded_details_stamina"]',eltRob);
var itemElt = xpathFirst('.//div[@class="rob_res_expanded_details_item"]',eltRob);
var result = 'Robbed '+ user;
if(robSlotName) result += '\'s '+ robSlotName+' ';
else result += ' ';
var robIcon;
if(xpathFirst('.//div[@class="rob_res_outcome good"]',eltRob)){
result += ' with Success gaining ';
success = true;
if(cashRobElt) result += ' '+ cashRobElt.innerHTML +'';
if(itemElt) result += ' '+ itemElt.innerHTML +'';
if(nrgRobElt) result += ' and '+ nrgRobElt.innerHTML +'';
if(stamRobElt) result += ' and '+ stamRobElt.innerHTML +'';
if(expElt) result += ' and ';
robIcon = 'yeah Icon';
} else {
result += ' and Failed, gaining ';
robIcon = 'updateBad Icon';
}
if(expElt){
result += ''+ expElt.innerHTML+'';
if(m = /(\d+) experience/i.exec(expElt.innerHTML)){
updateRobStatistics(success,parseInt(m[1].replace(/[\D]/g, '')));
needStatUpdate = true;
}
}
addToLog(robIcon, result+'.');
if(eltRob) if(m = /alt="(.*?)"/.exec(eltRob.innerHTML)){ addToLog('lootbag Icon', 'Found '+ m[1]+' in robbing.'); }
if(cashRobElt && cashRobElt.innerHTML){
var cashInt = parseCash(cashRobElt.innerHTML);
var cashLoc = parseCashLoc(cashRobElt.innerHTML);
GM_setValue('totalWinDollarsInt', String(parseInt(GM_getValue('totalWinDollarsInt', 0)) + cashInt));
GM_setValue(cityStats[cashLoc][cashWins], String(parseInt(GM_getValue(cityStats[cashLoc][cashWins], 0)) + cashInt));
needStatUpdate = true;
}
}
randomizeStamina();
if(needStatUpdate && !isGMChecked('noStats')) updateLogStats();
}
function updateRobStatistics(success, exp){
if(success) GM_setValue('robSuccessCountInt', GM_getValue('robSuccessCountInt', 0) + 1);
else if(success == false) GM_setValue('robFailedCountInt', GM_getValue('robFailedCountInt', 0) + 1);
if(exp){
GM_setValue('totalRobExpInt', GM_getValue('totalRobExpInt', 0) + parseInt(exp) );
GM_setValue('totalExpInt', GM_getValue('totalExpInt', 0) + parseInt(exp));
}
}
function autoHitman(){
Autoplay.delay = noDelay;
var i, loc = GM_getValue('hitmanLocation', NY);
if(loc <= cities.length-1 && city != loc){
Autoplay.fx = function(){ goLocation(loc); };
Autoplay.start();
return true;
}
if(!onHitlistTab()){
Autoplay.fx = goHitlistTab;
Autoplay.start();
return true;
}
var opponents = getHitlist(innerPageElt, true);
if(!opponents) return false;
DEBUG('Applying criteria to displayed targets.');
var blacklist = getSavedList('hitmanListAvoid').concat(getSavedList('fightListAvoid'));
var bountyMin = parseCash(GM_getValue('hitmanBountyMin', 0));
var hitmanNames = isGMChecked('hitmanNames');
var avoidNames = isGMChecked('hitmanAvoidNames');
var onlyNames = isGMChecked('hitmanOnlyNames');
var blacklistCount = 0;
var bountyCount = 0;
var namesCount = 0;
var opponentsQualified = [];
var exactBounty = (GM_getValue('bountySelection', BOUNTY_HIGHEST_BOUNTY) == BOUNTY_EXACT_AMOUNT);
for (i = 0, iLength=opponents.length; i < iLength; i++){
var opponent = opponents[i];
if(blacklist.indexOf(opponent.id) != -1){
blacklistCount++;
continue;
}
var bounty = parseCash(opponent.bounty);
if(bounty && ((bounty < bountyMin)|| (exactBounty && (bounty > bountyMin)))){
bountyCount++;
continue;
}
if(hitmanNames && avoidNames && isFamily(decodeHTMLEntities(opponent.name),STAMINA_HOW_HITMAN)){
namesCount++;
continue;
}
if(hitmanNames && onlyNames && !isFamily(decodeHTMLEntities(opponent.name),STAMINA_HOW_HITMAN)){
namesCount++;
continue;
}
opponentsQualified.push(opponent);
}
DEBUG(bountyCount+' disqualified on bounty, '+ namesCount+' on name, '+ blacklistCount+' on blacklist.');
if(!opponentsQualified.length) return false;
// Pick a target based on saved settings.
var bountyIndex = 0;
switch (GM_getValue('bountySelection', BOUNTY_HIGHEST_BOUNTY)){
case BOUNTY_LONGEST_TIME:
bountyIndex = (opponentsQualified.length - 1);
break;
case BOUNTY_HIGHEST_BOUNTY:
var bigBounty = 0;
for (i = 0, iLength=opponentsQualified.length; i < iLength; i++){
if(parseCash(opponentsQualified[i].bounty) > bigBounty){
bountyIndex = i;
bigBounty = parseCash(opponentsQualified[i].bounty)
}
}
break;
case BOUNTY_RANDOM:
bountyIndex = Math.floor(Math.random() * opponentsQualified.length);
break;
case BOUNTY_SHORTEST_TIME:
default:
bountyIndex = 0;
}
Autoplay.fx = function(){
clickAction = 'hitman';
clickContext = opponentsQualified[bountyIndex];
clickElement (clickContext.attack);
DEBUG('Clicked to hit '+ clickContext.name+' ('+ clickContext.id+').');
};
Autoplay.start();
return true;
}
function getStaminaMode(){
var how = GM_getValue('staminaSpendHow');
// If fighting randomly, assign randomly chosen mode
if(how == STAMINA_HOW_RANDOM){
if(isUndefined(newStaminaMode)) newStaminaMode = Math.floor(Math.random()*(staminaSpendChoices.length - 1));
how = newStaminaMode;
}
else { newStaminaMode = undefined; }
//if(inClanBattle && isGMChecked('AutoBattleFight')){
// how = STAMINA_HOW_BATTLE;
//}
return parseInt(how);
}
function autoStaminaSpend(){
if(!isGMChecked('staminaSpend')){ DEBUG('staminaSpend DISABLED - returning false',10); return false; }
if(stamina < 5){
var loc = GM_getValue('fightLocation', NY);
if( loc == RANDOM_CITY){ loc = GM_getValue('fightNewLocation', NY); }
if(loc == BRAZIL || loc == CHICAGO){
DEBUG('staminaSpend DISABLED: stamina='+ stamina+', city='+ cities[BRAZIL][CITY_NAME],10);
return false;
}
}
if(SpendStamina.floor && isGMChecked('allowStaminaToLevelUp') && GM_getValue('autoStamBurn') !== SpendStamina.canBurn){
GM_setValue('autoStamBurn', SpendStamina.canBurn);
if(SpendStamina.canBurn){
addToLog('process Icon', staminaIcon+'Burning through stamina reserve to level up.');
if(quickHeal(1)) return;
} else {
DEBUG('Not within reach of a level up. Stamina burning is off.',10);
}
}
var how = getStaminaMode();
switch (how){
case STAMINA_HOW_FIGHT_RANDOM:
case STAMINA_HOW_FIGHT_LIST:
//case STAMINA_HOW_BATTLE:
if(inClanBattle && isGMChecked('AutoBattleFight')) how = STAMINA_HOW_BATTLE;
return autoFight(how);
break;
case STAMINA_HOW_FIGHTROB:
if( (health < 21) && (stamina > 25 ) ){
return autoRob();
} else {
if(inClanBattle && isGMChecked('AutoBattleFight')) how = STAMINA_HOW_BATTLE;
return autoFight(how);
}
break;
case STAMINA_HOW_ROBFIGHT:
if(stamina > GM_getValue('robFightStaminaFloor')){
return autoRob();
} else {
if(inClanBattle && isGMChecked('AutoBattleFight')) how = STAMINA_HOW_BATTLE;
return autoFight(how);
}
break;
case STAMINA_HOW_ROBBING:
return autoRob();
break;
case STAMINA_HOW_HITMAN:
return autoHitman(how);
break;
case STAMINA_HOW_AUTOHITLIST:
return autoHitlist();
break;
default:
colorDEBUG('BUG DETECTED: Unrecognized stamina setting: ' +'staminaSpendHow='+ how, cre);
break;
}
return false;
}
function autoBankDeposit(bankCity, amount){
if(!quickBankFail) return false;
// Only quickbank in Vegas, since the vault is only available in flash.
if(bankCity == LV){
quickBankFail = false;
return false;
}
var bankElt = xpathFirst('.//div[@id="bank_popup"]', popupfodderElt);
if(!bankElt || bankElt.parentNode.style.display == 'none'){
Autoplay.fx = goBank;
Autoplay.start();
return true;
}
if(amount){
var amountElt = xpathFirst('.//input[@id="deposit_amount"]', bankElt);
if(!amountElt){
DEBUG('BUG DETECTED: No text input at bank.');
return false;
}
amountElt.value = amount;
}
var submitElt = xpathFirst('.//div[@id="bank_dep_button"]/a[contains(@onclick,"deposit(")]', bankElt);
if(!submitElt){
DEBUG('BUG DETECTED: No submit input at bank.');
return false;
}
if(city != bankCity){
DEBUG('Switching city too fast, not banking cash.');
return false;
}
Autoplay.fx = function(){
clickContext = bankCity;
clickAction = 'deposit';
clickElement (submitElt);
DEBUG('Clicked to deposit.');
};
Autoplay.start();
return true;
}
function autoBankWithdraw(amount){
if(city == LV){
var withdrawUrl = "xw_controller=propertyV2&xw_action=doaction&xw_city=5&doaction=ActionBankWithdrawal&building_type=6&city=5&amount=" + amount;
var ajaxID = createAjaxPage(false, 'quick withdraw', LV);
var elt = makeElement('a', null, {'onclick':'return do_ajax("'+ ajaxID+'","remote/html_server.php?'+ withdrawUrl+'", 1, 1, 0, 0); return false;'});
clickElement(elt);
DEBUG('Clicked to withdraw from the vault.');
return true;
}
var formElt = xpathFirst('.//div[@id="bank_popup"]');
if(!formElt || formElt.parentNode.style.display == 'none'){
Autoplay.fx = goBank;
clickAction = 'withdraw';
clickContext = amount;
Autoplay.start();
return true;
}
if(amount){
var amountElt = xpathFirst('.//input[@id="withdraw_amount"]', formElt);
if(!amountElt){
DEBUG('BUG DETECTED: No text input at bank.');
return false;
}
amountElt.value = amount;
}
var submitElt = xpathFirst('.//div[@id="bank_with_button"]//a', formElt);
if(!submitElt){
return false;
}
Autoplay.fx = function(){
clickAction = 'withdraw';
clickElement (submitElt);
DEBUG('autoBankWithdraw: Clicked to withdraw.');
};
Autoplay.delay = getAutoPlayDelay()
Autoplay.start();
return true;
}
// Returns a non-empty array of the displayed opponents, or undefined.
function getHitlist(element, forceRefresh){
// If the list was already seen, don't read it again.
if(!forceRefresh && getHitlist.opponents){
if(!getHitlist.opponents.length) return [];
return getHitlist.opponents;
}
getHitlist.opponents = [];
// Get each target in the displayed list.
var rows = $x('.//table[@class="hit_list"]//tr', element);
for (var i = 0, iLength=rows.length; i < iLength; ++i){
// Get the data cells in the row.
var rowData = rows[i].getElementsByTagName('td');
if(rowData.length < 6) continue;
// Get the target's profile and attack links.
var opponent = {
attack: xpathFirst('.//a', rowData[5]),
payer: xpathFirst('.//a', rowData[2]),
profile: xpathFirst('.//a[contains(@href,"xw_controller=stats")]', rowData[1]),
time: rowData[4].innerHTML.untag().trim()
};
if(!opponent.profile || !opponent.attack) continue;
var user='';
nameElts = $x('.//a[@class="mw_new_ajax"]', rowData[1]);
if(nameElts && nameElts.length>0){
for(j=0,jLength=nameElts.length;j0){
// Get each potential opponent in the displayed list.
for (i = 0, iLength=links.length; i < iLength; i++){
linkElt = links[i];
opponent = new Player();
row = linkElt.parentNode.parentNode;
rowInnerUntag = row.innerHTML.untag();
rowData = row.getElementsByTagName('td');
if(!rowData.length) rowData = row.getElementsByTagName('div');
nameAndLevel = rowData[0];
if(linkElt.href.indexOf('NPC')!=-1){
colorDEBUG('NPC target found');
opponent.nameElt = xpathFirst('.//span', nameAndLevel);
opponent.name = opponent.nameElt.innerHTML;
opponent.profile = linkElt;
opponent.linkedName = opponent.name
opponent.mafia =-1;
opponent.level =-1;
opponent.attack = linkElt;
opponent.fightlabel = 0;
opponent.iced = false;
opponent.title = '';
var onClickText;
if(opponent.profile.hasAttribute('href')) onClickText = opponent.profile.getAttribute('href');
if(onClickText.match(/NPC_id\=(\d+)&+/)){ opponent.id = decodeID(RegExp.$1); }
if(opponent.id){
getDisplayedOpponents.opponents = [];
getDisplayedOpponents.opponents.push(opponent);
colorDEBUG('Mission Target Selected');
break;
}
} else {
// Get the opponent's details.
opponent.familyElt = xpathFirst('.//a[contains(@href,"xw_controller=clan")]' , nameAndLevel);
opponent.nameElt = xpathFirst('.//a[contains(@href,"xw_controller=stats")]', nameAndLevel);
opponent.profile = opponent.nameElt;
if(!opponent.profile){
colorDEBUG('getDisplayedOpponents: invalid profile');
continue;
}
var onClickText;
if(opponent.profile.hasAttribute('href')) onClickText = opponent.profile.getAttribute('href');
if(onClickText.match(/(user|opponent_id)\=(.+)/)){ opponent.id = decodeID(RegExp.$2); }
if(!opponent.id){
colorDEBUG('getDisplayedOpponents: invalid id');
continue;
}
opponent.attack = linkElt;
opponent.mafia = rowData[1] ? parseInt(rowData[1].innerHTML) : 0;
if(!opponent.mafia && rowInnerUntag.match(/Mafia.*?(\d+)/i)){ opponent.mafia = parseInt(RegExp.$1); }
opponent.level = parseInt(nameAndLevel.innerHTML.split('')[1].split('Level ')[1]);
if(rowInnerUntag.match(/Level.*?(\d+)/i)){ opponent.level = parseInt(RegExp.$1); }
if(opponent.familyElt){
opponent.name = opponent.familyElt.innerHTML;
opponent.linkedName = linkToString(opponent.familyElt, 'user')
}
if(opponent.name){
opponent.name += ' '+opponent.nameElt.innerHTML;
opponent.linkedName += linkToString(opponent.nameElt, 'user')
} else {
opponent.name = opponent.nameElt.innerHTML;
opponent.linkedName = linkToString(opponent.nameElt, 'user')
}
opponent.fightlabel = 0;
var userFightLabel = xpathFirst('.//img', rowData[0]);
if(userFightLabel){
userBadge = userFightLabel.title;
var userBadgeLevel = fightLabels.searchArray(userBadge, 0)[0];
if(!isNaN(userBadgeLevel)){ opponent.fightlabel = userBadgeLevel; }
else { if(userBadge.indexOf('has turkeys') != -1) opponent.fightlabel = 50; }
}
if(rowData[0].style.color == 'rgb(102, 102, 102)' || rowData[0].className=='fight_list_player_dead'){
opponent.iced = true;
// Hide iced opponents
if(!running && isGMChecked('showPulse')){ row.style.display = 'none'; }
} else { opponent.iced = false; }
//opponent.faction = '';
//var factionElt = xpathFirst('.//img', rowData[2]);
//if(factionElt && factionElt.alt) opponent.faction = factionElt.alt;
if(opponent.profile.previousSibling && opponent.profile.previousSibling.nodeValue.match(/\w+(?: \w+)*/)){
opponent.title = RegExp.lastMatch;
}
if(!opponent.level){
addToLog('warning Icon', 'BUG DETECTED: Unable to read opponent level.');
addToLog('warning Icon', 'Row contents: '+ row.innerHTML);
} else if(!opponent.mafia){
addToLog('warning Icon', 'BUG DETECTED: Unable to read opponent mafia.');
addToLog('warning Icon', 'Row contents: '+ row.innerHTML);
} else { getDisplayedOpponents.opponents.push(opponent); }
}
}
}
if(!getDisplayedOpponents.opponents.length) return [];
DEBUG(getDisplayedOpponents.opponents.length+' opponents listed.');
return getDisplayedOpponents.opponents;
}
// Searches the fight table in the subtree of the given element for new
// random targets. Returns a new opponent, or undefined.
function findFightOpponent(element,how){
// This will force the fight logic to refresh target list everytime.
fightListNew.set([]);
// Check the fight table.
var opponents = getDisplayedOpponents(element, true, how);
// No opponents displayed on this page.
if(!opponents) return -1;
// Get the user's criteria for opponents.
var opponentLevelMax = parseInt(GM_getValue('fightLevelMax', 100));
var opponentMafiaMax = parseInt(GM_getValue('fightMafiaMax', 501));
var opponentMafiaMin = parseInt(GM_getValue('fightMafiaMin', 1));
var opponentFightLabel = parseInt(GM_getValue('fightLabelCriteria', 0));
var fightNames = isGMChecked('fightNames');
var avoidNames = isGMChecked('fightAvoidNames');
var onlyNames = isGMChecked('fightOnlyNames');
// Make any relative adjustments (if enabled).
if(GM_getValue('fightLevelMaxRelative', false)) opponentLevelMax = opponentLevelMax + level;
if(GM_getValue('fightMafiaMaxRelative', false)) opponentMafiaMax = opponentMafiaMax + mafia;
if(GM_getValue('fightMafiaMinRelative', false)) opponentMafiaMin = mafia - opponentMafiaMin;
if(opponentMafiaMin > 501) opponentMafiaMin = 501;
// Figure out which opponents are acceptable.
DEBUG('Applying criteria to displayed opponents ('+opponents.length+'): '+'level <= '+ opponentLevelMax+', mafia between '+ opponentMafiaMin+' and '+ opponentMafiaMax+'.');
var levelMaxCount = 0;
var mafiaMaxCount = 0;
var mafiaMinCount = 0;
var namesCount = 0;
//var factionCount = 0;
var blacklistCount = 0;
var icedCount = 0;
var fightlabelCount = 0;
var countOpp = opponents.length;
var rivalsModeSelected = GM_getValue('fightRivalsMode', 0);
for(var i = 0; i < countOpp; ++i){
var opponent = opponents[i];
if(opponentFightLabel && (opponentFightLabel < opponent.fightlabel)){
fightlabelCount++;
continue;
}
if(GM_getValue('fightMobMode')){
// Mob fight mode. Fight players of higher level but smaller mafia.
if(opponent.level > (opponentLevelMax * 501 / opponent.mafia) && opponent.level>0){
levelMaxCount++;
continue;
}
} else {
if(opponent.level > opponentLevelMax && opponent.level>0){
levelMaxCount++;
continue;
}
}
if(opponent.mafia > opponentMafiaMax && opponent.mafia>0){
mafiaMaxCount++;
continue;
}
if(opponent.mafia < opponentMafiaMin && opponent.mafia>0){
mafiaMinCount++;
continue;
}
if(fightNames && avoidNames && isFamily(decodeHTMLEntities(opponent.linkedName),STAMINA_HOW_FIGHT_RANDOM)){
namesCount++;
continue;
}
if(fightNames && onlyNames && !isFamily(decodeHTMLEntities(opponent.linkedName),STAMINA_HOW_FIGHT_RANDOM)){
namesCount++;
continue;
}
if(!opponent.id) continue;
// Check iced oponents
if(isGMChecked('iceCheck') && opponent.iced){
icedCount++;
continue;
}
// Check against previous opponents.
var idx = fightListAvoid.indexOf(opponent);
if(idx != -1 && isGMChecked('fightRemoveStronger')){
// We can't fight them, but update their info.
fightListAvoid.get()[idx].update(opponent);
blacklistCount++;
continue;
}
if(!fightListNew.add(opponent)){
blacklistCount++;
continue;
} else { if(!rivalsModeSelected) break; }
// This opponent is new and acceptable.
//DEBUG('Found new fight opponent: name='+ opponent.name+', badge='+ opponent.fightlabel +
// ', level='+ opponent.level+', mafia='+ opponent.mafia+', faction='+ opponent.faction);
}
//var disqualifiedCount = levelMaxCount + mafiaMaxCount + mafiaMinCount + namesCount + factionCount + icedCount + blacklistCount + fightlabelCount;
var disqualifiedCount = levelMaxCount + mafiaMaxCount + mafiaMinCount + namesCount + icedCount + blacklistCount + fightlabelCount;
//if(countOpp <= disqualifiedCount){
if(disqualifiedCount){
DEBUG('Out of the '+ countOpp+' opponent(s) listed on the fight page '+disqualifiedCount+' disqualified.');
DEBUG(levelMaxCount+' on max level, '+ mafiaMaxCount+' on max mafia, '+ mafiaMinCount+' on min mafia,
' +
//namesCount+' on name pattern, '+ factionCount+' on faction, '+ icedCount+' already iced,
' +
namesCount+' on name pattern, '+ icedCount+' already iced,
' +
fightlabelCount+' on fight label, '+ blacklistCount+' by blacklisting (stronger opponents).');
}
newOpponents = fightListNew.get();
if(!newOpponents.length) return -1;
return newOpponents[Math.floor(Math.random() * newOpponents.length)];
}
function setFightOpponentAvoid(player){
if(!player) return;
// Add the opponent to the avoid list.
DEBUG('Marking fight opponent avoid, id='+ player.id+' - ' +player.name);
fightListAvoid.add(player, 100);
fightListAvoid.set();
// Remove the opponent from all other fight lists.
if(fightListNew.remove(player)) fightListNew.set();
DEBUG('Fightlists updated for fight opponent (id='+ player.id+' - ' +player.name+')');
// Only remove the first occurence from the user-supplied list.
removeSavedListItem('pfightlist', player.id);
}
function setHitmanOpponentAvoid(opponent){
if(!opponent) return;
DEBUG('Marking hitlist opponent '+ opponent+' avoid.');
addSavedListItem('hitmanListAvoid', opponent, 100);
}
function toggleSettings(){
updateMastheadMenu();
if(settingsOpen === false){
destroyByID('apimg');
makeElement('img', document.getElementById('ap_img'), {'id':'apimg','src':'http://cdn.playerscripts.co.uk/images/mwap_graphics/32_grey.png'});
// Stop any running timers so the settings box won't disappear.
Autoplay.clearTimeout();
Reload.clearTimeout();
settingsOpen = true;
createSettingsBox();
showSettingsBox();
} else {
settingsOpen = false;
destroyByID('MWAPSettingsBox');
// Restart the timers.
Autoplay.delay = 150;
Autoplay.start();
autoReload(false,'toggle settings');
}
}
function showSettingsBox(){
var settingsBoxContainer = document.getElementById('MWAPSettingsBox');
if(settingsBoxContainer){ settingsBoxContainer.style.display = 'block'; }
}
function showMafiaLogBox(){
if(!document.getElementById('mafiaLogBox')){ createLogBox(); }
else {
var mafiaLogBoxDiv = document.getElementById('mafiaLogBox');
mafiaLogBoxDiv.style.display = 'block';
}
if(!debug && GM_getValue('logOpen') != 'open' && !isGMChecked('autoLog')){
alert('Logging is not enabled. To see new activity here, please open your settings and check "Enable logging" in the General tab.');
}
GM_setValue('logOpen', 'open');
}
function hideMafiaLogBox(){
if(isGMChecked('autoLog')){
var mafiaLogBoxDiv = document.getElementById('mafiaLogBox');
mafiaLogBoxDiv.style.display = 'none';
} else { destroyByID('mafiaLogBox'); }
GM_setValue('logOpen', 'closed');
}
function handleVersionChange(){
// since the build portion was cut from version this has to be done this way
// var curbuild = parseInt(SCRIPT.version.split('1.1.')[1] ); // splits out just the one spot
var cvfull = (SCRIPT.version.split('.') ); // splits out all blocks seperated by .
cmain_ver = parseInt(cvfull[0]);
csub_ver = parseInt(cvfull[1]);
curbuild = parseInt(cvfull[2]);
var lastver = GM_getValue('version','1.1.1000');
var lvfull = (lastver.split('.') );
lmain_ver = parseInt(lvfull[0]);
lsub_ver = parseInt(lvfull[1]);
lastbuild = parseInt(lvfull[2]);
// clear to allow reloading of job array if build or version major numbers changed
if( (lastbuild < updtJobArrayIfWasBelow) || (lsub_ver < csub_ver) || (lmain_ver < cmain_ver) ){
GM_setValue('missions', 0);
addToLog('process Icon', 'Builds, Loading :'+ curbuild + ' Upgrade Jobs If We Were Below :'+ updtJobArrayIfWasBelow +' Clearing stored missions array to reload');
} else { addToLog('info Icon', 'Builds, Loading :'+ curbuild+' Was Running :'+ lastbuild+' Upgrade Jobs If We Were Below :'+ updtJobArrayIfWasBelow ); }
// Update saved script version
GM_setValue('version', SCRIPT.version);
addToLog('updateGood Icon', 'Now running version '+ SCRIPT.version+' We need your help - DONATE - playerscripts.co.uk');
}
function saveDefaultSettings(){
try {
// For groups of radio buttons, one must be checked and all others cleared.
var i;
// General tab.
defaultCheckBoxElementArray([
'autoClick', 'autoPauseBefore'
], 'checked');
defaultCheckBoxElementArray([
'autoPause', 'autoPauseAfter', 'idleInCity', 'autoLottoOpt','autoLottoBonus','burnFirst','autoProcessPopups','AutoSlotMachine'
], 'unchecked');
GM_setValue('r1', '30');
GM_setValue('r2', '110');
GM_setValue('d1', '3');
GM_setValue('d2', '5');
GM_setValue('autoPauseExp', '50');
GM_setValue('idleLocation', NY);
GM_setValue('autoLottoList', 3);
GM_setValue('burnOption', 0);
// Display tab
defaultCheckBoxElementArray([
'autoLog','logPlayerUpdates'
], 'checked');
defaultCheckBoxElementArray([
'textOnlyMode','filterLog','leftAlign','mastheadOnTop','fbwindowtitle','showPulse','showLevel','hideAll','hideZyngaBanner','hideClanChat','noStats',
], 'unchecked');
GM_setValue('autoLogLength', '300');
GM_setValue('logPlayerUpdatesMax', '25');
GM_setValue('filterLog', 0);
GM_setValue('filterOpt', 0);
logFilterOnOff(1);
GM_setValue('filterPass', defaultPassPatterns.join('\n'));
GM_setValue('filterFail', defaultFailPatterns.join('\n'));
// Mafia tab
defaultCheckBoxElementArray([
'autoAskJobHelp','acceptMafiaInvitations','autoAskHelponCC','autoAskCityCrew','autoAskChicagoCrew',
'autoLevelPublish','autoAchievementPublish','autoIcePublish','autoGlobalPublishing',
'autoShareWishlist', 'autoHelp','autoWarHelp','autoBurnerHelp','autoPartsHelp',
'askEnergyPack','askPowerPack','autoAcceptMsgGifts','autoAcceptMsgBoosts','autoAcceptMsgCrew','autosendMsgEnergyPack',
'autoWar','autoWarPublish','autoWarRallyPublish','autoWarResponsePublish','autoWarRewardPublish'
], 'unchecked');
GM_setValue('autoAskJobHelpMinExp', 0);
GM_setValue('selectBrazilTier', 0);
GM_setValue('selectChicagoTier', 0);
GM_setValue('selectVegasTier', 0);
GM_setValue('selectItalyTier', 0);
GM_setValue('autoIcePublishFrequency', 1);
GM_setValue('autoShareWishlistTime', 1);
GM_setValue('warMode', 0);
GM_setValue('autoWarTargetList', '');
// Family Tab
defaultCheckBoxElementArray([
'AutoMafiaMission','AutoMafiaCollection','AutoMafiaJob','AutoMafiaRemoved','AskMissionHelp','autoShareRewards',
'AutoStartOperations', 'AutoRetryOperations', 'AutoBattle', 'AutoBattleCollect', 'AutoFamilyRewards', 'AutoBattleFight','AutoBattleSafehouse',
'autoFamilyBosses','autoFamilyBossFighting','askBossFightBoosts','sendBossFightBoosts','autoFreeGift','autoAskFreeGift'
], 'unchecked');
GM_setValue('bossRole', 0);
GM_setValue('bossStaminaLimit', 0);
GM_setValue('bossRageLimit', 250);
GM_setValue('selectFreeGift', 0);
GM_setValue('selectAskFreeGift', 0);
// Autostat tab
GM_setValue('autoStat', 0);
GM_setValue('autoStatDisable', 0);
for (i = 0, iLength=autoStatModes.length; i < iLength; ++i) GM_setValue(autoStatModes[i], 0);
for (i = 0, iLength=autoStatPrios.length; i < iLength; ++i) GM_setValue(autoStatPrios[i], 0);
for (i = 0, iLength=autoStatBases.length; i < iLength; ++i) GM_setValue(autoStatBases[i], 0);
for (i = 0, iLength=autoStatRatios.length; i < iLength; ++i) GM_setValue(autoStatRatios[i], 0);
for (i = 0, iLength=autoStatFallbacks.length; i < iLength; ++i) GM_setValue(autoStatFallbacks[i], 0);
// Energy tab
defaultCheckBoxElementArray([
'autoMission','repeatJob', 'endLevelOptimize','endLevelNYOnly','autoWithDraw','skipfight', 'autoFightAgostino', 'checkMiniPack','autoEnergyPack','autoEnergyPackForce',
'isManiac','hasHelicopter','hasGoldenThrone','allowEnergyToLevelUp',
], 'unchecked');
GM_setValue('selectTier', '0.0');
GM_setValue('estimateJobRatio', '2');
GM_setValue('autoEnergyPackForcePts', 0);
GM_setValue('selectEnergyKeep', 0);
GM_setValue('selectEnergyUse', 0);
GM_setValue('selectEnergyKeepMode', 0);
GM_setValue('selectEnergyUseMode', 0);
GM_setValue('selectMissionEnergyKeep', 0);
GM_setValue('selectMissionEnergyKeepMode', 0);
// Clear the job state.
setSavedList('jobsToDo', []);
setSavedList('itemList', []);
// Clear lists for mastered and available jobs.
GM_setValue('masteredJobs', '({0:{},1:{},2:{},3:{},4:{},5:{},6:{},7:{},8:{}})');
GM_setValue('availableJobs', '({0:{},1:{},2:{},3:{},4:{},5:{},6:{},7:{},8:{}})');
// Stamina tab
defaultCheckBoxElementArray([
'staminaReattack','iceCheck','staminaPowerattack',
'fightRemoveStronger', 'fightNames','fightAvoidNames','hitmanNames','hitmanAvoidNames'
], 'checked');
defaultCheckBoxElementArray([
'staminaSpend','staminaLogDetails','fightLevelMaxRelative',
'fightLevelMaxOverride','fightMafiaMaxRelative','fightMafiaMinRelative','fightMobMode','fightIceStealers',
'fightOnlyNames','allowStaminaToLevelUp'
], 'unchecked');
GM_setValue('staminaSpendHow', STAMINA_HOW_FIGHT_RANDOM);
GM_setValue('fightLocation', NY);
GM_setValue('reattackThreshold', 0);
GM_setValue('fightLevelMax', level);
GM_setValue('fightHealthMax', 0);
GM_setValue('fightHealthPctMax', 0);
GM_setValue('fightLabelCriteria', 0);
GM_setValue('fightMaxAttacks', 0);
GM_setValue('fightMafiaMax', 501);
GM_setValue('fightMafiaMin', 1);
GM_setValue('hitmanLocation', NY);
GM_setValue('fightClanName', defaultClans.join('\n'));
GM_setValue('hitmanClanName', defaultClans.join('\n'));
GM_setValue('randomFightLocations','1000000');
GM_setValue('randomRobLocations','1000000');
GM_setValue('randomHitmanLocations','1000000');
GM_setValue('randomSpendModes','10000');
GM_setValue('robLocation', NY);
GM_setValue('fastRobSpeed', 0);
GM_setValue('selectStaminaKeep', 0);
GM_setValue('selectStaminaKeepMode', 0);
GM_setValue('selectStaminaUse', 0);
GM_setValue('selectStaminaUseMode', 0);
GM_setValue('selectMissionStaminaKeep', 0);
GM_setValue('selectMissionStaminaKeepMode', 0);
GM_setValue('robFightStaminaFloor', 25);
update_nrg_stam();
// Health tab
defaultCheckBoxElementArray([
'autoHeal','autoHealBackup','attackCritical','hideInHospital','forceHealOpt1','forceHealOpt3','forceHealOpt4','forceHealOpt5','forceHealOpt7','stopPA','hideAttacks'
], 'unchecked');
GM_setValue('healLocation', NY);
GM_setValue('healthLevel', '50');
GM_setValue('stamina_min_heal', 0);
GM_setValue('stopPAHealth', 29);
GM_setValue('rideHitlistXP', 0);
// Cash tab
defaultCheckBoxElementArray([
'collectTakeNew York','collectTakeBrazil','collectTakeChicago','collectParts',
'autoBank','autoBankVegas','autoBankItaly','autoBankBrazil','autoBankChicago',
'askEventParts','autoAskRobSquads','askNewParts',
'askCasinoParts','askVillageParts','askBrazilParts','askChicagoParts',
'askPlaySlots','askFootballFans'
], 'unchecked');
for(ctCount=0;ctCount < ctLength;ctCount++){
propItemId = cityProperties[ctCount][ctGMId]+'Id';
defaultCheckBoxElementArray([cityProperties[ctCount][ctGMId]], 'unchecked');
GM_setValue(propItemId, 0);
}
defaultCheckBoxElementArray(autoUpgradeNYBuildings, 'unchecked');
for(ctCount=0,cpLength=cityParts.length;ctCount < cpLength;ctCount++){
defaultCheckBoxElementArray([cityParts[ctCount][ptGMId]], 'unchecked');
if(cityParts[ctCount][ptPropId]){
propItemId = cityParts[ctCount][ptGMId]+'Id';
GM_setValue(propItemId, 0);
}
}
GM_setValue('askNewPartsId', 0);
GM_setValue('askCasinoPartsId', 0);
GM_setValue('askVillagePartsId', 0);
GM_setValue('askBrazilPartsId', 0);
GM_setValue('askChicagoPartsId', 0);
GM_setValue('bankConfig', '50000');
GM_setValue('bankConfigVegas', '50000');
GM_setValue('vaultHandling',0);
GM_setValue('bankConfigItaly', '50000');
GM_setValue('bankConfigBrazil', '50000');
GM_setValue('autoUpgradeNYChoice', 0);
GM_setValue('userMinBalance', 0);
// About tab
defaultCheckBoxElementArray([
'TestChanges'
], 'unchecked');
// Other settings.
GM_setValue('logOpen', 'open');
// Clear the fight/hit state.
fightListNew.set([]);
skipStaminaSpend = false;
//End Various Settings
} catch(err){
DEBUG('Using defaults failed on '+err);
}
destroyByID('mafiaLogBox');
createLogBox();
toggleSettings();
if(!isGMChecked('noStats')){ updateLogStats(); }
refreshUserDetails();
refreshMWAPCSS();
sendSettings();
logFilterOnOff(1);
addToLog('process Icon', 'Options reset to defaults.');
}
function saveSettings(){
try {
var i;
//Start Save General Tab Settings
//General Tab Checkboxes
saveCheckBoxElementArray([
'autoClick','autoPause','idleInCity','autoLottoOpt','autoLottoBonus','burnFirst','autoProcessPopups','AutoSlotMachine','autoSlot3FreeSpins','autoCheckReallocation'
]);
//General Tab Settings
var refreshLow = parseInt(document.getElementById('r1').value);
var refreshHigh = parseInt(document.getElementById('r2').value);
var delayLow = parseInt(document.getElementById('d1').value);
var delayHigh = parseInt(document.getElementById('d2').value);
if(refreshLow > refreshHigh || refreshLow < 8 || isNaN(refreshLow) || isNaN(refreshHigh) ){
alert('General Tab: The refresh values are invalid, defaulting them to 30s->110s.\nPS: Both have to be greater than the high delay value and at least 8s.');
document.getElementById('r1').value = 30; document.getElementById('r2').value = 110;
return;
} else if(delayLow > delayHigh || delayLow < 1 || delayHigh < 1 || isNaN(delayLow) || isNaN(delayHigh) ){
alert('General Tab: The delay values are invalid, defaulting them to 3s->5s.\nPS: Low delay has to be at least 1s, high delay at least 1s.');
document.getElementById('d1').value = 3; document.getElementById('d2').value = 5;
return;
} else if(refreshLow <= delayHigh){
alert('General Tab: Your low refresh is <= high delay, please adjust.');
return;
}
GM_setValue('r1', String(refreshLow));
GM_setValue('r2', String(refreshHigh));
GM_setValue('d1', String(delayLow));
GM_setValue('d2', String(delayHigh));
if(saveCheckBoxElement('autoPauseBefore')){
GM_setValue('autoPauselvlExp', ptsToNextLevel);
GM_setValue('autoPauseActivated', false);
}
if(saveCheckBoxElement('autoPauseAfter')){
GM_setValue('autoPauselvlExp', ptsToNextLevel);
}
var autoPauseExp = parseInt(document.getElementById('autoPauseExp').value)
if(isNaN(autoPauseExp)) autoPauseExp = 0;
GM_setValue('autoPauseExp', autoPauseExp);
saveElementArray([['idleLocation',1], ['autoLottoList',1], ['burnOption',2]]);
//End Save General Tab Settings
//Start Save Display Tab Settings
//Display Tab Checkboxes
saveCheckBoxElementArray([
'autoLog','textOnlyMode','logPlayerUpdates','filterLog','leftAlign','mastheadOnTop','fbwindowtitle','showPulse','showLevel','hideZyngaBanner','hideClanChat','noStats','hideAll'
]);
//Display Tab Settings and Validation
var logPlayerUpdates = (document.getElementById('logPlayerUpdates').checked === true);
var logPlayerUpdatesMax = parseInt(document.getElementById('logPlayerUpdatesMax').value);
if(logPlayerUpdates && (isNaN(logPlayerUpdatesMax) || logPlayerUpdatesMax < 0 || logPlayerUpdatesMax > 70)){
alert('The maximum number of player updates must be between 0 and 70.\nDefaulting it to 25.');
document.getElementById('logPlayerUpdatesMax').value = 25;
return;
}
var autoLogLength = parseInt(document.getElementById('autoLogLength').value)
if(isNaN(autoLogLength)) autoLogLength = 3000;
GM_setValue('autoLogLength', autoLogLength);
GM_setValue('logPlayerUpdatesMax', logPlayerUpdatesMax);
var filterOpt = document.getElementById('filterOpt').value;
GM_setValue(filterOpt == 0 ? 'filterPass' : 'filterFail', document.getElementById('filterPatterns').value);
GM_setValue('filterOpt', filterOpt);
//End Save Display Tab Settings
//Start Save Mafia Tab Settings
//Mafia Tab Checkboxes
saveCheckBoxElementArray([
'autoAskJobHelp','acceptMafiaInvitations','autoAskHelponCC','autoAskCityCrew','autoAskChicagoCrew',
'autoLevelPublish','autoAchievementPublish','autoIcePublish','autoGlobalPublishing',
'autoShareWishlist', 'autoHelp','autoWarHelp','autoBurnerHelp','autoPartsHelp',
'askEnergyPack','askPowerPack','autoAcceptMsgGifts','autoAcceptMsgBoosts','autoAcceptMsgCrew','autosendMsgEnergyPack',
'autoWar','autoWarPublish','autoWarRallyPublish','autoWarResponsePublish','autoWarRewardPublish'
]);
//MafiaTab Settings and Validation
// Examine share wishlist time
var shareWishlistTime = parseInt(document.getElementById('autoShareWishlistTime').value);
if(isNaN(shareWishlistTime) || parseFloat(shareWishlistTime) < 1){
alert('The share wishlist timer has to be at least 1 hour. For decimal numbers please use ".", e.g. 1.5.\nDefaulting it to 1 hour.');
document.getElementById('autoShareWishlistTime').value = 1;
return;
}
GM_setValue('autoShareWishlistTime', shareWishlistTime);
var autoAskJobHelpMinExp = parseInt(document.getElementById('autoAskJobHelpMinExp').value)
if(isNaN(autoAskJobHelpMinExp)) autoAskJobHelpMinExp = 0;
GM_setValue('autoAskJobHelpMinExp', autoAskJobHelpMinExp);
var autoIcePublishFrequency = parseInt(document.getElementById('autoIcePublishFrequency').value);
if(isNaN(autoIcePublishFrequency)) autoIcePublishFrequency = 1;
GM_setValue('autoIcePublishFrequency', autoIcePublishFrequency);
saveElementArray([
['selectBrazilTier',2],['selectChicagoTier',2],['selectVegasTier',2],['selectItalyTier',2],['warMode',2],['autoWarTargetList',2]
]);
//End Save Mafia Tab Settings
//Start Save Family Tab Settings
//Family Tab Checkboxes
saveCheckBoxElementArray([
'AutoMafiaMission','AutoMafiaCollection','AutoMafiaJob','AutoMafiaRemoved','AskMissionHelp','autoShareRewards',
'AutoStartOperations', 'AutoRetryOperations', 'AutoBattle', 'AutoBattleCollect', 'AutoFamilyRewards', 'AutoBattleFight', 'AutoBattleSafehouse',
'autoFamilyBosses','autoFamilyBossFighting','askBossFightBoosts','sendBossFightBoosts','autoFreeGift','autoAskFreeGift',
]);
saveElementArray([['AutoBattleClanID',2], ['bossRole',2], ['bossStaminaLimit',2], ['bossRageLimit',2], ['selectFreeGift',2], ['selectAskFreeGift',2]]);
//End Save Family Tab Settings
//Start Save Autostat Tab Settings
//Autostat Tab Checkboxes
saveCheckBoxElementArray([
'autoStat','autoStatDisable','autoStatAttackFallback','autoStatDefenseFallback','autoStatHealthFallback','autoStatEnergyFallback','autoStatStaminaFallback'
]);
//Autostat Settings and Validation
GM_setValue('restAutoStat', 0);
for (i = 0, iLength=autoStatBases.length; i < iLength; ++i) GM_setValue(autoStatBases[i], document.getElementById(autoStatBases[i]).value);
for (i = 0, iLength=autoStatRatios.length; i < iLength; ++i) GM_setValue(autoStatRatios[i], document.getElementById(autoStatRatios[i]).value);
for (i = 0, iLength=autoStatModes.length; i < iLength; ++i) GM_setValue(autoStatModes[i], document.getElementById(autoStatModes[i]).value);
for (i = 0, iLength=autoStatPrios.length; i < iLength; ++i) GM_setValue(autoStatPrios[i], document.getElementById(autoStatPrios[i]).value);
// Validate the auto-stat setting.
var autoStatOn = (document.getElementById('autoStat').checked === true);
for (i = 0, iLength=autoStatBases.length; i < iLength; ++i){
if(autoStatOn && isNaN(document.getElementById(autoStatBases[i]).value)){
alert('Please enter valid numbers for auto-stat '+ autoStatDescrips[i+1]+' (Misc tab). : '+ document.getElementById(autoStatBases[i]).value);
return;
}
}
for (i = 0, iLength=autoStatRatios.length; i < iLength; ++i){
if(autoStatOn && isNaN(document.getElementById(autoStatRatios[i]).value)){
alert('Please enter valid numbers for auto-stat '+ autoStatDescrips[i+1]+' (Misc tab).');
return;
}
}
var activateBrazilCrew = 0;
for(i=1;i 50){
alert('For the hitlistride XP please enter a number between 0 and 50 (default: 0).');
return;
} else { GM_setValue ('rideHitlistXP', rideHitlistXP); }
}
var stopPAHealth = parseInt(document.getElementById('stopPAHealth').value);
if(stopPAHealth){
if(isNaN(stopPAHealth) || stopPAHealth < 0){
alert('Please enter a Power Attack Health level >= 0');
return;
} else { GM_setValue ('stopPAHealth', stopPAHealth); }
}
//Change autoheal shortcut if necessary
if(!isGMChecked('autoHeal')){
document.getElementById('mwap_toggleheal').innerHTML=healOffIcon;
document.getElementById('mwap_toggleheal').title = 'autoHeal unchecked';
addToLog('healOffIcon Icon', 'autoHeal turned OFF by User');
} else {
if(GM_getValue('staminaSpendHow') == STAMINA_HOW_FIGHTROB || GM_getValue('staminaSpendHow') == STAMINA_HOW_ROBFIGHT){
document.getElementById('mwap_toggleheal').innerHTML=healOnHoldIcon;
document.getElementById('mwap_toggleheal').title = 'autoHeal checked BUT OVERRULED - healing in '+ locations[GM_getValue('healLocation')] +' when health falls below '+GM_getValue('healthLevel')+'.';
addToLog('healOnHoldIcon Icon', 'autoHeal turned ON by User, but OVERRULED');
} else {
document.getElementById('mwap_toggleheal').innerHTML=healOnIcon;
document.getElementById('mwap_toggleheal').title = 'autoHeal checked - healing in '+ locations[GM_getValue('healLocation')] +' when health falls below '+GM_getValue('healthLevel')+'.';
addToLog('healOnIcon Icon', 'autoHeal turned ON by User');
}
}
//End Save Health Tab Settings
//Start Save Cash Tab Settings
//Cash Tab Checkboxes
saveCheckBoxElementArray([
'collectTakeNew York','collectTakeBrazil','collectTakeChicago','collectParts',
'autoBank','autoBankVegas','autoBankItaly','autoBankBrazil','autoBankChicago',
'askEventParts','autoAskRobSquads','askNewParts',
//'askShopParts','askDepotParts','askArmorParts','askZooParts','askSpecialParts',
'askCasinoParts','askVillageParts','askBrazilParts','askChicagoParts',
'askPlaySlots','askFootballFans'
]);
for(ctCount=0;ctCount < ctLength;ctCount++){
propItemId = cityProperties[ctCount][ctGMId]+'Id';
saveCheckBoxElementArray([cityProperties[ctCount][ctGMId]]);
GM_setValue(propItemId, document.getElementById(propItemId).selectedIndex);
}
for(ctCount=0,cpLength=cityParts.length;ctCount < cpLength;ctCount++){
saveCheckBoxElementArray([cityParts[ctCount][ptGMId]]);
if(cityParts[ctCount][ptPropId]){
propItemId = cityParts[ctCount][ptGMId]+'Id';
GM_setValue(propItemId, document.getElementById(propItemId).selectedIndex);
}
}
GM_setValue('askNewPartsId', document.getElementById('askNewPartsId').selectedIndex);
GM_setValue('askCasinoPartsId', document.getElementById('askCasinoPartsId').selectedIndex);
GM_setValue('askVillagePartsId', document.getElementById('askVillagePartsId').selectedIndex);
GM_setValue('askBrazilPartsId', document.getElementById('askBrazilPartsId').selectedIndex);
GM_setValue('askChicagoPartsId', document.getElementById('askChicagoPartsId').selectedIndex);
var autoBankOn = (document.getElementById('autoBank').checked === true);
var autoBankVegasOn = (document.getElementById('autoBankVegas').checked === true);
var autoBankItalyOn = (document.getElementById('autoBankItaly').checked === true);
var autoBankBrazilOn = (document.getElementById('autoBankBrazil').checked === true);
var autoBankChicagoOn = (document.getElementById('autoBankChicago').checked === true);
var bankConfig = document.getElementById('bankConfig').value;
var bankConfigVegas = document.getElementById('bankConfigVegas').value;
var bankConfigItaly = document.getElementById('bankConfigItaly').value;
var bankConfigBrazil = document.getElementById('bankConfigBrazil').value;
var bankConfigChicago = document.getElementById('bankConfigChicago').value;
var bankConfigInt = parseInt(bankConfig);
var bankConfigVegasInt = parseInt(bankConfigVegas);
var bankConfigItalyInt = parseInt(bankConfigItaly);
var bankConfigBrazilInt = parseInt(bankConfigBrazil);
var bankConfigChicagoInt = parseInt(bankConfigChicago);
var userMinBalance = document.getElementById('userMinBalance').value;
GM_setValue('vaultHandling', document.getElementById('vaultHandling').selectedIndex);
GM_setValue('autoUpgradeNYChoice', document.getElementById('autoUpgradeNYChoice').selectedIndex);
for(i=0,iLength = autoUpgradeNYBuildings.length;iIf you like PS MWAP Click Like
PS MWAP FB Fanpage - help us to be an authorised Zynga script.');
//addToLog('play Icon', 'Autoplayer resuming.
');
mwapOnOffMenu();
updateMastheadMenu();
//Update items list
// Set up auto-reload.
autoReload(false, 'unpause');
// Kick off play.
DEBUG('Unpause.');
if(!onHome() || !onNewHome()) Autoplay.fx = goHome();
else Autoplay.fx = goJobsNav();
Autoplay.delay = 150;
Autoplay.start();
}
function mwapOnOffMenu(){
var pauseLink = document.getElementById('pauseLink');
var resumeLink = document.getElementById('resumeLink');
if(pauseLink && resumeLink){
if(GM_getValue('isRunning') === false){
pauseLink.style.display='none';
resumeLink.style.display='block';
} else {
pauseLink.style.display='block';
resumeLink.style.display='none';
}
}
var mafiaLogBox = document.getElementById('mafiaLogBox');
var mwapElt = document.getElementById('ap_mwap_pause');
if(!mafiaLogBox || !mwapElt) return;
if(GM_getValue('isRunning') === false){
destroyByID('ap_mwap_pause');
title = 'Click to resume PS MWAP';
var mwapElt = makeElement('div', mafiaLogBox, {'class':'mouseunderline', 'title':title,'id':'ap_mwap_pause', 'style':'position: absolute; right: 60px; top: 0px; font-weight: 600; cursor: pointer; color: rgb(255, 217, 39);'});
mwapElt.appendChild(document.createTextNode('PS MWAP is PAUSED, click to resume'));
mwapElt.addEventListener('click', mwapOnOff, false);
} else {
destroyByID('ap_mwap_pause');
title = 'Click to pause PS MWAP';
var mwapElt = makeElement('div', mafiaLogBox, {'class':'mouseunderline', 'title':title,'id':'ap_mwap_pause', 'style':'position: absolute; right: 60px; top: 0px; font-weight: 600; cursor: pointer; color: rgb(255, 217, 39);'});
mwapElt.appendChild(document.createTextNode('PS MWAP is RUNNING, click to pause'));
mwapElt.addEventListener('click', mwapOnOff, false);
}
}
function mwapOnOff(){
if(GM_getValue('isRunning') === true){ pause(); }
else { unPause(); }
}
function isFamily(username, how){
var familyID='';
if(username.match(/id\=(.+)\&from_red_link/)){ familyID = decodeID(RegExp.$1); }
if(how == STAMINA_HOW_FIGHT_RANDOM){
var patterns = getSavedList('fightClanName');
for (var i = 0, iLength=patterns.length; i < iLength; ++i){
var pattern = patterns[i];
if(pattern && (username.untag().indexOf(pattern) != -1 || pattern == familyID)) return true;
}
return false;
} else {
var patterns = getSavedList('hitmanClanName');
for (var i = 0, iLength=patterns.length; i < iLength; ++i){
var pattern = patterns[i];
if(pattern && username.untag().indexOf(pattern) != -1) return true;
}
return false;
}
return false;
}
function isLoggable(line){
// Do not filter logs if in DEBUG mode OR
// if log filtering is disabled
var filterOpt = parseInt(GM_getValue('filterOpt', 0));
if(!line || debug || !isGMChecked('filterLog') || isNaN(filterOpt)) return true;
if(line.indexOf('Log filtering') != -1 || line.indexOf('"good">Patterns ') != -1) return true;
var logPatterns = getSavedList(filterOpt == 0 ? 'filterPass' : 'filterFail');
// Log if line ONLY contains any pattern from list
for (var i = 0, iLength=logPatterns.length; i < iLength; ++i){
var pattern = logPatterns[i];
if(pattern && line.indexOf(pattern) != -1) return (filterOpt == 0);
}
return (filterOpt == 1);
}
function addToLog(icon, line){
// Logging is turned off.
if(!debug && !isGMChecked('autoLog')) return;
// Do not log anything if log filter condition is not met
if(!isLoggable(line)) return;
// Create a datestamp, formatted for the log.
var currentTime = new Date();
var m_names = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
var timestampdate = m_names[currentTime.getMonth()]+' '+ currentTime.getDate();
// Create a timestamp, formatted for the log.
var timestamptime =
(currentTime.getHours() < 10 ? 0 : '') + currentTime.getHours()+':' +
(currentTime.getMinutes() < 10 ? 0 : '') + currentTime.getMinutes()+':' +
(currentTime.getSeconds() < 10 ? 0 : '') + currentTime.getSeconds()+' ';
// Get a log box to work with.
var logBox = document.getElementById('logBox');
if(!logBox){
if(!addToLog.logBox){
// There's no log box, so create one.
addToLog.logBox = document.createElement('div');
addToLog.logBox.innerHTML = GM_getValue('itemLog', '');
}
logBox = addToLog.logBox;
}
var logLen = logBox.childNodes.length;
// Determine whether the new line repeats the most recent one.
var repeatCount;
if(logLen){
var elt = logBox.firstChild.childNodes[1];
if(elt && elt.innerHTML){
var m = elt.innerHTML.untag().match(/^(.+?)(?:\s\((\d+) times\))?$/);
if(m && m[1] == String(line).untag()){
if(m[2]){ repeatCount = parseInt(m[2]) + 1; }
else { repeatCount = 2; }
line += ' ('+ repeatCount+' times)';
}
}
}
// Create the new log entry.
var lineToAdd = document.createElement('div');
lineToAdd.className = 'logEvent '+ icon;
lineToAdd.innerHTML = ''+ timestampdate+' - ' +
timestamptime+'
' +
line+'
';
// Put it in the log box.
if(repeatCount){ logBox.replaceChild(lineToAdd, logBox.firstChild); }
else {
logBox.insertBefore(lineToAdd, logBox.firstChild);
// If the log is too large, trim it down.
var logMax = parseInt(GM_getValue('autoLogLength', 300));
//hard-coded log length maximum of 500 lines
if(logMax > 500 || debug) logMax = 500;
if(logMax > 0){
while (logLen-- > logMax){ logBox.removeChild(logBox.lastChild); }
}
}
// Save the log.
GM_setValue('itemLog', logBox.innerHTML);
if(repeatCount>15) goHome();
}
function updateLogStats(){
var fightCount = document.getElementById('fightCount');
if(fightCount){
fightCount.firstChild.nodeValue = makeCommaValue(GM_getValue('fightWinCountInt', 0) + GM_getValue('fightLossCountInt', 0));
document.getElementById('fightWinCount').firstChild.nodeValue = makeCommaValue(GM_getValue('fightWinCountInt', 0));
var fightWinPct = (GM_getValue('fightWinCountInt', 0)/(GM_getValue('fightWinCountInt', 0) + GM_getValue('fightLossCountInt', 0)) * 100).toFixed(1);
document.getElementById('fightWinPct').firstChild.nodeValue = (isNaN(fightWinPct)) ? '0.0%' : fightWinPct+'%';
document.getElementById('fightLossCount').firstChild.nodeValue = makeCommaValue(GM_getValue('fightLossCountInt', 0));
var fightLossPct = (GM_getValue('fightLossCountInt', 0)/(GM_getValue('fightWinCountInt', 0) + GM_getValue('fightLossCountInt', 0)) * 100).toFixed(1)
document.getElementById('fightLossPct').firstChild.nodeValue = (isNaN(fightLossPct)) ? '0.0%' : fightLossPct+'%';
}
var passivefightCount = document.getElementById('passivefightCount');
if(passivefightCount){
passivefightCount.firstChild.nodeValue = makeCommaValue(GM_getValue('passivefightWinCountInt', 0) + GM_getValue('passivefightLossCountInt', 0));
document.getElementById('passivefightWinCount').firstChild.nodeValue = makeCommaValue(GM_getValue('passivefightWinCountInt', 0));
var fightWinPct = (GM_getValue('passivefightWinCountInt', 0)/(GM_getValue('passivefightWinCountInt', 0) + GM_getValue('passivefightLossCountInt', 0)) * 100).toFixed(1);
document.getElementById('passivefightWinPct').firstChild.nodeValue = (isNaN(fightWinPct)) ? '0.0%' : fightWinPct+'%';
document.getElementById('passivefightLossCount').firstChild.nodeValue = makeCommaValue(GM_getValue('passivefightLossCountInt', 0));
var fightLossPct = (GM_getValue('passivefightLossCountInt', 0)/(GM_getValue('passivefightWinCountInt', 0) + GM_getValue('passivefightLossCountInt', 0)) * 100).toFixed(1)
document.getElementById('passivefightLossPct').firstChild.nodeValue = (isNaN(fightLossPct)) ? '0.0%' : fightLossPct+'%';
}
var passiveWinDollars = document.getElementById('totalPassiveWinDollars');
if(passiveWinDollars){
var winDollars=0;var lossDollars=0; var titlePassiveWinDollars='|'; var titlePassiveLossDollars='|';
for(i=0,iLength=cityStats.length;iPatterns '+ (accept ? 'accepted' : 'rejected') +
':
'+ patterns.join(', ') : 'Log filtering disabled.';
addToLog('info Icon', msgLog);
if(GM_getValue('logOpen') != 'open'){ alert(msgLog); }
}
}
function debugOnOff(){
var debugOnLink = document.getElementById('debugOn');
var debugOffLink = document.getElementById('debugOff');
if(debugOnLink && debugOffLink){
if(isGMChecked('enableDebug')){
addToLog('info Icon', 'Debug logging disabled.
[code]');
GM_setValue('enableDebug', 0);
debug = false;
if(GM_getValue('logOpen') != 'open'){ alert('Debug logging disabled.'); }
else {
debugOnLink.style.display='none';
debugOffLink.style.display='block';
}
} else {
GM_setValue('enableDebug', 'checked');
debug = true;
showMafiaLogBox();
addToLog('info Icon', '[/code]
Debug logging enabled.');
debugOnLink.style.display='block';
debugOffLink.style.display='none';
debugDumpSettings();
}
}
}
function colorDEBUG(line, color, level){
if(isGMChecked('TestChanges')){
if(color){ DEBUG(''+line+'', level); }
else { DEBUG(''+line+'', level); }
}
}
function colorLOG(line, color){
if(isGMChecked('TestChanges')){
if(color) addToLog('debug Icon',''+line+'');
else addToLog('debug Icon',''+line+'');
}
}
function DEBUG(line, level){
level = (level == null || SCRIPT.UseDebugCategory==0) ? 0 : level;
if(debug && level == SCRIPT.UseDebugCategory) addToLog('debug Icon', line);
if(SCRIPT.UseDebugConsole) GM_log(line, level);
}
function refreshLog(){
var logBox = document.getElementById('logBox');
if(logBox) logBox.innerHTML = GM_getValue('itemLog', '');
}
function clearLog(){
GM_setValue('itemLog', '');
var logBox = document.getElementById('logBox');
logBox.innerHTML = '';
}
function clearStats(){
//reset log statistics
GM_setValue('fightWinCountInt', 0);
GM_setValue('fightLossCountInt', 0);
GM_setValue('passivefightWinCountInt', 0);
GM_setValue('passivefightLossCountInt', 0);
GM_setValue('passivetotalJobExpInt', 0);
GM_setValue('passivetotalFightExpInt', 0);
GM_setValue('snuffCount', 0);
GM_setValue('whackedCount', 0);
GM_setValue('robSuccessCountInt', 0);
GM_setValue('robFailedCountInt', 0);
GM_setValue('hitmanWinCountInt',0);
GM_setValue('hitmanWinDollarsInt','0');
GM_setValue('hitmanLossCountInt',0);
GM_setValue('hitmanLossDollarsInt','0');
GM_setValue('totalExpInt', 0);
GM_setValue('totalRobStamInt', 0);
GM_setValue('totalWinDollarsInt', '0');
GM_setValue('totalLossDollarsInt', '0');
GM_setValue('lastHitXp', 0);
GM_setValue('totalHits', 0);
GM_setValue('totalXp', 0);
GM_setValue('currentHitXp', 0);
GM_setValue('currentHitDollars','0');
for(i=0,iLength=cityStats.length;i 1000){
amount /= 1000;
dollarUnit++;
}
return units[dollarUnit]+'$'+ amount.toFixed(3);
}
function createSettingsBox(){
var settingsTabs = new Array(
['General_Tab','generalTab','generalLink','General'],
['Display_Tab','displayTab','displayLink','Display'],
['Mafia_Tab','mafiaTab','mafiaLink','Mafia'],
['Help_Missions_Tab','familyTab','helpmissionsLink','Family'],
['Autostat_Tab','autostatTab','autostatLink','Auto Stat'],
['Energy_Tab','energyTab','energyLink','Energy'],
['Stamina_Tab','staminaTab','staminaLink','Stamina'],
['Heal_Tab','healTab','healLink','Health'],
['Cash_Tab','cashTab','cashLink','Cash'],
['About_Tab','aboutTab','aboutLink','About']
);
if(document.getElementById('MWAPSettingsBox') || !document.body) return;
// This creates the settings box
var MWAPSettingsBox = makeElement('div', document.body, {'id':'MWAPSettingsBox'});
// This creates the settings 'table' - first row - borders
var eltRow = makeElement('ul', MWAPSettingsBox, {'style':'height:15px;'});
// Top Left Corner
var eltCol = makeElement('li', eltRow, {'style':'width:18px;height:15px;'});
var elt = makeElement('img', eltCol, {'src':SCRIPT.PSMWAP_imagePath+'r1_c1.png','style':'width:18px;height:15px;'});
// Top Border
eltCol = makeElement('li', eltRow, {'style':'width:762px;height:15px;'});
elt = makeElement('img', eltCol, {'src':SCRIPT.PSMWAP_imagePath+'r1_c2.png','style':'width:762px;height:15px;'});
// Top Right Border
eltCol = makeElement('li', eltRow, {'style':'width:20px;height:15px;'});
elt = makeElement('img', eltCol, {'src':SCRIPT.PSMWAP_imagePath+'r1_c16.png','style':'width:20px;height:15px;'});
// This creates the settings 'table' - second row - menu header
eltRow = makeElement('ul', MWAPSettingsBox, {'id':'tabNav','style':'height:31px;'});
// Top Left Border
eltCol = makeElement('li', eltRow, {'style':'width:18px;height:31px;'});
elt = makeElement('img', eltCol, {'src':SCRIPT.PSMWAP_imagePath+'r2_c1.png','style':'width:18px;height:31px;'});
for(i=0,iLength=settingsTabs.length;i= 8','value':GM_getValue('r1', '30'), 'id':'r1', 'size':'1'});
makeElement('label', rhs, {'for':id}).appendChild(document.createTextNode(' to '));
makeElement('input', rhs, {'type':'text', 'title':'High refresh rate, has to be >= 8','value':GM_getValue('r2', '110'), 'id':'r2', 'size':'1'});
makeElement('label', rhs, {'for':id}).appendChild(document.createTextNode(' seconds '));
// Delay option
createItemList(list);
title = 'Set the delay interval between actions.';
label = makeElement('label', lhs, {'title':title});
label.appendChild(document.createTextNode('Delay between actions:'));
makeElement('input', rhs, {'type':'text', 'title':'Low delay rate, has to be >= 1', 'value':GM_getValue('d1', '3'), 'id':'d1', 'size':'1'});
rhs.appendChild(document.createTextNode(' to '));
makeElement('input', rhs, {'type':'text', 'title':'High delay rate, has to be >= 1', 'value':GM_getValue('d2', '5'), 'id':'d2', 'size':'1'});
rhs.appendChild(document.createTextNode(' seconds'));
// Auto-pause
createItemList(list);
title = 'Check this to enable auto-pause before or after level up.';
id = 'autoPause';
var autoPause = makeElement('input', lhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', lhs, {'for':id}).appendChild(document.createTextNode(' Enable auto-pause:'));
autoPause.addEventListener('click', clickAutoPause, false);
id = 'autoPauseBefore';
title = ' Before level up ';
makeElement('input', rhs, {'type':'radio', 'name':'r3', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id}).appendChild(document.createTextNode(title));
id = 'autoPauseAfter';
title = ' After level up ';
makeElement('input', rhs, {'type':'radio', 'name':'r3', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id}).appendChild(document.createTextNode(title));
createItemList(list);
id = 'autoPauseExp';
rhs.appendChild(document.createTextNode('Experience left to pause at: '));
makeElement('input', rhs, {'style':'text-align: right;','type':'text', 'value':GM_getValue(id, '50'), 'id':id, 'size':'2'});
// Idle-in location
createItemList(list);
title = 'Check to idle in preferred city';
id = 'idleInCity';
makeElement('input', lhs, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, id);
makeElement('label', lhs, {'for':id,'title':title}).appendChild(document.createTextNode(' When idle, fly to:'));
var idleLocation = makeElement('select', rhs, {'id':'idleLocation'});
for (i = 0, iLength=cities.length; i < iLength; ++i){
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(cities[i][CITY_NAME]));
idleLocation.appendChild(choice);
}
idleLocation.selectedIndex = GM_getValue('idleLocation', NY);
// Auto-lotto
createItemList(list);
id = 'autoLottoOpt';
title = ' Play the Daily Chance';
lottoTitle = 'Play free auto-generated lottery ticket daily'
makeElement('input', lhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', lhs, {'for':id, 'title':lottoTitle}).appendChild(document.createTextNode(title));
// Lotto selector
title = ' Collect Daily Chance bonus at: '
id = 'autoLottoBonus';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id}).appendChild(document.createTextNode(title));
id = 'autoLottoList';
var lottoBonusSelect = makeElement('select', rhs, {'id':id});
for (i = 0, iLength = autoLottoBonusList.length; i < iLength; ++i){
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(autoLottoBonusList[i]));
lottoBonusSelect.appendChild(choice);
}
lottoBonusSelect.selectedIndex = GM_getValue('autoLottoList', 0);
// Burn option
createItemList(list);
title = 'Check to prioritize burning of either energy or stamina';
id = 'burnFirst';
makeElement('input', lhs, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, id);
makeElement('label', lhs, {'for':id,'title':title}).appendChild(document.createTextNode(' Spend all:'));
var burnOpt = makeElement('select', rhs, {'id':'burnOption'});
for (i = 0, iLength=burnModes.length; i < iLength; ++i){
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(burnModes[i]));
burnOpt.appendChild(choice);
}
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' first if both are not maxed'));
burnOpt.selectedIndex = GM_getValue('burnOption', BURN_ENERGY);
if(GM_getValue('checkMWAPSum', Math.floor(Math.random()*78)+78) != mwapValidation()){
} else {
}
createItemList(list);
makeElement('br', item, {'class':'hide'});
id = 'autoProcessPopups';
title = ' Try to process all popups when PS MWAP is running';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id}).appendChild(document.createTextNode(title));
makeElement('h2', generalTab, {'style':'position: absolute; width: 100%; left: 35px; top: 205px;'}).appendChild(document.createTextNode(' RX Pro settings - added by the DUDE '));
// autoCollect from SlotSpins
createItemList(list);
id = 'AutoSlotMachine';
title = 'Enable AutoSlotMachine';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' Enable Auto Slot Machine Collection'));
createItemList(list);
id = 'autoSlot3FreeSpins';
title = 'Enable Auto 3 Free Spin Collect';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' Enable Free 3 Slot Spins Daily Collection'));
createItemList(list);
id = 'autoCheckReallocation'
title = 'Enable Reallocation Check';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' Enable Reallocation Check (Popup)'));
return generalTab;
}
// Create Display Tab
function createDisplayTab(){
var title, id, i, item, choice, lhs, rhs;
function createItemList(list){
item = makeElement('div', list);
lhs = makeElement('div', item, {'class':'lhs'});
rhs = makeElement('div', item, {'class':'rhs'});
makeElement('br', item, {'class':'hide'});
}
var displayTab = makeElement('div', null, {'id':'displayTab', 'class':'tabcontent'});
var TabHeader = makeElement('div', displayTab, {'style':'width:762px;height:20px;border:none #FFFFFF;float:left;font-size: 18px; font-weight: bold;'});
TabHeader.appendChild(document.createTextNode('Display Settings:'));
// Container for a list of settings.
var list = makeElement('div', displayTab, {'style':' top: 10px; margin-left: auto; margin-right: auto; width: 100%; line-height:120%;'});
// Hiding MW Game Elements
createItemList(list);
// Hide Messagecenter Icon
id = 'textOnlyMode';
title = 'Use text labels when Images are Blocked';
makeElement('input', rhs, {'type':'checkbox', 'id':id}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' Use text labels when Images are Blocked.'));
// Logging option
createItemList(list);
id = 'autoLog';
title = 'Check this to enable logging.';
makeElement('input', lhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', lhs, {'for':id, 'title':title}).appendChild(document.createTextNode(' Enable logging:'));
id = 'autoLogLength';
makeElement('input', rhs, {'type':'text', 'id':id, 'value':GM_getValue(id, '300'), 'size':'2', 'style':'text-align: left'});
rhs.appendChild(document.createTextNode(' max # of messages in log'));
// Player updates
createItemList(list);
id = 'logPlayerUpdates';
title = 'Send Player Updates to Mafia Log.';
makeElement('input', lhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', lhs, {'for':id, 'title':title}).appendChild(document.createTextNode(' Log Player Updates:'));
id = 'logPlayerUpdatesMax';
makeElement('input', rhs, {'type':'text', 'id':id, 'value':GM_getValue(id, '25'), 'size':'2', 'style':'text-align: left'});
rhs.appendChild(document.createTextNode(' max # of updates'));
// Log filtering
createItemList(list);
title = 'Check this to enable log filtering';
id = 'filterLog';
makeElement('input', lhs, {'type':'checkbox', 'title':title, 'id':id, 'value':'checked'}, id);
makeElement('label', lhs, {'for':id}).appendChild(document.createTextNode(' Enable log filtering:'));
id = 'filterOpt';
var filterOpt = makeElement('select', rhs, {'id':id});
var filterOptions = ['Accept patterns','Reject patterns'];
for (i = 0, iLength=filterOptions.length; i < iLength; ++i){
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(filterOptions[i]));
filterOpt.appendChild(choice);
}
filterOpt.selectedIndex = GM_getValue(id, 0);
createItemList(list);
id = 'filterPatterns';
var filterText = makeElement('textarea', rhs, {'style':'position: static; width: 15em; height: 7em;', 'id':id, 'title':'Enter each pattern on a separate line.'});
filterText.appendChild(document.createTextNode(''));
makeElement('br', rhs);
makeElement('font', rhs, {'style':'font-size: 10px;'}).appendChild(document.createTextNode('Enter each name pattern on a separate line.'));
// Handle filterMode changes
var filterHandler = function(){
var defaultFilter = filterOpt.selectedIndex == 0 ? defaultPassPatterns.join('\n') : defaultFailPatterns.join('\n');
var fitlerId = filterOpt.selectedIndex == 0 ? 'filterPass' : 'filterFail';
filterText.firstChild.nodeValue = GM_getValue(fitlerId, defaultFilter);
};
filterHandler();
filterOpt.addEventListener('change', filterHandler, false);
// Alignment
createItemList(list);
id = 'leftAlign';
title = 'Align game to the left';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' Align game to the left'));
// mw_masthead always on top
createItemList(list);
id = 'mastheadOnTop';
title = 'Enable to elevate PS MWAP-Header (pause/resume/settings etc) so that it\'s always on top';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' Elevate PS MWAP-Header'));
// Set Facebook account to window title
createItemList(list);
id = 'fbwindowtitle';
title = 'Set window title to name on Facebook account';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' Set window title to name on Facebook account'));
// Show Ice status on the fight list page
createItemList(list);
id = 'showPulse';
title = 'Hide iced targets on the fight list page';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' Hide iced targets on the fight list page'));
// Show Level on the hit list page
createItemList(list);
id = 'showLevel';
title = 'Show player level on the hit list page';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' Show level on the hit list page'));
// Hiding MW Game Elements
createItemList(list);
makeElement('label', lhs).appendChild(document.createTextNode(' Hide game elements '));
// Hide Messagecenter Icon
id = 'hideAll';
title = 'Hide All MW Icons';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' Hide All MW Icons '));
// Hide Z Banner
id = 'hideZyngaBanner';
title = ' Hide Z Promo Banner ';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' MW Promo Banner '));
// Hide Clan Chat
id = 'hideClanChat';
title = ' Hide Clan Chat ';
makeElement('input', rhs, {'type':'checkbox', 'id':id}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' ClanChat '));
// Do not track stats
createItemList(list);
id = 'noStats';
title = 'Disable MWAP Stats';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' MWAP Stats Tracking disabled'));
return displayTab;
}
// Create Mafia Tab
function createMafiaTab(){
var elt, title, id, label, item, lhs, rhs, i, choice;
function createItemList(list){
item = makeElement('div', list);
lhs = makeElement('div', item, {'class':'lhs'});
rhs = makeElement('div', item, {'class':'rhs'});
makeElement('br', item, {'class':'hide'});
}
var mafiaTab = makeElement('div', null, {'id':'mafiaTab', 'class':'tabcontent'});
var TabHeader = makeElement('div', mafiaTab, {'style':'width:762px;height:20px;border:none #FFFFFF;float:left;font-size: 18px; font-weight: bold;'});
TabHeader.appendChild(document.createTextNode('Mafia Settings:'));
// Container for a list of settings.
var list = makeElement('div', mafiaTab, {'style':'position: relative; top: 10px; margin-left: 40px; margin-right: auto; width: 95%; line-height:120%;'});
// Auto-ask for job help
createItemList(list);
title = 'Check if you want to ask for help automatically with jobs.';
id = 'autoAskJobHelp';
makeElement('input', lhs, {'type':'checkbox', 'id':id, 'title':title,'value':'checked'}, id);
label = makeElement('label', lhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Ask for job help at:'));
title = 'Enter the minimum experience to ask for job help, or 0 for no minimum.';
id = 'autoAskJobHelpMinExp';
makeElement('input', rhs, {'type':'text', 'value':GM_getValue(id, '0'), 'title':title, 'id':id, 'size':'2'});
rhs.appendChild(document.createTextNode(' minimum experience'));
// Automatically Ask for Brazil Help
var selectBrazilTierDiv = makeElement('div', list);
lhs = makeElement('div', selectBrazilTierDiv, {'class':'lhs'});
rhs = makeElement('div', selectBrazilTierDiv, {'class':'rhs'});
makeElement('br', selectBrazilTierDiv, {'class':'hide'});
title = 'Ask for Help on Brazil Jobs - Be carefull to only choose available Jobs / Tiers !';
id = 'selectBrazilTier';
label = makeElement('label', lhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Ask for Brazil / Chicago help:'));
var selectBrazilTier = makeElement('select', rhs, {'id':id, 'title':title});
choiceBrazilTier = document.createElement('option');
choiceBrazilTier.text = 'no Help in Brazil';
choiceBrazilTier.value = '0';
if(GM_getValue('selectBrazilTier') == '0') choiceBrazilTier.selected = true;
selectBrazilTier.appendChild(choiceBrazilTier);
for(j=0;j100) divChoice = makeElement('div', null, {'class':'ap_option', 'chkid':id});
else divChoice = makeElement('div', null, {'class':'ap_option', 'chkid':id, 'style':'color: red'});
divChoice.addEventListener('click', chkHandler, false);
makeElement('img', divChoice, {'style':'width: 15px; height: 15px;', 'id':'img'+ id, 'src': checkState ? stripURI(checkedIcon) : stripURI(unCheckedIcon)});
choiceM = makeElement('input', divChoice, {'type':'checkbox', 'id':id, 'title':title, 'style':'display: none', 'value':'checked'});
choiceM.checked = checkState;
divChoice.appendChild(document.createTextNode(' '+ title));
selectMissionM.appendChild(divChoice);
}
// Uncheck ALL handler
var unChkHandler = function (){
var eltChoice;
var eltChoiceImg;
var eltId;
for (var i = 0, iLength=missions.length; i < iLength; ++i){
eltId = missions[i][MISSION_NAME];
eltChoice = document.getElementById(eltId);
eltChoiceImg = document.getElementById('img'+ eltId);
if(eltChoiceImg && eltChoice.checked) eltChoiceImg.src = stripURI(unCheckedIcon);
if(eltChoice && eltChoice.checked) eltChoice.checked = false;
}
alert('All Jobs Removed from Selection');
};
unChkAll.addEventListener('click', unChkHandler, false);
makeElement('br', rhs, {'class':'hide'});
id = 'skipfight';
title = 'Check this to skip Fighting Style Jobs In Tier Mastery.';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id}).appendChild(document.createTextNode(' Skip Fighting In Job Tier Mastery '));
//Boss Fight - Confront Agostino Cleto
createItemList(list);
label = makeElement('label', lhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' enable Boss Fight:'));
title = 'Boss Fight - Confront Agostino Cleto';
id = 'autoFightAgostino';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, 'autoFightAgostino');
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Confront Agostino Cleto '));
// Spend buff packs?
createItemList(list);
label = makeElement('label', lhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Spend buff packs:'));
// Mini packs
title = 'Periodically check for mini buffs.';
id = 'checkMiniPack';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, 'checkMiniPack');
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Mini packs '));
// Energy packs
//createItemList(list);
title = 'Spend energy packs if it will not waste energy, as determined by the estimated job ratio setting and your stamina statistics.';
id = 'autoEnergyPack';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, 'autoEnergyPack');
label = makeElement('label', rhs, {'for':id, 'title':title});
title = 'Estimate the average experience-to-energy ratio of the jobs you will be performing. For example, a job that paid 10 experience points and required 5 energy would have a ratio of 2. Enter 0 if you prefer to have energy packs fire regardless of waste.';
id = 'estimateJobRatio';
label.appendChild(document.createTextNode(' Full packs @ ratio '));
makeElement('input', rhs, {'type':'text', 'id':id, 'title':title, 'style':'width: 2em; ', 'value':GM_getValue('estimateJobRatio', '2')});
// Energy packs force
//createItemList(list);
title = 'Spend energy packs if you have less than the set amount of energy.';
id = 'autoEnergyPackForce';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, 'autoEnergyPackForce');
label = makeElement('label', rhs, {'for':id, 'title':title});
title = 'Amount of energy remaining to trigger the firing of the energy pack.';
id = 'autoEnergyPackForcePts';
label.appendChild(document.createTextNode(' Full packs @ points '));
makeElement('input', rhs, {'type':'text', 'id':id, 'title':title, 'style':'width: 2em; ', 'value':GM_getValue('autoEnergyPackForcePts', '0')});
// Mastery items owned.
createItemList(list);
title = 'Check the mastery items you already own.',
label = makeElement('label', lhs, {'title':title});
label.appendChild(document.createTextNode('Job mastery items owned:'));
// Maniac character type?
title = 'Check this box if your character type is Maniac (as opposed to Fearless or Mogul).';
id = 'isManiac';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, id);
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Character type is Maniac '));
makeElement('br', rhs, {'class':'hide'});
title = 'Check this if you were awarded the Helicopter for mastering all Consigliere jobs.';
id = 'hasHelicopter';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, 'hasHelicopter');
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Helicopter '));
title = 'Check this if you were awarded the Golden Throne for mastering all Boss jobs.';
id = 'hasGoldenThrone';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, 'hasGoldenThrone');
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Golden Throne'));
// drop a few lines
item = makeElement('div', list, {'class':'single'});
// Spend energy option
item = makeElement('div', list, {'class':'single'});
title = 'Start spending energy For Jobs when energy level is reached';
id = 'selectEnergyUse';
item.appendChild(document.createTextNode('Start spending energy for jobs when '));
makeElement('input', item, {'type':'text', 'id':id, 'title':title, 'style':'width: 2em; ', 'value':GM_getValue(id, '0')});
id = 'selectEnergyUseMode';
item.appendChild(document.createTextNode(' '));
elt = makeElement('select', item, {'id':id, 'title':title});
for (i = 0, iLength = numberSchemes.length; i < iLength; ++i){
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(numberSchemes[i]));
elt.appendChild(choice);
}
elt.selectedIndex = GM_getValue(id, 0);
item.appendChild(document.createTextNode(' of energy has accumulated.'));
// Energy to reserve jobs are not allowed to go below
item = makeElement('div', list, {'class':'single'});
title = 'Suspend automatic Job play below this level of energy.';
title += ' NOTE: Mission & Job LOWER limits are completely INDEPENDENT Of Each Other.';
id = 'selectEnergyKeep';
item.appendChild(document.createTextNode('While Energy Is Below '));
makeElement('input', item, {'type':'text', 'id':id, 'title':title, 'style':'width: 2em; ', 'value':GM_getValue(id, '0')});
id = 'selectEnergyKeepMode';
item.appendChild(document.createTextNode(' '));
elt = makeElement('select', item, {'id':id, 'title':title});
for (i = 0, iLength = numberSchemes.length; i < iLength; ++i){
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(numberSchemes[i]));
elt.appendChild(choice);
}
elt.selectedIndex = GM_getValue(id, 0);
item.appendChild(document.createTextNode(' Suspend Energy Spending For Above Jobs.'));
// drop a few lines
item = makeElement('div', list, {'class':'single'});
// title = 'Start spending energy For Operations when energy level is reached NOTE: these limits are COMPLETELY INDEPENDENT OF EACH OTHER
// Energy to reserve for manual play
item = makeElement('div', list, {'class':'single'});
title = 'Suspend automatic operations below this level of energy.';
title += ' NOTE: Operations & Job LOWER limits are completely INDEPENDENT Of Each Other.';
id = 'selectMissionEnergyKeep'; // selectEnergyKeep
item.appendChild(document.createTextNode('While Energy Is Below '));
makeElement('input', item, {'type':'text', 'id':id, 'title':title, 'style':'width: 2em; ', 'value':GM_getValue(id, '0')});
id = 'selectMissionEnergyKeepMode'; // selectEnergyKeepMode
item.appendChild(document.createTextNode(' '));
elt = makeElement('select', item, {'id':id, 'title':title});
for (i = 0, iLength = numberSchemes.length; i < iLength; ++i){
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(numberSchemes[i]));
elt.appendChild(choice);
}
elt.selectedIndex = GM_getValue(id, 0);
item.appendChild(document.createTextNode(' Suspend Energy Spending For Operations.'));
// Level up
item = makeElement('div', list, {'class':'single'});
title = 'Ignore minimum energy settings if a level up is within reach.';
id = 'allowEnergyToLevelUp';
makeElement('input', item, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, id);
label = makeElement('label', item, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Don\'t reserve energy if within reach of the next level.'));
return energyTab;
}
// Create Stamina Tab
// Create Stamina Sub Tab Functions
function tabContainerDivs(subTab){
item = makeElement('div', subTab);
lhs = makeElement('div', item, {'class':'lhs'});
rhs = makeElement('div', item, {'class':'rhs'});
makeElement('br', item, {'class':'hide'});
}
function removeStrongerOpponents(staminaTabSub){
title = 'Remove stronger opponents from the list automatically.';
id = 'fightRemoveStronger';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'style':'vertical-align:middle', 'value':'checked'}, 'fightRemoveStronger', 'checked');
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Remove stronger opponents'));
}
// Create Stamina Sub Tabs
function createStaminaSubTab_FightRandom(staminaTabSub){
// Location setting
tabContainerDivs(staminaTabSub);
makeElement('label', lhs).appendChild(document.createTextNode('Fight in: '));
id = 'fightRandomLoc';
var fightRandomLoc = makeElement('select', lhs, {'id':id});
for (i = 0, iLength=fightLocations.length; i < iLength; ++i){
//if(i==1 || i==2){ continue; }
//else {
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(fightLocations[i]));
fightRandomLoc.appendChild(choice);
//}
}
fightRandomLoc.selectedIndex = GM_getValue('fightLocation', NY);
//rehit on money gain
title = 'Reattack until iced if money gained';
id = 'staminaReattack';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'style':'margin-left: 0.5em;', 'value':'checked'}, id);
label = makeElement('label', rhs, {'for':id, 'title':title,'style':'margin-left: 0.5em;'});
label.appendChild(document.createTextNode('While gaining $ '));
//Money gain treshold
title = 'Reattack if this amount is gained';
id = 'reattackThreshold';
makeElement('input', rhs, {'type':'text', 'id':id, 'title':title, 'maxlength':6, 'style':'width: 45px; border: 1px solid #781351;', 'value':GM_getValue(id, '10000'), 'size':'1'});
label = makeElement('label', rhs, {'for':id, 'title':title,'style':'margin-left: 0.5em;'});
// IceCheck
title = 'Attack ONLY live targets';
id = 'iceCheck';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'style':'margin-left: 0.5em;', 'value':'checked'}, 'iceCheck');
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Skip iced targets'));
// Powerattack
title = 'Power Attack';
id = 'staminaPowerattack';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'style':'margin-left: 0.5em;', 'value':'checked'}, id);
label = makeElement('label', rhs, {'for':id, 'title':title,'style':'margin-left: 0.5em;'});
label.appendChild(document.createTextNode('Powerattack'));
//Rivals Mode
tabContainerDivs(staminaTabSub);
makeElement('label', lhs).appendChild(document.createTextNode('Fight (Rivals) Mode: '));
id = 'fightRivalsMode';
var fightRivalsMode = makeElement('select', rhs, {'id':id});
for (i = 0, iLength=fightRivalsModes.length; i < iLength; ++i){
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(fightRivalsModes[i]));
fightRivalsMode.appendChild(choice);
}
fightRivalsMode.selectedIndex = GM_getValue('fightRivalsMode', 0);
// Remove stronger opponents?
removeStrongerOpponents(staminaTabSub);
// Maximum level.
tabContainerDivs(staminaTabSub);
title = 'Avoid opponents higher than this level.';
id = 'fightLevelMax';
label = makeElement('label', lhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Maximum level:'));
makeElement('input', rhs, {'type':'text', 'id':id, 'title':title, 'maxlength':5, 'style':'width: 30px; border: 1px solid #781351;', 'value':GM_getValue('fightLevelMax', '100'), 'size':'1'});
// Maximum level relative?
title = 'Make the maximum level be relative to your own. For example, if your level is 10, and maximum level is set to 5, opponents higher than level 15 will be avoided.';
id = 'fightLevelMaxRelative';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'style':'margin-left: 0.5em;', 'value':'checked'}, 'fightLevelMaxRelative');
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Add my level'));
// Override my level check?
title = 'Override the check for level to be the same or greater than my level - CAUTION: might cause slow fighting.';
id = 'fightLevelMaxOverride';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'style':'margin-left: 0.5em;', 'value':'checked'}, 'fightLevelMaxOverride');
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Override level check'));
//Fight Labels
tabContainerDivs(staminaTabSub);
makeElement('label', lhs).appendChild(document.createTextNode('Fight Label Criteria: '));
id = 'fightLabelCriteria';
var fightLabelCriteria = makeElement('select', rhs, {'id':id});
for (i = 0, iLength=fightLabels.length; i < iLength; ++i){
var choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(fightLabels[i][0]));
fightLabelCriteria.appendChild(choice);
}
fightLabelCriteria.selectedIndex = GM_getValue('fightLabelCriteria', 0);
// Opponent Maximum Health.
tabContainerDivs(staminaTabSub);
title = 'Avoid opponents with higher health than this setting - Set 0 for unlimited';
id = 'fightHealthMax';
label = makeElement('label', lhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Maximum Health / '));
makeElement('input', rhs, {'type':'text', 'id':id, 'title':title, 'maxlength':5, 'style':'width: 30px; border: 1px solid #781351;', 'value':GM_getValue('fightHealthMax', '0'), 'size':'1'});
title = 'Avoid opponents with higher health pct left than this setting - Set 0 for unlimited';
id = 'fightHealthPctMax';
label = makeElement('label', lhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Maximum Health Pct:'));
makeElement('input', rhs, {'type':'text', 'id':id, 'title':title, 'maxlength':5, 'style':'margin-left:5px;width: 30px; border: 1px solid #781351;', 'value':GM_getValue('fightHealthPctMax', '0'), 'size':'1'});
// Maximum Number of Attacks
tabContainerDivs(staminaTabSub);
title = 'Maximum number of Attacks per Opponenent - Set 0 for unlimited';
id = 'fightMaxAttacks';
label = makeElement('label', lhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Maximum # Attacks:'));
makeElement('input', rhs, {'type':'text', 'id':id, 'title':title, 'maxlength':3, 'style':'width: 30px; border: 1px solid #781351;', 'value':GM_getValue('fightMaxAttacks', '100'), 'size':'1'});
// Maximum mafia size.
tabContainerDivs(staminaTabSub);
id = 'fightMafiaMax';
title = 'Avoid opponents with mafia sizes larger than this.',
label = makeElement('label', lhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Maximum mafia:'));
makeElement('input', rhs, {'type':'text', 'id':id, 'title':title, 'style':'width: 30px; border: 1px solid #781351;', 'value':GM_getValue('fightMafiaMax', '501'), 'size':'1'});
// Maximum mafia relative?
title = 'Make the maximum mafia size be relative to your own. For example, if you have 300 mafia members, and maximum mafia is set to 50, opponents with more than 350 mafia members will be avoided.';
id = 'fightMafiaMaxRelative';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'style':'margin-left: 0.5em;', 'value':'checked'}, 'fightMafiaMaxRelative');
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Relative | Minimum Mafia: '));
// Minimum mafia size.
//tabContainerDivs(staminaTabSub);
id = 'fightMafiaMin';
title = 'Avoid opponents with mafia sizes smaller than this.',
label = makeElement('label', lhs, {'for':id, 'title':title});
makeElement('input', rhs, {'type':'text', 'id':id, 'title':title, 'style':'width: 30px; border: 1px solid #781351;', 'value':GM_getValue('fightMafiaMin', '1'), 'size':'1'});
// Minimum mafia relative?
title = 'Make the minimum mafia size be relative to your own. For example, if you have 300 mafia members, and minimum mafia is set to 50, opponents with less than 250 mafia members will be avoided.';
id = 'fightMafiaMinRelative';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'style':'margin-left: 0.5em;', 'value':'checked'}, 'fightMafiaMinRelative');
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Relative'));
tabContainerDivs(staminaTabSub);
// Mob fight
title = 'Fight higher levels if the mafia is smaller. You mob them, overwhelm the smaller numbers';
id = 'fightMobMode';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, 'fightMobMode');
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Mob Fight '));
// Fight Ice Stealers
title = 'Fight Ice Stealers';
id = 'fightIceStealers';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, 'fightIceStealers');
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Attack Ice Stealers '));
tabContainerDivs(staminaTabSub);
// Pattern Fighting ?
title = ' Use Mafia Family Patterns when fighting';
id = 'fightNames';
var UseFightNames = makeElement('input', lhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', lhs, {'for':id}).appendChild(document.createTextNode(' Use Patterns when fighting:'));
UseFightNames.addEventListener('click', clickUseFightNames, false);
makeElement('br', lhs);
id = 'fightAvoidNames';
title = ' Avoid mafia families';
makeElement('input', lhs, {'type':'radio', 'name':'rm3', 'id':id, 'value':'checked'}, id);
makeElement('label', lhs, {'for':id}).appendChild(document.createTextNode(title));
makeElement('br', lhs);
id = 'fightOnlyNames';
title = ' Only Fight Mafia Families ';
makeElement('input', lhs, {'type':'radio', 'name':'rm3', 'id':id, 'value':'checked'}, id);
makeElement('label', lhs, {'for':id}).appendChild(document.createTextNode(title));
makeElement('textarea', rhs, {'style':'position: static; width: 15em; height: 6em;', 'id':'fightClanName', 'title':'Enter each pattern (such as a clan name) on a separate line.'}).appendChild(document.createTextNode(GM_getValue('fightClanName', defaultClans.join('\n'))));
makeElement('br', rhs);
makeElement('font', rhs, {'style':'font-size: 10px;'}).appendChild(document.createTextNode('Enter each name pattern on a separate line.'));
}
/*
//STAMINA_HOW_LVJOBFIGHT
// Create Stamina Sub Tabs
function createStaminaSubTab_LVJobFight(staminaTabSub){
}
*/
function createStaminaSubTab_FightSpecific(staminaTabSub){
// Location setting
tabContainerDivs(staminaTabSub);
makeElement('label', lhs).appendChild(document.createTextNode('Fight in: '));
id = 'fightListLoc';
var fightListLoc = makeElement('select', lhs, {'id':id});
for (i = 0, iLength=fightLocations.length; i < iLength; ++i){
//if(i==1 || i==2){ continue; }
//else {
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(fightLocations[i]));
fightListLoc.appendChild(choice);
//}
}
fightListLoc.selectedIndex = GM_getValue('fightLocation', NY);
//rehit on money gain
title = 'Reattack until iced if money gained';
id = 'staminaReattackList';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'style':'margin-left: 0.5em;', 'value':'checked'}, id);
label = makeElement('label', rhs, {'for':id, 'title':title,'style':'margin-left: 0.5em;'});
label.appendChild(document.createTextNode('While gaining $ '));
//Money gain treshold
title = 'Reattack if this amount is gained';
id = 'reattackThresholdList';
makeElement('input', rhs, {'type':'text', 'id':id, 'title':title, 'maxlength':6, 'style':'width: 45px; border: 1px solid #781351;', 'value':GM_getValue(id, '10000'), 'size':'1'});
label = makeElement('label', rhs, {'for':id, 'title':title,'style':'margin-left: 0.5em;'});
// IceCheck
title = 'Attack ONLY live targets';
id = 'iceCheck';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'style':'margin-left: 0.5em;', 'value':'checked'}, 'iceCheck');
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Skip iced targets'));
// Powerattack
title = 'Power Attack';
id = 'staminaPowerattack';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'style':'margin-left: 0.5em;', 'value':'checked'}, id);
label = makeElement('label', rhs, {'for':id, 'title':title,'style':'margin-left: 0.5em;'});
label.appendChild(document.createTextNode('Powerattack'));
// Opponent list
tabContainerDivs(staminaTabSub);
lhs.appendChild(document.createTextNode('Fight these opponents:'));
makeElement('textarea', rhs, {'style':'position: static; width: 180px; height: 105px;', 'id':'pfightlist', 'title':'Enter each opponent\'s ID (not their name) on a separate line.'}).appendChild(document.createTextNode(GM_getValue('pfightlist', '')));
makeElement('br', rhs);
makeElement('font', rhs, {'style':'font-size: 10px;'}).appendChild(document.createTextNode('Enter each target on a separate line. Add the userid part of the p|userid.'));
tabContainerDivs(staminaTabSub);
//Load MW Id's from family Page
title = 'Clear Fight List';
id = 'fightListClear';
eltA = makeElement('a', rhs, {'id':id,'href':'#','alt':title,'title':title});
eltA.appendChild(document.createTextNode('Clear MW Id\'s'));
eltA.addEventListener('click', clearFight, false);
title = 'Load MW Id\'s from family Page';
id = 'fightListUpdate';
eltA = makeElement('a', rhs, {'id':id,'href':'#','alt':title,'title':title,'style':'margin-left:10px;'});
eltA.appendChild(document.createTextNode('Add MW Id\'s'));
eltA.addEventListener('click', addPageToFight, false);
// Remove stronger opponents?
tabContainerDivs(staminaTabSub);
removeStrongerOpponents(staminaTabSub);
}
function clearFight(){
var txtFightList = document.getElementById('pfightlist');
if(txtFightList){
txtFightList.value="";
txtFightList.innerHTML="";
}
}
function addPageToFight(){
var familyList="";
var userMWID;
var txtFightList = document.getElementById('pfightlist');
if(txtFightList){
var familyMembersContainer = xpathFirst('.//div[id="clan_main"]');
if(!familyMembersContainer) familyMembersContainer = document.getElementById('clan_main');
if(familyMembersContainer){
var familyMembers = $x('.//a[contains(@href,"user=")]', familyMembersContainer);
if(familyMembers && familyMembers.length>0){
alert('Adding '+familyMembers.length+' members');
for(i=0,iLength=familyMembers.length;i'));
item.appendChild(document.createTextNode('Please verify these specific settings before saving!'));
makeElement('br', item,{'style':'margin-bottom:1em;'});
}
// Create New Stamina Tab
function createStaminaTab(){
var i, elt, title, id, label, lhs, item, choice;
var staminaTab = makeElement('div', null, {'id':'staminaTab', 'class':'tabcontent'});
var TabHeader = makeElement('div', staminaTab, {'style':'width:762px;height:20px;border:none #FFFFFF;float:left;font-size: 18px; font-weight: bold;'});
TabHeader.appendChild(document.createTextNode('Stamina Settings:'));
// Container for a list of settings.
var list = makeElement('div', staminaTab, {'style':'position: relative; top: 5px; margin-left: auto; margin-right: auto; width: 95%; line-height:120%;'});
//
// How to spend stamina (fight/hitlist).
//
item = makeElement('div', list);
lhs = makeElement('div', item, {'class':'lhs'});
rhs = makeElement('div', item, {'class':'rhs'});
makeElement('br', item, {'class':'hide'});
title = 'Spend stamina automatically.';
id = 'staminaSpend';
makeElement('input', lhs, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, 'staminaSpend');
label = makeElement('label', lhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Spend stamina to:'));
id = 'staminaSpendHow';
var staminaSpendHow = makeElement('select', rhs, {'id':id});
for (i = 0, iLength=staminaSpendChoices.length; i < iLength; ++i){
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(staminaSpendChoices[i]));
staminaSpendHow.appendChild(choice);
}
title = 'Log Details';
id = 'staminaLogDetails';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'style':'margin-left: 0.5em;', 'value':'checked'}, 'staminaLogDetails');
label = makeElement('label', rhs, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Log Details'));
// Subtab for staminaSpendHow specific settings
var staminaTabSub = makeElement('div', list, {'id':'staminaTabSub', 'style':'position: static; border: 1px inset #FFD927; margin-left: auto; margin-right: auto; margin-top: 5px; margin-bottom: 5px;'});
// Spend stamina option
item = makeElement('div', list, {'class':'single'});
title = 'Start spending stamina when stamina level is reached';
id = 'selectStaminaUse';
item.appendChild(document.createTextNode('Start spending stamina when '));
makeElement('input', item, {'type':'text', 'id':id, 'title':title, 'style':'width: 2em; ', 'value':GM_getValue(id, '0')});
id = 'selectStaminaUseMode';
item.appendChild(document.createTextNode(' '));
elt = makeElement('select', item, {'id':id, 'title':title});
for (i = 0, iLength = numberSchemes.length; i < iLength; ++i){
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(numberSchemes[i]));
elt.appendChild(choice);
}
elt.selectedIndex = GM_getValue(id, 0);
item.appendChild(document.createTextNode(' of stamina has accumulated.'));
// Stamina to reserve for manual play
item = makeElement('div', list, {'class':'single'});
title = 'Suspend spending stamina for above choices while below this level.';
title += ' NOTE: Operations & Stamina LOWER limits are completely INDEPENDENT Of Each Other.';
id = 'selectStaminaKeep';
item.appendChild(document.createTextNode('While Stamina Is Below '));
makeElement('input', item, {'type':'text', 'id':id, 'title':title, 'style':'width: 2em; ', 'value':GM_getValue(id, '0')});
id = 'selectStaminaKeepMode';
item.appendChild(document.createTextNode(' '));
elt = makeElement('select', item, {'id':id, 'title':title});
for (i = 0, iLength = numberSchemes.length; i < iLength; ++i){
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(numberSchemes[i]));
elt.appendChild(choice);
}
elt.selectedIndex = GM_getValue(id, 0);
item.appendChild(document.createTextNode(' Suspend Stamina Spending For Jobs & Fighting.'));
// drop a line
// Stamina to reserve for manual play
item = makeElement('div', list, {'class':'single'});
title = 'Suspend automatic play and operations processing while below this level of stamina.';
title += ' NOTE: Operations & Stamina LOWER limits are completely INDEPENDENT Of Each Other.';
id = 'selectMissionStaminaKeep'; // selectStaminaKeep
item.appendChild(document.createTextNode('While Stamina Is Below '));
makeElement('input', item, {'type':'text', 'id':id, 'title':title, 'style':'width: 2em; ', 'value':GM_getValue(id, '0')});
id = 'selectMissionStaminaKeepMode'; // selectStaminaKeepMode
item.appendChild(document.createTextNode(' '));
elt = makeElement('select', item, {'id':id, 'title':title});
for (i = 0, iLength = numberSchemes.length; i < iLength; ++i){
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(numberSchemes[i]));
elt.appendChild(choice);
}
elt.selectedIndex = GM_getValue(id, 0);
item.appendChild(document.createTextNode(' Suspend Stamina Spending For Operations.'));
// Level up
item = makeElement('div', list, {'class':'single'});
title = 'Ignore minimum stamina settings if a level up is within reach.';
id = 'allowStaminaToLevelUp';
makeElement('input', item, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, 'allowStaminaToLevelUp');
label = makeElement('label', item, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' Don\'t reserve stamina if within reach of the next level.'));
// Handler for switching sub-areas.
var handleSpendChanged = function(){
staminaTabSub.innerHTML = '';
// Create the appropriate SubTab
var i = staminaSpendHow.selectedIndex;
switch(i){
case STAMINA_HOW_FIGHT_RANDOM :
createStaminaSubTab_FightRandom(staminaTabSub);
break;
case STAMINA_HOW_FIGHT_LIST :
createStaminaSubTab_FightSpecific(staminaTabSub);
break;
case STAMINA_HOW_HITMAN :
createStaminaSubTab_CollectBounties(staminaTabSub);
break;
case STAMINA_HOW_ROBBING :
createStaminaSubTab_Rob(staminaTabSub);
break;
case STAMINA_HOW_AUTOHITLIST :
createStaminaSubTab_SetBounties(staminaTabSub);
break;
case STAMINA_HOW_RANDOM :
createStaminaSubTab_Random(staminaTabSub);
break;
case STAMINA_HOW_FIGHTROB :
createStaminaSubTab_FightRob(staminaTabSub);
break;
//newchange_fight
// case STAMINA_HOW_LVJOBFIGHT :
// createStaminaSubTab_LVJobFight(staminaTabSub);
// break;
case STAMINA_HOW_ROBFIGHT :// New Stamina Mode
createStaminaSubTab_RobFight(staminaTabSub);
break;
default :
createStaminaSubTab_Random(staminaTabSub);
break;
}
}
staminaSpendHow.selectedIndex = GM_getValue('staminaSpendHow', 0);
handleSpendChanged();
staminaSpendHow.addEventListener('change', handleSpendChanged, false);
return staminaTab;
}
// Create Heal Tab
function createHealTab(){
var elt, title, id, label, item, lhs, rhs, i, choice;
var healTab = makeElement('div', null, {'id':'healTab', 'class':'tabcontent'});
var TabHeader = makeElement('div', healTab, {'style':'width:762px;height:20px;border:none #FFFFFF;float:left;font-size: 18px; font-weight: bold;'});
TabHeader.appendChild(document.createTextNode('Health Settings:'));
// Container for a list of settings.
var list = makeElement('div', healTab, {'style':'position: relative; top: 10px; margin-left: 0px; margin-right: auto; width: 95%; line-height:120%;'});
// Healing options
item = makeElement('div', list);
lhs = makeElement('div', item, {'class':'lhs'});
rhs = makeElement('div', item, {'class':'rhs'});
makeElement('br', item, {'class':'hide'});
title = 'Heal when health lands below indicated health.';
id = 'autoHeal';
makeElement('input', lhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id, 'checked');
makeElement('img', lhs, {'style':'padding-left: 5px;','src':stripURI(healthIcon)});
makeElement('label', lhs, {'for':id, 'title':title}).appendChild(document.createTextNode(' Heal in:'));
id = 'healLocation';
var healLocation = makeElement('select', rhs, {'id':id});
for (i = 0, iLength=locations.length; i < iLength; ++i){
choice = document.createElement('option');
choice.value = i;
choice.appendChild(document.createTextNode(locations[i]));
healLocation.appendChild(choice);
}
healLocation.selectedIndex = GM_getValue('healLocation', NY);
makeElement('label', rhs, {'title':title}).appendChild(document.createTextNode(' when health falls below '));
makeElement('input', rhs, {'style':'text-align: center','type':'text', 'value':GM_getValue('healthLevel', '50'), 'id':'healthLevel', 'size':'1'});
makeElement('label', rhs, {'title':title}).appendChild(document.createTextNode(' points'));
item = makeElement('div', list);
lhs = makeElement('div', item, {'class':'lhs'});
rhs = makeElement('div', item, {'class':'rhs'});
makeElement('br', item, {'class':'hide'});
title = 'Set NY as backup for healing';
id = 'autoHealBackup';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id, 'checked');
makeElement('label', rhs, {'for':id, 'title':title}).appendChild(document.createTextNode(' Use NY as backup for healing'));
// stamina minimum to allow healing
item = makeElement('div', list);
lhs = makeElement('div', item, {'class':'lhs'});
rhs = makeElement('div', item, {'class':'rhs'});
makeElement('br', item, {'class':'hide'});
title = 'Set the minimum Stamina Points Needed for Auto-Heal.';
label = makeElement('label', rhs, {'title':title});
label.appendChild(document.createTextNode('Disable Auto-Heal when Stamina falls below '));
makeElement('input', rhs, {'type':'text', 'value':GM_getValue('stamina_min_heal', '22'), 'id':'stamina_min_heal', 'size':'3'});
rhs.appendChild(document.createTextNode(' points.'));
makeElement('br', rhs, {'class':'hide'});
makeElement('font', rhs, {'style':'font-size: 10px;color:yellow;'}).appendChild(document.createTextNode('This setting determins switching from fighting to robbing when \'Fight then Rob\' is chosen from the Stamina subTab.'));
// Attack at critical health
item = makeElement('div', list);
lhs = makeElement('div', item, {'class':'lhs'});
rhs = makeElement('div', item, {'class':'rhs'});
makeElement('br', item, {'class':'hide'});
title = 'Check to attack even when at critical health (21-28 health points) ';
id = 'attackCritical';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'title':title, 'value':'checked'}, id);
makeElement('img', rhs, {'style':'padding-left: 5px;','src':stripURI(attackIcon)});
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' Attack at critical health'));
// Hide in hospital
item = makeElement('div', list);
lhs = makeElement('div', item, {'class':'lhs'});
rhs = makeElement('div', item, {'class':'rhs'});
makeElement('br', item, {'class':'hide'});
title = 'Hide in hospital ';
id = 'hideInHospital';
var hideInHosp = makeElement('input', rhs, {'type':'checkbox', 'title':title, 'id':id, 'value':'checked'}, id);
makeElement('img', rhs, {'style':'padding-left: 5px;','src':stripURI(hideIcon)});
title = hideInHosp.checked ? ' Hide in hospital but...' : ' Hide in hospital';
makeElement('label', rhs, {'id':'hideLabel', 'for':id, 'title':title}).appendChild(document.createTextNode(title));
elt = makeElement('div', rhs, {'style':'line-height: 135%;','id':'hideOpts'});
for (i = 0, iLength=healOptions.length; i < iLength; i++){
id = healOptions[i][0];
title = healOptions[i][1];
var info = healOptions[i][2];
var optElt = makeElement('div', elt);
makeElement('input', optElt, {'type':'checkbox', 'id':id, 'title':info, 'value':'checked', 'style':'margin-left: 15px;'}, id);
label = makeElement('label', optElt, {'for':id, 'title':info});
label.appendChild(document.createTextNode(' '+ title));
}
elt.style.display = hideInHosp.checked ? '' : 'none';
var hideHandler = function(){
var hideOpts = document.getElementById('hideOpts');
var hideLabel = document.getElementById('hideLabel');
if(!hideOpts) return false;
if(this.checked){
hideOpts.style.display = '';
hideLabel.firstChild.nodeValue = ' Hide in hospital but...';
} else {
hideOpts.style.display = 'none';
hideLabel.firstChild.nodeValue = ' Hide in hospital';
}
return true;
};
hideInHosp.addEventListener('click', hideHandler, false);
// Health reserve
item = makeElement('div', list);
lhs = makeElement('div', item, {'class':'lhs'});
rhs = makeElement('div', item, {'class':'rhs'});
makeElement('br', item, {'class':'hide'});
id = 'stopPA';
title = 'do not use Powerattack when health is below treshold';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' Do not use Power Attack when health falls below '));
id = 'stopPAHealth';
title = 'Enter min health level';
makeElement('input', rhs, {'type':'text', 'value':GM_getValue(id, '0'), 'title':title, 'id':id, 'style':'width: 25px'});
// Hitlist riding
item = makeElement('div', list);
lhs = makeElement('div', item, {'class':'lhs'});
rhs = makeElement('div', item, {'class':'rhs'});
makeElement('br', item, {'class':'hide'});
id = 'hideAttacks';
title = 'Enable hitlist riding: PS MWAP disables autoHeal after you got XP from attacks; it enables it again after parsing a snuffed message.';
makeElement('input', rhs, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', rhs, {'for':id,'title':title}).appendChild(document.createTextNode(' Hitlist riding, turn off autoHeal after '));
id = 'rideHitlistXP';
title = 'Enter the XP you want to gain before PS MWAP turns off autoHeal. Enter \'0\' if you want PS MWAP to turn off autoHeal after it detected a 0 xp attack.';
makeElement('input', rhs, {'type':'text', 'value':GM_getValue(id, '0'), 'title':title, 'id':id, 'style':'width: 25px'});
rhs.appendChild(document.createTextNode(' xp'));
return healTab;
}
// Create Cash tab
function createCashTab (){
var elt, title, id, label;
var cashTab = makeElement('div', null, {'id':'cashTab', 'class':'tabcontent','style':'height:460px;overflow-y:auto;overflow-x:hidden'});
var TabHeader = makeElement('div', cashTab, {'style':'width:762px;height:20px;border:none #FFFFFF;float:left;font-size: 18px; font-weight: bold;'});
TabHeader.appendChild(document.createTextNode('Cash / Properties Settings:'));
var xTop = 0;
for(ctCount=0;ctCount < ctLength;ctCount++){
xTop += 23;
// Option Label and Check Box
title = cityProperties[ctCount][ctTitle];
id = cityProperties[ctCount][ctGMId];
var baseElt = makeElement('div', cashTab, {'style':'top: '+xTop+'px;'});
makeElement('input', baseElt, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', baseElt, {'for':id, 'title':title});
label.appendChild(document.createTextNode(cityProperties[ctCount][ctText]));
// Option Items
id = cityProperties[ctCount][ctGMId]+'Id';
var elt = makeElement('select', baseElt, {'id':id, 'style':'position: static; margin-left: 5px;'});
for (i = 0, iLength=cityProperties[ctCount][ctArray].length; i < iLength; ++i){
var choice = makeElement('option', null, {'value':i,'title':cityProperties[ctCount][ctArray][i][2]});
choice.appendChild(document.createTextNode(cityProperties[ctCount][ctArray][i][0]));
elt.appendChild(choice);
}
elt.selectedIndex = GM_getValue(id, 8);
elt.setAttribute('title', cityProperties[ctCount][ctArray][elt.selectedIndex][2]);
}
xTop += 33;
makeElement('div', cashTab, {'style':'font-size: 10px;top: '+xTop+'px;'}).appendChild(document.createTextNode('These may result in some delay, when the request is not ready for processing.'));
// Ask for Special Parts
xTop += 15;
/*
title = 'Check this to Ask for Special Parts every 12 hours';
id = 'askSpecialParts';
var specialParts = makeElement('div', cashTab, {'style':'top: '+xTop+'px;'});
makeElement('input', specialParts, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', specialParts, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Ask for Special Parts '));
*/
title = 'Check this to Ask for Event Parts Parts every 4 hours';
id = 'askEventParts';
var eventParts = makeElement('div', cashTab, {'style':'top: '+xTop+'px;left:150px;'});
makeElement('input', eventParts, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', eventParts, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Ask for Event Parts'));
for(ctCount=0,cpLength=cityParts.length;ctCount < cpLength;ctCount++){
xTop += 23;
// Option Label and Check Box
title = cityParts[ctCount][ptTitle];
id = cityParts[ctCount][ptGMId];
var baseElt = makeElement('div', cashTab, {'style':'top: '+xTop+'px;'});
makeElement('input', baseElt, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', baseElt, {'for':id, 'title':title});
label.appendChild(document.createTextNode(cityParts[ctCount][ptProp]));
//label.appendChild(document.createTextNode('Ask for '+cityParts[ctCount][ptProp])+' parts');
if(cityParts[ctCount][ptPropId]){
// Option Items (if available)
id = cityParts[ctCount][ptGMId]+'Id';
var elt = makeElement('select', baseElt, {'id':id, 'style':'position: static; margin-left: 5px;'});
for (i = 0, iLength=cityParts[ctCount][ptArray].length; i < iLength; ++i){
var choice = makeElement('option', null, {'value':i,'title':cityParts[ctCount][ptArray][i][0]});
choice.appendChild(document.createTextNode(cityParts[ctCount][ptArray][i][0]));
elt.appendChild(choice);
}
elt.selectedIndex = GM_getValue(id, 0);
}
}
/*
// Ask for Chop Shop Parts
xTop += 23;
title = 'Check this to Ask for Chop Shop Parts every 12 hours';
id = 'askShopParts';
var shopParts = makeElement('div', cashTab, {'style':'top: '+xTop+'px;'});
makeElement('input', shopParts, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', shopParts, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Ask for Chop Shop Parts'));
// List Chop Shop Parts
id = 'askShopPartsId';
var shopPartsType = makeElement('select', shopParts, {'id':id, 'style':'position: static; margin-left: 5px;'});
for (i = 0, iLength=cityShopParts.length; i < iLength; ++i){
var choice = makeElement('option', null, {'value':i,'title':cityShopParts[i][0]});
choice.appendChild(document.createTextNode(cityShopParts[i][0]));
shopPartsType.appendChild(choice);
}
shopPartsType.selectedIndex = GM_getValue(id, 0);
// Ask for Weapon Depots Parts
xTop += 23;
title = 'Check this to Ask for Weapon Depots Parts every 12 hours';
id = 'askDepotParts';
var depotParts = makeElement('div', cashTab, {'style':'top: '+xTop+'px;'});
makeElement('input', depotParts, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', depotParts, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Ask for Weapon Depots Parts'));
// List Weapon Depots Parts
id = 'askDepotPartsId';
var depotPartsType = makeElement('select', depotParts, {'id':id, 'style':'position: static; margin-left: 5px;'});
for (i = 0, iLength=cityDepotParts.length; i < iLength; ++i){
var choice = makeElement('option', null, {'value':i,'title':cityDepotParts[i][0]});
choice.appendChild(document.createTextNode(cityDepotParts[i][0]));
depotPartsType.appendChild(choice);
}
depotPartsType.selectedIndex = GM_getValue(id, 0);
// Ask for Armor Parts
xTop += 23;
title = 'Check this to Ask for Armor Parts every 12 hours';
id = 'askArmorParts';
var armorParts = makeElement('div', cashTab, {'style':'top: '+xTop+'px;'});
makeElement('input', armorParts, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', armorParts, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Ask for Armor Parts'));
// List Armor Parts
id = 'askArmorPartsId';
var armorPartsType = makeElement('select', armorParts, {'id':id, 'style':'position: static; margin-left: 5px;'});
for (i = 0, iLength=cityArmorParts.length; i < iLength; ++i){
var choice = makeElement('option', null, {'value':i,'title':cityArmorParts[i][0]});
choice.appendChild(document.createTextNode(cityArmorParts[i][0]));
armorPartsType.appendChild(choice);
}
armorPartsType.selectedIndex = GM_getValue(id, 0);
// Ask for Zoo Parts
xTop += 23;
title = 'Check this to Ask for Zoo Parts every 12 hours';
id = 'askZooParts';
var zooParts = makeElement('div', cashTab, {'style':'top: '+xTop+'px;'});
makeElement('input', zooParts, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', zooParts, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Ask for Zoo Parts'));
// List Zoo Parts
id = 'askZooPartsId';
var zooPartsType = makeElement('select', zooParts, {'id':id, 'style':'position: static; margin-left: 5px;'});
for (i = 0, iLength=cityZooParts.length; i < iLength; ++i){
var choice = makeElement('option', null, {'value':i,'title':cityZooParts[i][0]});
choice.appendChild(document.createTextNode(cityZooParts[i][0]));
zooPartsType.appendChild(choice);
}
zooPartsType.selectedIndex = GM_getValue(id, 0);
*/
// Ask for New Parts
xTop += 23;
title = 'Check this to Ask for New Parts every 8 hours';
id = 'askNewParts';
var newParts = makeElement('div', cashTab, {'style':'top: '+xTop+'px;'});
makeElement('input', newParts, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', newParts, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Ask for New Parts'));
// List New Parts
id = 'askNewPartsId';
var newPartsType = makeElement('select', newParts, {'id':id, 'style':'position: static; margin-left: 5px;'});
for (i = 0, iLength=cityNewParts.length; i < iLength; ++i){
var choice = makeElement('option', null, {'value':i,'title':cityNewParts[i][0]});
choice.appendChild(document.createTextNode(cityNewParts[i][0]));
newPartsType.appendChild(choice);
}
newPartsType.selectedIndex = GM_getValue(id, 0);
// Ask for Casino Parts
xTop += 23;
title = 'Check this to Ask for Casino Parts every 2 hours, since no MW timer available';
id = 'askCasinoParts';
var casinoParts = makeElement('div', cashTab, {'style':'top: '+xTop+'px;'});
makeElement('input', casinoParts, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', casinoParts, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Ask for Casino Parts'));
// List Casino Parts
id = 'askCasinoPartsId';
var casinoPartsType = makeElement('select', casinoParts, {'id':id, 'style':'position: static; margin-left: 5px;'});
for (i = 0, iLength=cityCasinoParts.length; i < iLength; ++i){
var choice = makeElement('option', null, {'value':i,'title':cityCasinoParts[i][0]});
choice.appendChild(document.createTextNode(cityCasinoParts[i][0]));
casinoPartsType.appendChild(choice);
}
casinoPartsType.selectedIndex = GM_getValue(id, 0);
// Ask Friends to Play your Slots
xTop += 23;
title = 'Check this to Ask Friends to Play your Slots every 4 hours';
id = 'askPlaySlots';
var playSlots = makeElement('div', cashTab, {'style':'top: '+xTop+'px;'});
makeElement('input', playSlots, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', playSlots, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Ask to Play your Slots'));
// Ask for Village Parts
xTop += 23;
title = 'Check this to Ask for Village Parts every 2 hours, since no MW timer available';
id = 'askVillageParts';
var villageParts = makeElement('div', cashTab, {'style':'top: '+xTop+'px;'});
makeElement('input', villageParts, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', villageParts, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Ask for Village Parts'));
// List Village Parts
id = 'askVillagePartsId';
var villagePartsType = makeElement('select', villageParts, {'id':id, 'style':'position: static; margin-left: 5px;'});
for (i = 0, iLength=cityVillageParts.length; i < iLength; ++i){
var choice = makeElement('option', null, {'value':i,'title':cityVillageParts[i][0]});
choice.appendChild(document.createTextNode(cityVillageParts[i][0]));
villagePartsType.appendChild(choice);
}
villagePartsType.selectedIndex = GM_getValue(id, 0);
// Ask for Football Fans
xTop += 23;
title = 'Check this to Ask for Football Fans';
id = 'askFootballFans';
var footballFans = makeElement('div', cashTab, {'style':'top: '+xTop+'px;'});
makeElement('input', footballFans, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', footballFans, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Ask for Football Fans'));
// Ask for Brazil Parts
xTop += 23;
title = 'Check this to Ask for Brazil Parts every 2 hours, since no MW timer available';
id = 'askBrazilParts';
var brazilParts = makeElement('div', cashTab, {'style':'top: '+xTop+'px;'});
makeElement('input', brazilParts, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', brazilParts, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Ask for Brazil Parts'));
// List Brazil Parts
id = 'askBrazilPartsId';
var brazilPartsType = makeElement('select', brazilParts, {'id':id, 'style':'position: static; margin-left: 5px;'});
for (i = 0, iLength=cityBrazilParts.length; i < iLength; ++i){
var choice = makeElement('option', null, {'value':i,'title':cityBrazilParts[i][0]});
choice.appendChild(document.createTextNode(cityBrazilParts[i][0]));
brazilPartsType.appendChild(choice);
}
brazilPartsType.selectedIndex = GM_getValue(id, 0);
// Ask for Chicago Parts
xTop += 23;
title = 'Check this to Ask for chicago Parts every 2 hours, since no MW timer available';
id = 'askChicagoParts';
var chicagoParts = makeElement('div', cashTab, {'style':'top: '+xTop+'px;'});
makeElement('input', chicagoParts, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', chicagoParts, {'for':id, 'title':title});
label.appendChild(document.createTextNode('Ask for Chicago Parts'));
// List Chicago Parts
id = 'askChicagoPartsId';
var chicagoPartsType = makeElement('select', chicagoParts, {'id':id, 'style':'position: static; margin-left: 5px;'});
for (i = 0, iLength=cityChicagoParts.length; i < iLength; ++i){
var choice = makeElement('option', null, {'value':i,'title':cityChicagoParts[i][0]});
choice.appendChild(document.createTextNode(cityChicagoParts[i][0]));
chicagoPartsType.appendChild(choice);
}
chicagoPartsType.selectedIndex = GM_getValue(id, 0);
// Collect Cash Takes
xTop = 23;
title = 'Automatically collect from properties';
id = 'collectTake'+ cities[0][CITY_NAME];
var autoTake = makeElement('div', cashTab, {'style':'top: '+xTop+'px; left: 425px;'});
makeElement('input', autoTake, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', autoTake, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' autoCollect Cash from Properties'));
//Collect BRAZIL
xTop += 23;
title = 'Automatically collect in BRAZIL';
id = 'collectTakeBrazil';
var autoBRAZIL = makeElement('div', cashTab, {'style':'top: '+xTop+'px; left: 425px;'});
makeElement('input', autoBRAZIL, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', autoBRAZIL, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' autoCollect in BRAZIL'));
//Collect BRAZIL
xTop += 23;
title = 'Automatically collect in CHICAGO';
id = 'collectTakeChicago';
var autoCHICAGO = makeElement('div', cashTab, {'style':'top: '+xTop+'px; left: 425px;'});
makeElement('input', autoCHICAGO, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', autoCHICAGO, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' autoCollect in CHICAGO'));
//Collect Parts
xTop += 23;
title = 'Automatically collect Parts from properties';
id = 'collectParts';
var autoParts = makeElement('div', cashTab, {'style':'top: '+xTop+'px; left: 425px;'});
makeElement('input', autoParts, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
label = makeElement('label', autoParts, {'for':id, 'title':title});
label.appendChild(document.createTextNode(' autoCollect Parts from Properties'));
// Autobanking
xTop += 69;
for (var i = 0, iLength = cities.length; i < iLength; ++i){
if(i < 1 || i > 3){
id = cities[i][CITY_AUTOBANK];
title = 'Enable '+ cities[i][CITY_NAME]+' banking';
var curBank = makeElement('div', cashTab, {'style':'top: '+xTop+'px; left: 425px; width: 280px; text-align: left;'});
makeElement('input', curBank, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', curBank, {'for':id}).appendChild(document.createTextNode(title));
makeElement('img', curBank, {'style':'position: absolute; right: 95px; margin-top: 3px;', 'src':stripURI(cities[i][CITY_CASH_ICON])});
id = cities[i][CITY_BANKCONFG];
title = 'Minimum deposit amount in '+ cities[i][CITY_NAME];
makeElement('input', curBank, {'type':'text', 'style':'position: absolute; right: 0px; width: 110px; text-align: right;', 'title':title, 'value':GM_getValue(id, '50000'), 'id':id, 'size':'5'});
xTop += 23;
if(i==4) xTop += 23;
} else {
continue;
}
}
xTop -= 92;
// Las Vegas: current vault level
var vaultLevel = makeElement('div', cashTab, {'style':'top: '+xTop+'px; left: 475px;'});
title = 'Las Vegas: disable automatic vault handling, or select the level of your vault and let PS MWAP handle it.';
id = 'vaultHandling';
makeElement('img', vaultLevel, {'src':stripURI(cashVegasIcon), 'style':'margin-right: 5px;'});
var vaultSelect = makeElement('select', vaultLevel, {'id':id, 'title':title, 'style':'position: static; text-align: left;'});
for (i = 0, iLength=vaultLevels.length; i < iLength; ++i){
var choice = makeElement('option', null, {'value':i});
choice.appendChild(document.createTextNode(vaultLevels[i][0]));
vaultSelect.appendChild(choice);
}
vaultSelect.selectedIndex = GM_getValue(id, 0);
xTop += 100;
makeElement('div', cashTab, {'style':'top: '+xTop+'px;left: 425px; width: 150px; text-align: left;'}).appendChild(document.createTextNode('autoUpgrade New York Properties:'));
xTop += 20;
var buildingListContainer = makeElement('div', cashTab, {'style':'top: '+xTop+'px;left: 580px; width: 150px; text-align: left;'});
var buildingList = makeElement('ul', buildingListContainer, {'style':'border: 1px solid rgb(204, 204, 204); width: 150px; height: 90px; list-style: none outside none; overflow: auto;'});
for(i=0,iLength = autoUpgradeNYBuildings.length;i' +
'Previous changes:
'+ GM_getValue('oldRevList');
item.innerHTML = 'Revision history pulled out for the mean time...
Google\'s project hosting servers are being overwhelmed by this feature :D
PS MWAP Team';
// Test New Changes
var devTools = makeElement('div', aboutTab, {'style': 'top: 350px; left: 10px; font-size: 12px;'});
id = 'TestChanges';
title = 'Enable Script Modifications In Testing Phase';
makeElement('input', devTools, {'type':'checkbox', 'id':id, 'value':'checked'}, id);
makeElement('label', devTools, {'for':id,'title':title}).appendChild(document.createTextNode('BETA TESTING ONLY : VERBOSITY ALERT - USE AT OWN RISK !'));
//var sideName = GM_getValue('aboutChange');
//var mockTest = makeElement('div', aboutTab, {'id':'mockTest','style': 'top: 400px; width: 550px; left: 10px; font-size: 12px; font-weight: bold;'});
//mockTest.appendChild(document.createTextNode('Mock War Registration - You were registered on team: '+sideName));
return aboutTab;
}
function grabToolbarInfo(manually){
// Function for creating the cookies necessary to use miniPacks without installing the Zynga toolbar:
var createToolbarCookies = function(){
var openSinglePopup = function(strUrl){ window.open(strUrl,"toolbar","resizable=yes,scrollbars=yes,status=yes"); }
window.setTimeout(function(){openSinglePopup('http://toolbar.zynga.com/game_iframe_proxy.php?playing=true');},1000);
window.setTimeout(function(){openSinglePopup('http://toolbar.zynga.com/game_iframe_proxy.php');},5000);
}
// In case the current browser lacks greasemonkey (chrome):
if(!gvar.isGreaseMonkey){
if(manually && window.confirm('Can\'t retrieve Toolbar info with this browser.\n\n' +
'In case the miniPack doesn\'t work here at all,\nyou could let MWAP create the necessary cookies for you.\nPS: For this to work, ' +
'you need to allow popups in your browser, and wait for ca. 10 secs before closing the popup (after confirming this dialog).')){
createToolbarCookies();
}
return;
}
GM_xmlhttpRequest({
method: 'GET',
url: 'http://toolbar.zynga.com/game_stats_proxy.php?src=mw',
headers: {'Accept': 'application/atom+xml'},
onload: function (resp){
if(resp.status != 200) return;
var toolbarInfo = JSON.parse(resp.responseText);
DEBUG('Toolbar response: '+ resp.responseText);
if(!toolbarInfo || toolbarInfo.error){
if(window.confirm('Error retrieving Toolbar info, probably because it\s the first time you are trying to fire the miniPack in this browser/-profile.\n\n' +
'Do you want MWAP to create the necessary cookies for you? If not, you have to install the Zynga Toolbar.\nPS: For this to work, ' +
'you need to allow popups in your browser, and wait for ca. 10 secs before closing the popup (after confirming this dialog).')){
createToolbarCookies();
}
// abort any time changes
return;
}
// Info in info. user_health, user_energy, user_stamina, energy_timestamp, toolbar_energy_timestamp
// has_toolbar_enery_pack, has_energypack, error
var datNow = new Date();
var modGMT = 8; // Default PDT
datNow.setMilliseconds(0);
var timer = toolbarInfo.toolbar_energy_timestamp - (datNow.getTime()/1000) + 3600 * modGMT;
setGMTime('miniPackTimer', timer+' seconds');
return;
}
});
}
function grabUpdateInfo(){
if(!gvar.isGreaseMonkey) return;
GM_setValue('newRevList', '');
GM_setValue('oldRevList', '');
return;
}
////////////////////////////////////////////////////////////////////
function validateStaminaTab(){
var elt, id;
var checked = function(id){ return document.getElementById(id).checked === true ? 'checked' : 0; }
// Create an empty object to hold the settings.
var s = {};
// Get the common settings.
s.staminaSpend = checked('staminaSpend');
s.staminaSpendHow = document.getElementById('staminaSpendHow').selectedIndex;
s.staminaLogDetails = checked('staminaLogDetails');
var selectStaminaUse = parseInt(document.getElementById('selectStaminaUse').value);
if(isNaN(selectStaminaUse)) selectStaminaUse = 0;
s.selectStaminaUse = selectStaminaUse;
s.selectStaminaUseMode = document.getElementById('selectStaminaUseMode').selectedIndex;
var selectStaminaKeep = parseInt(document.getElementById('selectStaminaKeep').value);
if(isNaN(selectStaminaKeep)) selectStaminaKeep = 0;
s.selectStaminaKeep = selectStaminaKeep;
s.selectStaminaKeepMode = document.getElementById('selectStaminaKeepMode').selectedIndex;
var selectMissionStaminaKeep = parseInt(document.getElementById('selectMissionStaminaKeep').value);
if(isNaN(selectMissionStaminaKeep)) selectMissionStaminaKeep = 0;
s.selectMissionStaminaKeep = selectMissionStaminaKeep;
s.selectMissionStaminaKeepMode = document.getElementById('selectMissionStaminaKeepMode').selectedIndex;
s.allowStaminaToLevelUp = checked('allowStaminaToLevelUp');
// selectStaminaKeep selectMissionStaminaKeep selectStaminaKeepMode selectMissionStaminaKeepMode
// Validate common settings
if(isNaN(s.selectStaminaUse) || isNaN(s.selectStaminaKeep) || isNaN(s.selectMissionStaminaKeep) ){
alert('Please enter numeric values for Stamina reserve and Stamina threshold.');
return false;
}
// The method of getting and verifying the rest of the settings depends
// on how stamina will be spent.
switch (s.staminaSpendHow){
case STAMINA_HOW_ROBFIGHT: // Rob then Fight
s.robFightStaminaFloor = parseInt(document.getElementById('robFightStaminaFloor').value);
// Validate RobFight Stamina Spending Floor settings.
if(isNaN(s.robFightStaminaFloor)){
alert('Please enter the threshold for switching from robbing to fighting.');
return false;
} else if(s.robFightStaminaFloor < 25 || s.robFightStaminaFloor > maxStamina){
alert('Please enter a stamina between 25 and '+ maxStamina);
return false;
}
case STAMINA_HOW_FIGHTROB: // Fight then Rob
// Get the settings.
s.robLocation = document.getElementById('robLocation').selectedIndex;
s.fastRob = checked('fastRob');
s.fastRobSpeed = document.getElementById('fastRobSpeed').selectedIndex;
s.useRobSquads = checked('useRobSquads');
s.useBurners = checked('useBurners');
case STAMINA_HOW_FIGHT_RANDOM: // Random fighting
// Get the specific settings.
s.fightLocation = document.getElementById('fightRandomLoc').selectedIndex;
s.reattackThreshold = parseInt(document.getElementById('reattackThreshold').value);
s.staminaReattack = checked('staminaReattack');
s.iceCheck = checked('iceCheck');
s.staminaPowerattack = checked('staminaPowerattack');
s.fightLevelMax = parseInt(document.getElementById('fightLevelMax').value);
s.fightLevelMaxRelative = checked('fightLevelMaxRelative');
s.fightLevelMaxOverride = checked('fightLevelMaxOverride');
s.fightMafiaMax = parseInt(document.getElementById('fightMafiaMax').value);
s.fightMafiaMaxRelative = checked('fightMafiaMaxRelative');
s.fightMafiaMin = parseInt(document.getElementById('fightMafiaMin').value);
s.fightMafiaMinRelative = checked('fightMafiaMinRelative');
s.fightHealthMax = parseInt(document.getElementById('fightHealthMax').value);
s.fightHealthPctMax = parseInt(document.getElementById('fightHealthPctMax').value);
s.fightMobMode = checked('fightMobMode');
s.fightIceStealers = checked('fightIceStealers');
s.fightNames = checked('fightNames');
s.fightAvoidNames = checked('fightAvoidNames');
s.fightOnlyNames = checked('fightOnlyNames');
s.fightClanName = document.getElementById('fightClanName').value;
s.fightRemoveStronger = checked('fightRemoveStronger');
if(document.getElementById('fightRivalsMode')) s.fightRivalsMode = document.getElementById('fightRivalsMode').selectedIndex;
s.fightMaxAttacks = parseInt(document.getElementById('fightMaxAttacks').value);
if(document.getElementById('fightLabelCriteria')) s.fightLabelCriteria = document.getElementById('fightLabelCriteria').selectedIndex;
// Validate maxAttacks settings.
if(isNaN(s.fightMaxAttacks)){
alert('Please enter the threshold for maximum # attacks per opponent.');
return false;
} else if(s.fightMaxAttacks < 0){
alert('Please enter a maximum # attacks per opponent threshold of zero or more.');
return false;
}
// Validate reattack settings.
if(isNaN(s.reattackThreshold)){
alert('Please enter the threshold for reattacking opponents.');
return false;
} else if(s.reattackThreshold < 0){
alert('Please enter a reattack threshold of zero or more.');
return false;
}
// Validate the maximum level settings.
if(isNaN(s.fightLevelMax)){
alert('Please enter a maximum level for fighting.');
return false;
} else if(s.fightLevelMaxRelative && s.fightLevelMax < 0){
alert('Please enter a maximum relative level of zero or more.');
return false;
} else if(!s.fightLevelMaxRelative && s.fightLevelMax < level && !s.fightLevelMaxOverride){
addToLog('warning Icon', 'Maximum level for fighting is set to '+ s.fightLevelMax+'. Setting to current level of '+ level+'.');
s.fightLevelMax = level;
}
// Validate the maximum health settings.
if(isNaN(s.fightHealthMax)){
alert('Please enter a maximum oppononent health for fighting.');
return false;
} else if(s.fightHealthMax < 0){
alert('Please enter a maximum oppononent health for fighting of zero or more.');
return false;
}
if(isNaN(s.fightHealthPctMax)){
alert('Please enter a maximum oppononent health for fighting.');
return false;
} else if(s.fightHealthPctMax < 0){
alert('Please enter a maximum oppononent health for fighting of zero or more.');
return false;
}
// Validate the maximum mafia size settings.
if(isNaN(s.fightMafiaMax)){
alert('Please enter a maximum mafia size for fighting.');
return false;
} else if(!s.fightMafiaMaxRelative && (s.fightMafiaMax < 1)){
alert('Please enter a maximum mafia size of one or more for fighting.');
return false;
} else if(s.fightMafiaMaxRelative && (s.fightMafiaMax + mafia < 1)){
alert('Please enter a larger relative mafia size for fighting.');
return false;
}
// Validate the minimum mafia size settings.
if(isNaN(s.fightMafiaMin)){
alert('Please enter a minimum mafia size for fighting.');
return false;
} else if(!s.fightMafiaMinRelative && (s.fightMafiaMin < 1)){
alert('Please enter a minimum mafia size of one or more for fighting.');
return false;
} else if(s.fightMafiaMinRelative && (mafia - s.fightMafiaMin < 1)){
alert('Please enter a smaller relative mafia size for fighting.');
return false;
}
if(s.fightNames == 'checked'){
// Validate the fight list.
var list = s.fightClanName.split('\n');
if(!list[0]){
alert('Enter at least one clan name/symbol in the list');
return false;
}
}
break;
case STAMINA_HOW_FIGHT_LIST: // List fighting
// Get the settings.
s.fightLocation = document.getElementById('fightListLoc').selectedIndex;
s.reattackThresholdList = parseInt(document.getElementById('reattackThresholdList').value);
s.staminaReattackList = checked('staminaReattackList');
s.iceCheck = checked('iceCheck');
s.staminaPowerattack = checked('staminaPowerattack');
s.pfightlist = document.getElementById('pfightlist').value;
s.fightRemoveStronger = document.getElementById('fightRemoveStronger').checked === true? 'checked' : 0;
// Validate reattack settings.
if(isNaN(s.reattackThresholdList)) alert('Please enter the threshold for reattacking opponents.');
else if(s.reattackThresholdList < 0) alert('Please enter a reattack threshold of zero or more.');
// Validate the fight list.
var list = s.pfightlist.split('\n');
if(!list[0]){
alert('Enter the Facebook ID of at least one opponent to fight.');
return false;
}
break;
case STAMINA_HOW_HITMAN: // Hitlist bounty collection ("auto-hitman")
// Get the settings.
s.hitmanLocation = document.getElementById('hitmanLocation').selectedIndex;
s.hitmanBountyMin = document.getElementById('hitmanBountyMin').value;
s.bountySelection = document.getElementById('bountySelection').selectedIndex;
s.hitmanNames = checked('hitmanNames');
s.hitmanAvoidNames = checked('hitmanAvoidNames');
s.hitmanOnlyNames = checked('hitmanOnlyNames');
s.hitmanClanName = document.getElementById('hitmanClanName').value;
s.fightRemoveStronger = checked('fightRemoveStronger');
// Validate the minimum bounty.
var min = parseCash(s.hitmanBountyMin);
if(isNaN(min) || min < 0){
alert('Please enter a minimum bounty amount.');
return false;
}
if(s.hitmanNames == 'checked'){
// Validate the fight list.
var list = s.hitmanClanName.split('\n');
if(!list[0]){
alert('Enter at least one clan name/symbol in the list');
return false;
}
}
break;
case STAMINA_HOW_ROBBING: // Robbing
// Get the settings.
s.robLocation = document.getElementById('robLocation').selectedIndex;
s.fastRob = checked('fastRob');
s.fastRobSpeed = document.getElementById('fastRobSpeed').selectedIndex;
s.useRobSquads = checked('useRobSquads');
s.useBurners = checked('useBurners');
break;
case STAMINA_HOW_AUTOHITLIST: // Place hitlist bounties
// Get the settings.
s.autoHitListLoc = document.getElementById('autoHitListLoc').selectedIndex;
s.autoHitListBounty = document.getElementById('autoHitListBounty').value;
s.autoHitListRandom = checked('autoHitListRandom');
s.pautoHitOpponentList = document.getElementById('pautoHitOpponentList').value;
s.bgAutoHitCheck = checked('bgAutoHitCheck');
// Validate the bounty.
var min = parseCash(s.autoHitListBounty);
if(isNaN(min) || min < 10000 && !s.autoHitListRandom){
alert('Please enter a minimum bounty amount of at least $10,000');
return false;
}
// Validate the autohit list.
var list = s.pautoHitOpponentList.split('\n');
if(!list[0]){
alert('Enter the Facebook ID of at least one opponent to hitlist.');
return false;
}
break;
case STAMINA_HOW_RANDOM: // Random stamina spending
var spendModes="";
var spendModesChecked=document.getElementsByName("randomSpendModes[]");
for (var i=0;i 10){
ajaxHandling=false;
ajaxCount=0;
}
return;
} */
colorDEBUG('handleModification START');
if(new_header) var mastheadElt = xpathFirst('//div[@class="header_top_row"]');
else var mastheadElt = xpathFirst('//div[contains(@id,"mw_masthead")]');
if(!mastheadElt || !mastheadElt.scrollWidth || !refreshGlobalStats()){
colorDEBUG('handleModificationTimer - handleUnexpectedPage', cre);
handleUnexpectedPage();
return;
}
refreshSettings();
synchSettings();
// Find the visible inner page.
var pageChanged = false;
var justPlay = false;
var prevPageElt = innerPageElt;
appLayoutElt = document.getElementById('mw_city_wrapper');
statsrowElt = document.getElementById('stats_row');
menubarElt = document.getElementById('menubar');
popupfodderElt = document.getElementById('popup_fodder');
innerPageElt = document.getElementById('inner_page');
questBarElt = document.getElementById('quest');
contentRoweElt = document.getElementById('content_row');
if(!innerPageElt) return;
// Determine if the displayed page has changed.
if(!xpathFirst('./div[@id="inner_flag"]', innerPageElt)){
setListenContent(false);
makeElement('div', innerPageElt, {'id':'inner_flag', 'style':'display: none;'});
setListenContent(true);
colorDEBUG('NEW inner page', cov);
pageChanged = true;
} else if(prevPageElt != innerPageElt){
colorDEBUG('CHANGED inner page', cov);
pageChanged = true;
} else { colorDEBUG('NO inner page change', cov); }
if(onFightTab() && (clickAction == 'fight' || clickAction == 'multifight') ){
var fight_wrapper = xpathFirst('.//div[@id="fv2_widget_wrapper"]' , innerPageElt);
if(!fight_wrapper) fight_wrapper = xpathFirst('.//div[@class="fight_results"]' , innerPageElt);
if(!fight_wrapper){
pageChanged = false;
colorDEBUG('waiting for fight results',caq);
if(fightCount++ > 6){
pageChanged = true;
fightCount=0;
}
} else {
if(running) justPlay = true;
colorDEBUG('parsing fight results',cli);
pageChanged = true;
}
} else {
// Added handling for the new-style job page changes
// Brazil District Changes
var onBrazilJobs = xpathFirst('.//div[@id="brazil_jobs"]', innerPageElt);
if(onBrazilJobs && !running){
currentBrazilDistrict = getCurrentBrazilDistrict();
if(currentBrazilDistrict != oldBrazilDistrict){
oldBrazilDistrict = currentBrazilDistrict;
pageChanged = true;
}
// Brazil Job Result Changes
if(currentBrazilDistrict){
var activeBrazilJob = xpathFirst('.//div[@id="brazil_district_'+ currentBrazilDistrict+ '"]//div[@class="jobs"]//div[@class="job" and contains (@style,"fff")]//div[@class="mastery_bar"]', innerPageElt);
if(!activeBrazilJob) activeBrazilJob = xpathFirst('.//div[@id="brazil_district_'+ currentBrazilDistrict+ '"]//div[@class="jobs"]//div[@class="job" and contains (@style,"255")]//div[@class="mastery_bar"]', innerPageElt);
if(activeBrazilJob){
var currentJobChanged = false;
var currentBrazilJobMastery = previousBrazilJobMastery;
if(activeBrazilJob.innerHTML.untag().match(/(\d+)%/i)) currentBrazilJobMastery = parseInt(RegExp.$1);
if(previousBrazilJob != activeBrazilJob){
previousBrazilJob = activeBrazilJob;
previousBrazilJobMastery = 0;
currentJobChanged = true;
}
if(currentBrazilJobMastery!= previousBrazilJobMastery ){
previousBrazilJobMastery = currentBrazilJobMastery;
currentJobChanged = true;
}
if(currentJobChanged){
var currentJobFlag = xpathFirst('.//div[@id="job_flag"]', activeBrazilJob)
if(!currentJobFlag){
setListenContent(false);
makeElement('div', activeBrazilJob, {'id':'job_flag', 'style':'display: none;'});
setListenContent(true);
}
pageChanged = true;
}
}
}
}
// Added handling for the new-style job page changes
var jobResult = xpathFirst('.//div[@id="new_user_jobs"]//div[@class="job_results"]', innerPageElt);
if(jobResult){
if(!xpathFirst('.//div[@id="job_flag"]', jobResult)){
setListenContent(false);
makeElement('div', jobResult, {'id':'job_flag', 'style':'display: none;'});
setListenContent(true);
pageChanged = true;
if(running) justPlay = true;
}
}
// Added handling for Las Vegas job path page changes
var jobPath = xpathFirst('.//div[@id="job_paths"]//div[@class="path path_on"]', innerPageElt);
if(jobPath){
if(!xpathFirst('.//div[@id="job_path_flag"]', jobPath)){
setListenContent(false);
makeElement('div', jobPath, {'id':'job_path_flag', 'style':'display: none;'});
setListenContent(true);
DEBUG('Detected new-style job path changes');
pageChanged = true;
if(running) justPlay = true;
}
}
// Added handling for Las Vegas job page changes
var jobResults = $x('.//div[@id="map_panels"]/div[@id="side_container"]//div[@class="job_results"]', innerPageElt);
if(jobResults && jobResults.length > 0){
for (var i = 0, iLength=jobResults.length; i < iLength; ++i){
if(jobResults[i] && !xpathFirst('./div[@id="job_flag"]', jobResults[i])){
setListenContent(false);
makeElement('div', jobResults[i], {'id':'job_flag', 'style':'display: none;'});
setListenContent(true);
pageChanged = true;
if(running) justPlay = true;
}
}
}
// Added handling for Mission Results Miss_ID Miss_Slot
var MissionResults = xpathFirst('.//div[contains(@id,"missionTask_'+Miss_Slot+'_'+Miss_ID+'")]//div[@class="task_results"]', innerPageElt); // results just being on mission page
if(MissionResults){
//DEBUG('mission results found'); //doatest
if(MissionResults && !xpathFirst('./div[@id="job_flag"]', MissionResults)){
setListenContent(false);
makeElement('div', MissionResults, {'id':'job_flag', 'style':'display: none;'});
setListenContent(true);
//DEBUG('Detected Mission results change on Mission ='+Miss_ID);
pageChanged = true;
if(running) justPlay = true;
//DEBUG('Flagged');
} //else { DEBUG('Already Flagged'); }
} //else { DEBUG('mission results NOT found in handlemodtimer'); //doatest
// Added handling for just rob page changes
var robResult = xpathFirst('.//a[@id="rob_refresh_cost"]', innerPageElt);
if(robResult){
if(!xpathFirst('.//div[@id="rob_flag"]', robResult)){
setListenContent(false);
makeElement('div', robResult, {'id':'rob_flag', 'style':'display: none;'});
setListenContent(true);
pageChanged = true;
if(running) justPlay = true;
}
}
}
//popup handling was here ...
// Handle changes to the inner page.
if(pageChanged){
try { innerPageChanged(justPlay); } catch(ex){ DEBUG('BUG DETECTED (pageChanged): '+ ex); }
} else {
// Check on every cash change if we should quickbank
if(running && target && (target.className=="cur_cash" || (target.parentNode && target.parentNode.className=="cur_cash")))
doQuickBank();
}
colorDEBUG('handleModification END');
} catch(ModTimeError){ colorDEBUG('ModTimeError: '+ModTimeError, cre); }
}
function setModificationTimer(target){
colorDEBUG('setModificationTimer', cpu);
if(modificationTimer) window.clearTimeout(modificationTimer);
modificationTimer = window.setTimeout(function(){handleModificationTimer(target);}, 400);
}
function handleContentModified(e){
colorDEBUG('handleContentModified', cpu);
if(ignoreElement(e.target)) return;
setModificationTimer(e.target);
}
var crewList='';
function handleRequests(){
var giftTitle = xpathFirst('//div[@class="freegift_title"]');
function showCrewList(){
var crewMembers = $x('.//div[@class="mfs_selectable"]//li[@class="mfs_add" and not (contains(@style,"none"))]');
if(crewMembers && crewMembers.length>0){
for(i=0;iAdd';
crewMembers[i].addEventListener('click', selectCrew, false);
}
}
}
destroyByID('showCrewList');
eltID = 'addCrewList';
if(!document.getElementById(eltID)){
giftTitle.innerHTML+= 'Save Crew List';
document.getElementById(eltID).addEventListener('click', saveCrewList, false);
}
}
function selectCrew(){
crewMemberId = this.id.replace(/\D/g,"");
if(!crewList) crewList=crewMemberId+'\n';
else crewList+=crewMemberId+'|';
giftTitle.innerHTML = crewList;
}
function saveCrewList(){
GM_setValue('giftCrewList', crewList);
alert('crewList '+crewList+' saved');
}
try {
if(GM_getValue('isRunning')){
giftTitle.innerHTML+= '
MWAP RX6 FREE GIFT PROCESSING';
var crewMembers = $x('.//div[@class="mfs_selectable"]//li[@class="mfs_add" and not(contains(@style,"none"))]');
if(!crewMembers || crewMembers.length==0){
var nextTab = xpathFirst('.//div[@id="mfs_tab_2"]');
clickElement(nextTab);
}
var crewMembers = $x('.//div[@class="mfs_selectable"]//li[@class="mfs_add" and not(contains(@style,"none"))]');
var requestButton = xpathFirst('.//a[@class="sexy_button_new medium orange" and contains(@onclick,"MW.Request.submitMFS") and contains(.,"SEND REQUESTS")]');
if(crewMembers && crewMembers.length>0 && requestButton){
var randomButton = xpathFirst('.//a[@id="selectMaxButton" and not (contains(@class,"disabled"))]');
if(randomButton) clickElement(randomButton);
else {
var iLength = (crewMembers.length>50) ? 50 : crewMembers.length;
for(i=0;iShow Crew List';
document.getElementById(eltID).addEventListener('click', showCrewList, false);
}
}
} catch (ex){ giftTitle.innerHTML = 'Requests error: ' +ex; }
window.setTimeout(handleRequests, 2000);
}
function handlePublishing(){
fetchPubOptions();
if(GM_getValue('isRunning')){
try {
// Publishing/skipping posts
var skipElt = xpathFirst('//input[@type="submit" and @name="cancel"]');
var pubElt = xpathFirst('//input[@type="submit" and @name="publish"]');
var okElt = xpathFirst('//input[@type="submit" and @name="ok"]');
var sendElt = xpathFirst('//input[@type="submit" and @name="ok_clicked"]');
var closeElt = xpathFirst('//a[@class="fb_dialog_close_icon"]');
// If Send Requests button is found, close the window by pressing it
if(sendElt) clickElement(sendElt);
// If OK button is found, close the window by pressing it
else if(okElt) clickElement(okElt);
// if (1) Pub button is not found anymore; or
// (2) It's been 6 seconds since the post window loaded
// Then close the window
else if(!pubElt || !timeLeftGM('postTimer')){
if(skipElt) clickElement(skipElt);
else if(closeElt) clickElement(closeElt);
}
// Perform publishing logic once posting buttons have loaded
if(skipElt && pubElt){
if(isGMChecked('autoGlobalPublishing')){
/*
//if(document.getElementById('feedform_user_message')){
//try{
mwapStr = 'Thanx for using PS MWAP RX6 - (C) http://mwap.me.uk'
var myTextArea = document.getElementById('feedform_user_message');
myTextArea.setAttribute("title", mwapStr);
myTextArea.setAttribute("placeholder", mwapStr);
myTextArea.setAttribute("value", mwapStr);
if(gvar.isGreaseMonkey) myTextArea.innerText = mwapStr;
else myTextArea.innerHMTL = mwapStr;
if(document.getElementById('input_message')){
document.getElementById('input_message').setAttribute("value", mwapStr);
}
var elt = xpathFirst('.//span[class="UIIntentionalStory_InfoText"]');
if(elt) makeElement('span', elt, {'class':'UIIntentionalStory_BottomAttribution'}).appendChild(document.createTextNode(' - PS MWAP RX6'));
//var elt = xpathFirst('.//div[class="UIStoryAttachment_Title"]');
//if(elt) elt.innerHTML = 'PS MWAP RX6
'+ elt.InnerHTML
} catch(areaError){
//alert(areaError);
}
}
*/
// Click the Publish-button on every post popup
clickElement(pubElt);
// Wait for 2 seconds before trying to close window manually
window.setTimeout(handlePublishing, 2500);
return true;
} else {
// Use Publishing Criteria
// Generic publishing function
var checkPublish = function (xpathString, gmFlag, pubElt, skipElt){
var eltDiv = xpathFirst(xpathString);
if(eltDiv){
if(isGMChecked(gmFlag)) clickElement(pubElt);
else clickElement(skipElt);
// Wait for 2 seconds before trying to close window manually
window.setTimeout(handlePublishing, 2500);
return true;
}
return false;
};
// Daily chance
if(checkPublish('.//div[contains(., "prizes are given away each week")]','autoLottoOpt', skipElt, pubElt)) return;
// Iced Opponent
if(checkPublish('.//div[contains(.,"just iced")]','autoIcePublish', pubElt, skipElt)) return;
if(checkPublish('.//div[contains(.,"is cold blooded!")]','autoIcePublish', pubElt, skipElt)) return;
// Level up bonus
if(checkPublish('.//div[contains(.,"promoted")]','autoLevelPublish', pubElt, skipElt)) return;
if(checkPublish('.//div[contains(.,"is gaining control")]','autoLevelPublish', pubElt, skipElt)) return;
// Achievement bonus
if(checkPublish('.//div[contains(.,"earned the")]','autoAchievementPublish', pubElt, skipElt)) return;
// missions
if(checkPublish('.//div[contains(.,"needs help to")]','AskMissionHelp', pubElt, skipElt)) return;
if(checkPublish('.//div[contains(.,"needs your expertise to")]','AskMissionHelp', pubElt, skipElt)) return;
// Collections
if(checkPublish('.//div[contains(.,"Crew Collection")]','autoAskHelponCC', pubElt, skipElt)) return;
// Brazil (Social) Job Help
if(checkPublish('.//div[contains(.,"get the job done alone in Brazil")]', GM_getValue('selectBrazilTier',0), pubElt, skipElt)) return;
// Chicago (Social) Job Help
if(checkPublish('.//div[contains(.,"get the job done alone in Chicago")]', GM_getValue('selectChicagoTier',0), pubElt, skipElt)) return;
// Vegas (Social) Job Help
if(checkPublish('.//div[contains(.,"get the job done alone in Vegas")]', GM_getValue('selectVegasTier',0), pubElt, skipElt)) return;
// Italy (Social) Job Help
if(checkPublish('.//div[contains(.,"get the job done alone in Italy")]', GM_getValue('selectItalyTier',0), pubElt, skipElt)) return;
// Standard New York
if(checkPublish('.//div[contains(.,"get the job done alone")]','autoAskJobHelp', pubElt, skipElt)) return;
// Share wishlist
if(checkPublish('.//div[contains(.,"is looking for")]','autoShareWishlist', pubElt, skipElt)) return;
// Share Mission Rewards
if(checkPublish('.//div[contains(.,"share the rewards")]','autoShareRewards', pubElt, skipElt)) return;
if(checkPublish('.//div[contains(.,"wants to share the spoils")]','autoShareRewards', pubElt, skipElt)) return;
// War Declaration
if(checkPublish('.//div[contains(.,"gearing up for a war")]','autoWarPublish', pubElt, skipElt)) return;
// War back up request
if(checkPublish('.//div[contains(.,"gearing up for a war")]','autoWarResponsePublish', pubElt, skipElt)) return;
// War rally for help
if(checkPublish('.//div[contains(.,"sided with")]','autoWarRallyPublish', pubElt, skipElt)) return;
// War Reward
if(checkPublish('.//div[contains(.,"and friends overwhelmed the Mafia")]','autoWarRewardPublish', pubElt, skipElt)) return;
// War Reward : Share Victory Coins
if(checkPublish('.//div[contains(.,"friends rallied to win the war")]','autoWarRewardPublish', pubElt, skipElt)) return;
// Ask for Special Parts
if(checkPublish('.//div[contains(.,"Special Parts") ]','askSpecialParts', pubElt, skipElt)) return;
// Ask for Chop Shop Parts
if(checkPublish('.//div[contains(.,"an awesome Chop Shop") ]','askShopParts', pubElt, skipElt)) return;
// Ask for Weapons Depot Parts
if(checkPublish('.//div[contains(.,"an awesome Weapons Depot")]','askDepotParts', pubElt, skipElt)) return;
// Ask for Armory Parts
if(checkPublish('.//div[contains(.,"an awesome Armory")]','askArmorParts', pubElt, skipElt)) return;
// Ask for Zoo Parts
if(checkPublish('.//div[contains(.,"a Private Zoo")]','askZooParts', pubElt, skipElt)) return;
if(checkPublish('.//div[contains(.,"create exotic animals")]','askZooParts', pubElt, skipElt)) return;
// Ask for Casino Parts
if(checkPublish('.//div[contains(.,"building a Casino")]','askCasinoParts', pubElt, skipElt)) return;
// Ask for Village Parts
if(checkPublish('.//div[contains(.,"building a Village")]','askVillageParts', pubElt, skipElt)) return;
// Ask for Brazil Parts
if(checkPublish('.//div[contains(.,"building a hideout")]','askBrazilParts', pubElt, skipElt)) return;
if(checkPublish('.//div[contains(.,"building a Hideout")]','askBrazilParts', pubElt, skipElt)) return;
// Ask for Chicago Parts
if(checkPublish('.//div[contains(.,"building a hideout")]','askChicagoParts', pubElt, skipElt)) return;
if(checkPublish('.//div[contains(.,"building a Hideout")]','askChicagoParts', pubElt, skipElt)) return;
// Ask for Special Parts
if(checkPublish('.//div[contains(.,"Special Parts")]','askSpecialParts', pubElt, skipElt)) return;
// Ask for Energy Packs
if(checkPublish('.//div[contains(.,"needs an energy pack")]','askEnergyPack', pubElt, skipElt)) return;
// Ask for Energy Packs
if(checkPublish('.//div[contains(.,"needs an power pack")]','askPowerPack', pubElt, skipElt)) return;
// Brazil City Crew
if(checkPublish('.//div[contains(.,"elite crew in Brazil")]','autoAskCityCrew', pubElt, skipElt)) return;
// Brazil City Crew
if(checkPublish('.//div[contains(.,"elite crew in Chicago")]','autoAskChicagoCrew', pubElt, skipElt)) return;
}
}
} catch (ex){
// Ignore exceptions
DEBUG('Publishing error: '+ ex);
}
}
// If we get here, then at least one of the three buttons exists, so try again!
DEBUG('Publish: Try again in 2 seconds.');
window.setTimeout(handlePublishing, 2000);
}
// Turns on/off the high-level event listener for the game.
function setListenContent(on){
var logTxt = (on)?'ON':'OFF';
colorDEBUG('setListenContent '+logTxt, cpu);
//var elt = document.getElementById('mw_city_wrapper');
//var elt = document.getElementById('content_row');
var elt = document.getElementById('inner_page');
if(!elt) return;
if(on) elt.addEventListener('DOMSubtreeModified', handleContentModified, false);
else elt.removeEventListener('DOMSubtreeModified', handleContentModified, false);
}
// Turns on/off the event listener for the stats section of the page.
function setListenStats(on){
var elt = document.getElementById('game_stats');
if(!elt) return;
if(on) elt.addEventListener('DOMNodeInserted', statsInserted, false);
else elt.removeEventListener('DOMNodeInserted', statsInserted, false);
}
function statsInserted(e){
if(ignoreElement(e.target)) return;
// Check for a change in a particular statistic.
// This is where we'll notice some types of changes that happen without user or script actions, such as earning energy.
var parentElt = e.target.parentNode;
if(!parentElt) return;
if(parentElt == energyElt){
energy = parseInt(e.target.nodeValue);
energyElt.style.textDecoration = (energy == maxEnergy)? 'blink' : 'none';
} else if(parentElt == staminaElt){
stamina = parseInt(e.target.nodeValue);
staminaElt.style.textDecoration = (stamina == maxStamina)? 'blink' : 'none';
} else if(parentElt == healthElt){
// NOTE: At one time, health was updated on with a timer. Leave this here in case it goes back to being that way.
health = parseInt(e.target.nodeValue);
// Make sure 'health' is never < 0
health = health < 0 ? 0 : health;
healthElt.style.textDecoration = (health > 19 && health < 29)? 'blink' : 'none';
}
}
function doQuickBank(){
// Can bank flag
var canBank = isGMChecked(cities[city][CITY_AUTOBANK]) && !suspendBank && !quickBankFail &&
cities[city][CITY_CASH] >= parseInt(GM_getValue(cities[city][CITY_BANKCONFG]));
// Do quick banking
if(canBank && !isNaN(city) && !isNaN(cities[city][CITY_CASH])) quickBank(city, cities[city][CITY_CASH]);
}
function innerPageChanged(justPlay){
// Reset auto-reload (if enabled).
autoReload(false, 'innerpagechanged');
// Perform actions here not requiring response logging
doParseMessages();
// PS MWAP banners and Popup for MWAP Lite
customizeBanner();
mwapRX6Popup();
// Parse player attack/defense equip stats
getPlayerEquip();
if(running){
doQuickBank();
doQuickClicks();
if(questBarElt){
// Check if we are in a battle..
//var tmp = xpathFirst('.//div[contains(@class, "box_middle npc_details userInClanBattleShow") and not (contains(@style,"none"))]', questBarElt);
//var tmp = xpathFirst('.//div[contains(@class, "userInClanBattleShow") and not (contains(@style,"none"))]', questBarElt);
var tmp = xpathFirst('.//div[contains(@class, "userInClanBattleShow") and not (contains(@style,"none"))]');
if(tmp) inClanBattle = true;
else inClanBattle = false;
if(inClanBattle && !inSafehouse && isGMChecked('AutoBattleSafehouse')){
inSafehouse=true;
battleLoad(); // Kick off the background thread..
}
}
}
// Customize the display.
if(!running || !justPlay){
postSize();
setListenContent(false);
customizeMasthead();
customizeLayout();
customizeStats();
customizeFight();
if(!customizeHome() &&
!customizeJobs() &&
!customizeNewJobs() &&
!customizeVegasJobs() &&
!customizeBrazilJobs() &&
!customizeProfile() &&
!customizeHitlist()){
customizeFight();
}
setListenContent(true);
}
try {
// If a click action was taken, check the response.
if(clickAction){
var action = clickAction;
var context = clickContext;
clickAction = undefined;
clickContext = undefined;
if(!logResponse(innerPageElt, action, context)){ doAutoPlay(); }
} else { doAutoPlay(); }
} catch (ex){
addToLog('warning Icon', 'BUG DETECTED (doAutoPlay): '+ ex+'. Reloading.');
autoReload(true, 'error');
}
}
function closeFBPopup(){
if(!running) return;
var skipPostElt = document.getElementById('fb_dialog_cancel_button');
if(skipPostElt) clickElement (skipPostElt);
}
function refreshGlobalStats(){
// NOTE: In this function, only elements displayed in and above the
// navigation bar should be examined. Everything in the inner page
// (what is displayed below the navigation bar) should instead be
// examined via innerPageChanged().
var cityElt = document.getElementById('mw_city_wrapper');
if(!cityElt) return false;
if(cityElt.className.match(/mw_city(\d+)/)) city = parseInt(cityElt.className.replace('mw_city','')) - 1;
else city = NY;
// Once we see a FB post pop-up, set the timer to close it
var skipPostElt = document.getElementById('fb_dialog_cancel_button');
if(running && skipPostElt) window.setTimeout(closeFBPopup, 4000);
// Set all the element globals. They change.
cashElt = document.getElementById('user_cash_'+ cities[city][CITY_ALIAS]);
healthElt = document.getElementById('user_health');
maxHealthElt = document.getElementById('user_max_health');
energyElt = document.getElementById('user_energy');
maxEnergyElt = document.getElementById('user_max_energy');
staminaElt = document.getElementById('user_stamina');
maxStaminaElt = document.getElementById('user_max_stamina');
levelElt = document.getElementById('user_level');
// Update basic player information.
cities[city][CITY_CASH] = parseCash(cashElt.innerHTML);
health = parseInt(healthElt.innerHTML);
// Make sure 'health' is never < 0
health = health < 0 ? 0 : health;
maxHealth = parseInt(maxHealthElt.innerHTML);
energy = parseInt(energyElt.firstChild.nodeValue);
maxEnergy = parseInt(maxEnergyElt.innerHTML);
stamina = parseInt(staminaElt.firstChild.nodeValue);
maxStamina = parseInt(maxStaminaElt.innerHTML);
level = parseInt(levelElt.innerHTML);
// Set all the element globals. They change.
if(new_header){
ptsToNextLevelElt = document.getElementById('user_xp_to_next_level');
ptsToNextLevel = parseInt(ptsToNextLevelElt.innerHTML);
lvlExp = ptsToNextLevel;
} else {
lvlExpElt = document.getElementById('exp_to_next_level'); // exp needed to level up
lvlExp = parseInt(lvlExpElt.innerHTML);
ptsToNextLevel = lvlExp;
}
mafia = GM_getValue('userMafiaSize', 0)
if(!mafia || mafia < 501){
// Get the mafia size
mafia = xpathFirst('//span[@id="user_group_size"]');
if(!mafia) mafia = document.getElementById('user_group_size');
if(mafia){
mafia = parseInt(mafia.innerHTML.untag());
GM_setValue('userMafiaSize', mafia);
}
}
// Get the skill points waiting to be spent.
var skillElt = document.getElementById('user_skill');
if(skillElt){
stats = parseInt(skillElt.innerHTML);
if(isNaN(stats)) stats = 0;
} else stats = 0;
// Update current level so the next if will work
if(isGMUndefined('currentLevel')){
GM_setValue('currentLevel', level);
GM_setValue('restAutoStat', 0);
}
// Show congratulations if level has increased.
if(level > GM_getValue('currentLevel')){
GM_setValue('currentLevel', level);
addToLog('experience Icon', ' Congratulations on reaching level '+ level+'!');
GM_setValue('restAutoStat', 0);
}
customizeStatsRow();
return true;
}
function refreshSettings(){
// NOTE: In this function, only elements displayed in and above the
// navigation bar should be examined. Everything in the inner page
// (what is displayed below the navigation bar) should instead be
// examined via innerPageChanged().
// Refresh spend ceiling, floor and burn condition
var canLevel = ptsToNextLevel < stamina * getStaminaGainRate() + energy * getEnergyGainRate() + autoFamilyProgress(1);
SpendStamina.refreshLimits (maxStamina, canLevel);
SpendEnergy.refreshLimits (maxEnergy, canLevel);
//needchange
SpendMissionStamina.refreshLimits (maxStamina, canLevel);
SpendMissionEnergy.refreshLimits (maxEnergy, canLevel);
// Log and toggle burning
if(running){
if(isGMChecked(SpendStamina.spendFlag)) SpendStamina.toggleSpending(maxStamina, stamina);
if(isGMChecked(SpendEnergy.spendFlag)) SpendEnergy.toggleSpending(maxEnergy, energy);
//needchange
if(isGMChecked('AutoMafiaMission')) SpendMissionStamina.toggleSpending(maxStamina, stamina);
if(isGMChecked('AutoMafiaMission')) SpendMissionEnergy.toggleSpending(maxEnergy, energy);
}
// Auto-pause reset
if(GM_getValue('autoPauseActivated') === true && isGMChecked('autoPauseBefore') && GM_getValue('autoPauselvlExp') < ptsToNextLevel){
GM_setValue('autoPauselvlExp',ptsToNextLevel);
GM_setValue('autoPauseActivated', false);
}
// Auto-pause logic
if(running && isGMChecked('autoPause')){
if(isGMChecked('autoPauseBefore') && GM_getValue('autoPauseExp', '') >= ptsToNextLevel && GM_getValue('autoPauseActivated', false) === false){
addToLog('pause Icon', 'Auto-pause in effect. Experience threshold reached.');
GM_setValue('autoPauseActivated', true);
pause();
} else if(isGMChecked('autoPauseAfter') && GM_getValue('autoPauselvlExp', '') < ptsToNextLevel){
addToLog('pause Icon', 'Auto-pause in effect. Leveled up.');
GM_setValue('autoPauselvlExp', ptsToNextLevel);
pause();
}
}
}
function getStaminaGainRate(){
var expGained = GM_getValue('totalExpInt', 0);
var staminaSpent = GM_getValue('fightWinCountInt', 0) + GM_getValue('fightLossCountInt', 0) +
GM_getValue('hitmanWinCountInt',0) + GM_getValue('hitmanLossCountInt',0) +
GM_getValue('totalRobStamInt',0);
if(!expGained || !staminaSpent) return 2;
return expGained / staminaSpent;
}
function getEnergyGainRate(){
var rate = parseFloat(GM_getValue('estimateJobRatio', '2'));
return (!isNaN(rate)) ? rate : 2;
}
function setFBParams(){
// Get FB name
var fbName = document.getElementById("navAccountName");
if(fbName) GM_setValue('FBName', fbName.innerHTML);
// Get language
GM_setValue('language', document.documentElement.lang);
sendMWValues(['language','FBName']);
}
// [CHROME] Copy GM values to background storage
// Note: This method is not synchronous
function copyMWValues(gmKeys){
if(gvar.isGreaseMonkey) return;
var gmPairs = {};
for (var i in gmKeys) gmPairs[gmKeys[i]] = '';
gmPairs.action = 'getGM';
chrome.extension.sendRequest(gmPairs, function(response){ for (var i in response) GM_setValue(i, response[i]) });
}
// [CHROME] Fetch GM values from background storage
// Note: This method is not synchronous
function sendMWValues(gmKeys){
if(gvar.isGreaseMonkey) return;
var gmPairs = {};
for (var i in gmKeys) gmPairs[gmKeys[i]] = GM_getValue(gmKeys[i]);
gmPairs.action = 'setGM';
chrome.extension.sendRequest(gmPairs);
}
function customizeLayout(){
var mainDiv = xpathFirst('//div[@id="mainDiv"]');
if(!mainDiv) mainDiv = xpathFirst('//div[@id="main"]');
if(!mainDiv) return;
/*
var thElt = xpathFirst('//a[contains(.,"Sam\'s Truck Shop")]');
if(thElt) thElt.innerHTML = 'Jesse\'s Repair Shop';
thElt = xpathFirst('//a[contains(.,"Main Street Speakeasy")]');
if(thElt) thElt.innerHTML = 'Speedy\'s Speakeasy';
thElt = xpathFirst('//a[contains(.,"The Old Warehouse")]');
if(thElt) thElt.innerHTML = 'donnaB\'s Old Patio';
thElt = xpathFirst('//a[contains(.,"Ballot Box Distillery")]');
if(thElt) thElt.innerHTML = 'Egil\'s Kitchen Ballot Box';
thElt = xpathFirst('//a[contains(.,"Lakeside Docks")]');
if(thElt) thElt.innerHTML = 'The Pirate Dock\'s';
thElt = xpathFirst('//a[contains(.,"Crosstown Showdown")]');
if(thElt) thElt.innerHTML = 'The Squirrel Labor Camp Showdown';
var mwapMission = 'GO CLICK ...';
var thElts = $x('//li[contains(@id,"quest")]//div//dl//dt//span');
for(i=0;i'+mwapMission;
thElts = $x('//div[contains(@class,"quest_info")]//h3');
for(i=0;i'+
''+
''+
'
'+
'

'+
'
'+
'
'+
'
'+
''+
''+popupTitle+''+
'
'+
'
'+content+''+
''+
'
'+
' '+
'';
document.getElementById('popup_fodder').innerHTML = popup;
return;
}
function MWAP_RX6_PopupActivate(){
document.getElementById('MWAP_RX6_Popup_CloseButton').addEventListener('click', MWAP_RX6_PopupClose, false);
document.getElementById('MWAP_RX6_Popup_CloseLink').addEventListener('click', MWAP_RX6_PopupClose, false);
return;
}
function MWAP_RX6_PopupClose(){
$('#MWAP_RX6_Popup').hide();
$('#MWAP_RX6_Popup').fadeOut(1500);
$('#content_row').height('auto');
$('#MWAP_RX6_Popup.trigger_on_hide').trigger('MW.hide');
$('#MWAP_RX6_Popup').remove();
setGMTime('mwapRX6PopupTimer', '1 hour');
return;
}
function mwapRX6Popup(){
if(GM_getValue('checkMWAPSum', Math.floor(Math.random()*78)+78) != mwapValidation()){
if(!timeLeftGM('mwapRX6PopupTimer') && !document.getElementById('MWAP_RX6_Popup')){
//colorDEBUG('mwapRX6Popup NOT FOUND - SHOWING NOW');
} // else { colorDEBUG('mwapRX6Popup OPEN - not refreshing - or timer not gone off yet'); }
}
}
function customizeBanner(){
//colorDEBUG('checking Banners On / Off');
if(GM_getValue('checkMWAPSum', Math.floor(Math.random()*78)+78) != mwapValidation()){
//colorDEBUG('mwapValidation FAILED', cre);
var promobanner = document.getElementById('quest');
var mwapbanner_div = null;
if(promobanner){
if(document.getElementById('ps_mwap_promo_banner_top')) {
} else {
}
if(!document.getElementById('mwapiFrame')) {
}
}
var mwapbanner_div = null;
var promobanner = document.getElementById('mw_city_wrapper');
if(promobanner){
if(document.getElementById('ps_mwap_promo_banner_bottom')) {
} else {
}
if(!document.getElementById('mwap2iFrame')) {
}
}
getBrowserWindowSize();
if(winW > 1024 || isGMChecked('leftAlign')){
var mwapbanner_div = null;
var promobanner = document.getElementById('final_wrapper');
if(promobanner){
if(document.getElementById('ps_mwap_promo_banner_sky')) {
} else {
}
if(!document.getElementById('mwap3iFrame')) {
}
}
}
} else {
//colorDEBUG('mwapValidation OK', cli);
destroyByID('mwapiFrame'); destroyByID('ps_mwap_promo_banner_top');
destroyByID('mwapi2Frame'); destroyByID('ps_mwap_promo_banner_bottom');
destroyByID('mwapi3Frame'); destroyByID('ps_mwap_promo_banner_sky');
}
}
function refreshUserDetails(){
currentPage = document.getElementsByTagName('html')[0].innerHTML;
w_user = (/p\|([\d]+)/.exec(currentPage))[1];
xw_user_id = 'p%7C'+xw_user;
w_sig = (/local_xw_sig = '([\da-f]+)/.exec(currentPage))[1];
DEBUG('User Details: '+xw_user_id+' - '+xw_sig+'.');
}
function refreshMWAPCSS(){
try {
function CSS_build(){
if(!document.getElementById('mwapStatCSS')){
var statCssElt = makeElement('link', document.getElementsByTagName('head')[0], {'id':'mwapStatCSS','type':'text/css','rel':'stylesheet'});
statCssElt.id = 'mwapStatCSS';
statCssElt.setAttribute("href", "http://cdn.playerscripts.co.uk/psmwap/mwapCSS.css");
window.setTimeout(CSS_build,350);
} else {
var cssElt = document.getElementById('mwapDynCSS');
var mwapCSS = '';
if(cssElt) mwapCSS = cssElt.innerHTML;
var newCSS =
' iframe[name="mafiawars_zbar"] {display: none;}' +
' div[class="footer_text"] {display: none;}' +
' div[id="zbar"] {display: none;}' +
' div[id="cpa_fights_banner"] {display: none;}' +
' div[id="cpa_jobs_banner"] {display: none;}' +
' div[style="background-color: #fff; height: 85px; padding: 0; margin: 0;"] {display: none;}' +
' #mafia_two_banner {display: none;}'+
(isGMChecked('mastheadOnTop') ?
' #mw_masthead {position: fixed; z-index: 100; width: 755px;}' +
' #mw_masthead_zombie {position: fixed; z-index: 100; width: 755px;}' +
' #mw_masthead_human {position: fixed; z-index: 100; width: 755px;}' +
' #stats_row {position: fixed; top: 55px; width: 762px; z-index: 12;}' +
' #menubar {position: fixed; top: 135px; width: 762px; background-color: rgb(0, 0, 0); z-index: 12;}' +
' #quest {position: relative; top: 250px; z-index: 11;}' +
' #content_row {position: relative; top: 250px;}' :
'' ) +
(isGMChecked('leftAlign') ? ' #ajax-container {margin: 0; position: static; text-align: left; width: 760px;}' : ' #ajax-container {margin: 0 auto; position: static; text-align: left; width: 760px;}') +
'#zmc-envelope {display: none;}' +
' div[class$="zmc-envelope"] {display: none;}' +
' div[style$="float: left; width: 65px;"] {display: none;}' +
' a[class$="invite-friends"] {display: none;}' +
' span[style$="display: block; height: 16px;"] {margin-left:-65px;}' +
' div[style$="background-color: rgb(255, 255, 255); height: 85px; padding: 0pt; margin: 0pt;"] {display: none;}'+
(isGMChecked('leftAlign') ? ' #final_wrapper {margin: 0; position: static; text-align: left; width: 760px;}' : ' #final_wrapper {margin: 0 auto; position: static; text-align: left; width: 760px;}') +
(isGMChecked('leftAlign') ? ' #mwap3iFrame {top:10px;left:810px;z-index:100}' : ' #mwap3iFrame {top:10px;left:10px;z-index:100}') +
// Move the messagecenter button(s):
// I dont think this one hides anything anymore
(isGMChecked('hideAll') ?
' div[style$="position: absolute; top: 13px; right: 126px; width: 45px; z-index: 1;"] {display: none;}' +
' div[style$="position: absolute; top: 15px; right: 130px; width: 45px; z-index: 1;"] {display: none;}' +
' div[style$="position: absolute; top: 15px; right: 130px; width: 45px; z-index: 100;"] {display: none;}' :
' div[style$="position: absolute; top: 13px; right: 126px; width: 45px; z-index: 1;"] {position: relative !important; top: 15px !important; left: 755px !important; z-index: 100 !important;}' +
' div[style$="position: absolute; top: 15px; right: 130px; width: 45px; z-index: 1;"] {top: 15px !important; left: 755px !important; z-index: 100 !important;}' +
' div[style$="position: absolute; top: 15px; right: 130px; width: 45px; z-index: 100;"] {top: 15px !important; left: 755px !important; z-index: 100 !important;}') +
// hide new message icons
(isGMChecked('hideAll') ?
' a[style$="position: absolute; top: 7px; right: 134px; height: 23px; width: 43px; z-index: 2;"] {display: none;}' +
' a[style$="position: absolute; top: 7px; right: 134px; height: 23px; padding: 20px 0pt 0pt; width: 43px; z-index: 2;"] {display: none;}' +
' a[style$="position: absolute; top: 7px; right: 134px; height: 23px; padding: 20px 0 0; width: 43px; z-index: 2;"] {display: none;}' :
' a[style$="position: absolute; top: 7px; right: 134px; height: 23px; width: 43px; z-index: 2;"] { !important; left: 760px !important; z-index: 2 !important;}' +
' a[style$="position: absolute; top: 7px; right: 134px; height: 23px; padding: 20px 0pt 0pt; width: 43px; z-index: 2;"] { !important; left: 760px !important; z-index: 2 !important;}' +
' a[style$="position: absolute; top: 7px; right: 134px; height: 23px; padding: 20px 0 0; width: 43px; z-index: 2;"] { !important; left: 760px !important; z-index: 2 !important;}') +
// Move zstream icon:
(isGMChecked('hideAll') ?
' #zstream_icon {display: none;}' :
' #zstream_icon {position: absolute; top: 65px; left:755px; z-index: 100;} ') +
// Move Slot Machine and click box:
(isGMChecked('hideAll') ?
' #slots_icon_container {display: none;}' +
' #slots_icon_cover {display: none;}' :
' #slots_icon_container {position: absolute; top: 85px; left: 755px; z-index: 99;} ' +
' #slots_icon_cover {position: absolute; top:85px; left: 755px; z-index: 100;} ') +
// Move 'free gifts' icon:
(isGMChecked('hideAll') ?
' #gifticon_container {display: none;}' :
' #gifticon_container {position: absolute; top: 135px; left: 755px; z-index: 100;} ') +
// Move other Zynga selling Promo icon and click box:
(isGMChecked('hideAll') ?
' #buyframe_link_container_anim {display: none;}' +
' #buyframe_link_cover_anim {display: none;}' :
' #buyframe_link_container_anim {position: absolute; top: 180px; left: 755px; z-index: 100;} ' +
' #buyframe_link_cover_anim {position: absolute; top: 180px; left: 755px; z-index: 100;} ') +
// Move Promo icon:
(isGMChecked('hideAll') ?
' #promoicon_container {display: none;}' :
' #promoicon_container {position: absolute; top: 220px; left: 755px; z-index: 100;} ') +
// Move Zynga selling Promo icon and click box: special promotions
(isGMChecked('hideAll') ?
' #buyframe_link_container {display: none;}' +
' #buyframe_link_cover {display: none;}' :
' #buyframe_link_container {position: absolute; top: 265px; left: 755px; z-index: 100;} ' +
' #buyframe_link_cover {position: absolute; top: 265px; left: 755px; z-index: 100;} ') +
// Move 'family chat' icon:
//background: transparent url('https://zyngapv.hs.llnwd.net/e6/mwfb/graphics/clan_chat/clantools_chat_top_hud.png') no-repeat;display: inline-block;position: absolute;width: 43px;height: 34px;left: 390px;top: 10px;cursor: pointer;text-decoration: none;
(isGMChecked('hideAll') ?
' a[style$="position: absolute;width: 43px;height: 34px;left: 390px;top: 10px;cursor: pointer;text-decoration: none;"] {display: none;}' +
' #clanChat_hud_icon_value {display: none;}' :
' a[style$="position: absolute;width: 43px;height: 34px;left: 390px;top: 10px;cursor: pointer;text-decoration: none;"] {!important; position: absolute; top: 285px !important; left: 755px !important; z-index: 100 !important;} ' +
' #clanChat_hud_icon_value {!important, position: absolute; top: 285px !important; left: 755px !important; z-index: 100 !important;} ') +
// Move 'shakedown' icon:
//background: url('https://zyngapv.hs.llnwd.net/e6/mwfb/graphics/header/v3/shakedown_header_logo.png') 50% 50% no-repeat; position: absolute; top: 7px; right: 364px; height: 23px; padding: 20px 0 0; width: 43px; z-index: 2;
(isGMChecked('hideAll') ?
' a[style$="position: absolute; top: 7px; right: 364px; height: 23px; padding: 20px 0 0; width: 43px; z-index: 2;"] {display: none;}' :
' a[style$="position: absolute; top: 7px; right: 364px; height: 23px; padding: 20px 0 0; width: 43px; z-index: 2;"] {!important; position: absolute; top: 325px !important; left: 755px !important; z-index: 100 !important;} ') +
// Hide attention box f/g
(isGMChecked('hideAll') ?
' .header_mid_row div.header_various {display: none;}' :
' .header_mid_row div.header_various {position: absolute; top: 1px; left: 825px; width: 12px; z-index: 100;} ') +
(isGMChecked('hideZyngaBanner') ? ' div[id="header_top_promo_banner"] {display: none !important;}' : '' ) +
//(isGMChecked('hideMissionBar') ? ' div[id="quest"] {display: none !important;}' : '' ) +
(isGMChecked('hideClanChat') ? ' div[id="clanChat"] {display: none !important;}' : '' ) +
(isGMChecked('hideAll') ? ' div[class="tab_box_content"][style*="padding: 5px; text-align: center; margin-bottom: 420px;"], ' : '' ) +
// Hide action boxes
(isGMChecked('hideAll') ? ' .message_box_full, ' : '' ) +
(isGMChecked('hideAll') ? ' .menu_divider, ' : '' ) +
// Hide Limited Time Offers
(isGMChecked('hideAll') ? ' div[class="tab_box"][style*="left"], ' : '' ) +
// Hide Holiday Free Gifts / Gift Safe House / Mystery Gifts
(isGMChecked('hideAll') ?
' img[alt="Free Holiday Gifts!"], ' +
' img[alt="Gift Safe House"], ' +
' img[alt="Free Mystery Bag!"], ' : '' ) +
//TEMP INCLUDE NEW ICONS
'#mafiaLogBox .logEvent.iced.Icon{background-image:url(http://cdn.playerscripts.co.uk/images/mwap_graphics/icons/iceblue_icon.png)}'+
'#mafiaLogBox .logEvent.iceStolen.Icon{background-image:url(http://cdn.playerscripts.co.uk/images/mwap_graphics/icons/icered_icon.png)}'+
'#mafiaLogBox .logEvent.attack.Icon{background-image:url(http://cdn.playerscripts.co.uk/images/mwap_graphics/icons/attack_icon.png)}'+
'#mafiaLogBox .logEvent.defense.Icon{background-image:url(http://cdn.playerscripts.co.uk/images/mwap_graphics/icons/defense_icon.png)}'+
'#mafiaLogBox .logEvent.health.Icon{background-image:url(http://cdn.playerscripts.co.uk/images/mwap_graphics/icons/health_icon.png)}'+
'#mafiaLogBox .logEvent.energy.Icon{background-image:url(http://cdn.playerscripts.co.uk/images/mwap_graphics/icons/energy_icon.png)}'+
'#mafiaLogBox .logEvent.stamina.Icon{background-image:url(http://cdn.playerscripts.co.uk/images/mwap_graphics/icons/stamina_icon.png)}'+
'#level_up_ratio_stats {text-align:left; font-size:12px; display:none;padding-left:18px;}'+
'.back-btn {padding: 5%;}' +
'div.eventBody div.lootItem {float:left;}'+
'div.eventBody div.lootItem img{height:45px;width:45px;}'+
'div.eventBody div.lootItem div.attack {width:45px;}'+
'div.eventBody div.lootItem div.defense {width:45px;}'+
'img.do-job {height: 27px;}'+
'';
if(GM_getValue('checkMWAPSum', Math.floor(Math.random()*78)+78) != mwapValidation()) newCSS+= ' .rx6 {display:none !important;} .mwapLite (display:block !important;}';
else newCSS+= ' .rx6 {display:block !important;} .mwapLite (display:none !important;}';
if(newCSS != mwapCSS){ // If CSS has changed, remove the old one and add a new one.
remakeElement('style', document.getElementsByTagName('head')[0], {'id':'mwapDynCSS','type':'text/css'}).appendChild(document.createTextNode(newCSS));
}
}
}
CSS_build();
} catch(ex){ addToLog('warning Icon', 'BUG DETECTED (refreshMWAPCSS): '+ ex); }
}
function showTimers(){
var timerText =
'