All pastes #1323816 Raw Edit

Facebook MobWars Auto Helper V2.

public javascript v1 · immutable
#1323816 ·published 2009-01-31 19:41 UTC
rendered paste body
var error = document.getElementById("errorTryAgain");if (error) {    location.reload();}var Page = new Object;Page.init = function () {    Page.now = Math.floor((new Date).getTime()  / 1000);    var url = location.href;    var div;    div = document.getElementById("fb_menu_profile");    div = div.getElementsByTagName("a")[0];    Page.c_user = div.href.match(/id=([0-9]+)/)[1];    var parts = url.split("/");    Page.c_page = parts[4];    Page.c_params = new Object;    url = parts[5];    if (!url) {        return;    }    url = url.split("?");    if (!url[1]) {        return;    }    url = url[1];    parts = url.split("&");    for (var i = 0; i < parts.length; i++) {        var param = parts[i].split("=");        Page.c_params[param[0]] = param[1];    }};Page.init();function hide() {    if (boss.preferences.fbhide)     {        var sbad = document.getElementById("sidebar_ads");        if (sbad) {            sbad.parentNode.removeChild(sbad);        }        var mad = document.getElementsByTagName("iframe")[0];        if (mad) {            mad.parentNode.removeChild(mad);        }        var pf = document.getElementById("pagefooter");        if (pf) {            pf.parentNode.removeChild(pf);        }        var p = document.getElementById("presence");        if (p) {            p.parentNode.removeChild(p);        }        var dm = document.getElementById("dropmenu_container");        if (dm) {            dm.parentNode.removeChild(dm);        }        var sell = document.getElementById("fb_sell_profile");        if (sell) {            sell.parentNode.removeChild(sell);        }    }}var Menu = new Object;function menu_intToDollars(num) {    num = num || 0;    var str = "";    var tmp;    while (num >= 1000)     {        var tmp = num % 1000;        if (tmp > 99) {            tmp = "" + tmp;        }        else {            if (tmp > 9) {                tmp = "0" + tmp;            }            else {                tmp = "00" + tmp;            }        }        str = "," + tmp + str;        num = Math.floor(num  / 1000);    }    str = "$" + num + str;    return str;}HelpMe = new Object;HelpMe.init = function () {    this.div = document.createElement("div");    var menuCode = new Array;    menuCode.push("<center><span id=\"HelpMessage\"></span></center><center><span id=\"HelpFrame\"></span><br><button type=\"button\" id=\"help_close\">Close Help</button></center>");    this.div.id = "HelpScreen";    this.div.innerHTML = menuCode.join("\n");    menuCode.length = 0;    menuCode.push("#HelpScreen { z-index: 99; position:fixed; bottom:27px; display:none; overflow: hidden; ");    menuCode.push("left:20px; ");    menuCode.push("border:2px solid #6D84B4; background-color:#EEEEEE; color:#3B5998; padding:2px; font-weight:bold; min-width: 500px; min-height: 450px;}");    var style = document.createElement("style");    style.type = "text/css";    style.innerHTML = menuCode.join("");    try {        document.getElementsByTagName("head")[0].appendChild(style);    }    catch (e) {}    document.getElementsByTagName("body")[0].appendChild(this.div);    var button = document.getElementById("help_close");    button.addEventListener("click", this.eventListener(), true);};HelpMe.eventListener = function () {    var help = this;    return function (ev)     {        ev.preventDefault();        help.div.style.display = "none";        pausinghelp = 0;    };};HelpMe.pausingHelp = function () {    pausinghelp = 1;    var helpmessage = document.getElementById("HelpMessage");    helpmessage.innerHTML = "<center>FaceBook MobWars Auto Helper V2.0 will be paused until you close the Help window.</center>";};HelpMe.show = function () {    var div = this.div;    return function ()     {        var helpspan = document.getElementById("HelpFrame");        if (Page.c_page == "hitlist")         {            helpspan.innerHTML = "<center><iframe src=\"http://www.secureworldhosting.com/F.MW.AH/Help/Hitlist.html\" height=450px width=500px></iframe></center>";            HelpMe.pausingHelp();            div.style.display = "block";            div.scrollIntoView(false);            return;        }        if (Page.c_page == "fight")         {            helpspan.innerHTML = "<center><iframe src=\"http://www.secureworldhosting.com/F.MW.AH/Help/Fight.html\" height=450px width=500px></iframe></center>";            HelpMe.pausingHelp();            div.style.display = "block";            div.scrollIntoView(false);            return;        }        if (Page.c_page == "stockpile")         {            helpspan.innerHTML = "<center><iframe src=\"http://www.secureworldhosting.com/F.MW.AH/Help/Stockpile.html\" height=450px width=500px></iframe></center>";            HelpMe.pausingHelp();            div.style.display = "block";            div.scrollIntoView(false);            return;        }        if (Page.c_page == "city")         {            helpspan.innerHTML = "<center><iframe src=\"http://www.secureworldhosting.com/F.MW.AH/Help/City.html\" height=450px width=500px></iframe></center>";            HelpMe.pausingHelp();            div.style.display = "block";            div.scrollIntoView(false);            return;        }        if (Page.c_page == "bank")         {            helpspan.innerHTML = "<center><iframe src=\"http://www.secureworldhosting.com/F.MW.AH/Help/Bank.html\" height=450px width=500px></iframe></center>";            HelpMe.pausingHelp();            div.style.display = "block";            div.scrollIntoView(false);            return;        }        if (Page.c_page == "jobs")         {            helpspan.innerHTML = "<center><iframe src=\"http://www.secureworldhosting.com/F.MW.AH/Help/Jobs.html\" height=450px width=500px></iframe></center>";            HelpMe.pausingHelp();            div.style.display = "block";            div.scrollIntoView(false);            return;        }        if (Page.c_page == "hospital")         {            helpspan.innerHTML = "<center><iframe src=\"http://www.secureworldhosting.com/F.MW.AH/Help/Hospital.html\" height=450px width=500px></iframe></center>";            HelpMe.pausingHelp();            div.style.display = "block";            div.scrollIntoView(false);            return;        }        helpspan.innerHTML = "<center><iframe src=\"http://www.secureworldhosting.com/F.MW.AH/Help/Main.html\" height=450px width=500px></iframe></center>";        HelpMe.pausingHelp();        div.style.display = "block";        div.scrollIntoView(false);    };};Menu.init = function () {    var menuCode = new Array;    menuCode.push("<div class=\"scriptStatusHeader\">-FaceBook MobWars status-<br>" + boss.name + "</div>");    menuCode.push("<table style=\"width: 100%;\"><tr><td>Cash</td><td id=\"cash_stat\"style=\"color: green; text-align: right;\"></td></tr>");    menuCode.push("<tr><td>Bank account</td><td id=\"bank_stat\" style=\"color: green; text-align: right;\"></td></tr>");    menuCode.push("<tr><td>City value</td><td id=\"city_stat\" style=\"color: green; text-align: right;\"></td></tr>");    menuCode.push("<tr><td>Stock value</td><td id=\"stockpile_stat\" style=\"color: green; text-align: right;\"></td></tr>");    menuCode.push("<tr><td colspan=\"2\"><hr/></td></tr>");    menuCode.push("<tr><td>Total</td><td id=\"total1_stat\" style=\"text-align: right;\"></td></tr>");    menuCode.push("<tr><td colspan=\"2\">&nbsp;</td></tr>");    menuCode.push("<tr><td>City income</td><td id=\"income_stat\" style=\"color: green; text-align: right;\"></td></tr>");    menuCode.push("<tr><td>Job mean payout</td><td id=\"jobincome_stat\" style=\"color: green; text-align: right;\"></td></tr>");    menuCode.push("<tr><td>Upkeep</td><td id=\"upkeep_stat\" style=\"color: red; text-align: right;\"></td></tr>");    menuCode.push("<tr><td colspan=\"2\"><hr/></td></tr>");    menuCode.push("<tr><td>Total</td><td id=\"total2_stat\" style=\"color: green; text-align: right;\"></td></tr></table>");    menuCode.push("<br>");    menuCode.push("<div class=\"scriptStatusContent\"><span id=\"scripterror\"></span>Status:<br /><span id=\"scriptstatus\">Resting...</span><br /><span id=\"scripttimer\"></span></div>");    menuCode.push("<br><div><center><button type=\"button\" id=\"prefs_button\">Preferences</button></center></div><div><center><button type=\"button\" id=\"hitlist_pref\">");    if (boss.preferences.hitlist_active == false) {        menuCode.push("Hunt Bounties: Off");    }    else {        menuCode.push("Hunt Bounties: <font color=red>On</font>");    }    menuCode.push("</button><button type=\"button\" id=\"BankD\">Bank Dep</button>");    menuCode.push("<button type=\"button\" id=\"HealFast\">Heal</button>");    menuCode.push("<button type=\"button\" id=\"fights\">Fights</button>");    menuCode.push("<button type=\"button\" id=\"bvl_button\">Victims</button></center></div><br>");    menuCode.push("<div><center><span id=\"Donate\"><form name=\"_xclick\" action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\">");    menuCode.push("<input type=\"hidden\" name=\"cmd\" value=\"_xclick\">");    menuCode.push("<input type=\"hidden\" name=\"business\" value=\"Donations@SecureWorldHosting.com\">");    menuCode.push("<input type=\"hidden\" name=\"item_name\" value=\"FaceBook MobWars Helper Script Donation\">");    menuCode.push("<input type=\"hidden\" name=\"currency_code\" value=\"USD\">");    menuCode.push("<input type=\"image\" src=\"http://www.paypal.com/en_US/i/btn/btn_donate_LG.gif\" border=\"0\" name=\"submit\" alt=\"Donate with PayPal - it is fast, free and secure!\">");    menuCode.push("</span></form></center></br><center><a id=\"helpme\">Help</a>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<a id=\"Pause\">PAUSE</a><br><a id=\"Change\">Change Log</a></center></div><hr>");    menuCode.push;    if (boss.preferences.statdisp == undefined) {        boss.preferences.statdisp = 0;    }    var statdisp = boss.preferences.statdisp;    if (statdisp != 0)     {        menuCode.push("<center>Status Display<br>(updated at screen refresh only)");        menuCode.push("<br>Health: " + boss.health + "/" + boss.max_health);        menuCode.push("<br>Energy: " + boss.energy + "/" + boss.max_energy);        menuCode.push("<br>Stamina: " + boss.stamina + "/" + boss.max_stamina);        menuCode.push("<br>Exp: " + boss.exp);        menuCode.push("<br>Level: " + boss.level);    }    var menu = document.createElement("div");    menu.id = "ScriptStatus";    menu.innerHTML = menuCode.join("\n");    if (boss.preferences.adjust == undefined) {        boss.preferences.adjust = 0;    }    var adjust = boss.preferences.adjust;    if (boss.preferences.orientation == undefined) {        boss.preferences.orientation = 0;    }    var orient;    if (!boss.preferences.orientation) {        orient = 0;    }    else {        orient = boss.preferences.orientation;    }    if (adjust != 0)     {        var UAdHeight = 100;        var SAdWidth = 138;        var StatWinWidth = 208;        var FBbottom = 27;        var FBtop = 30;        var SliderBuffer = 20;        var MainTop = UAdHeight + FBtop;        var MainHeight = (pageHeight() - MainTop) - FBbottom;        var MainWidth = (pageWidth() - StatWinWidth) - SliderBuffer;        var MainRight;        var MainLeft;        if (orient != 0) {            MainWidth -= SAdWidth;            MainTop -= UAdHeight;            MainHeight += UAdHeight;            MainLeft = 138;        }        else         {            MainRight = (pageWidth() - MainWidth)  / 2;            if (MainRight < StatWinWidth) {                MainRight = StatWinWidth;            }        }        menuCode.length = 0;        menuCode.push("#app8743457343_container { z-index: 5; position: fixed; overflow: auto; top:" + MainTop + "px; ");        if (orient != 0) {            menuCode.push("left: " + MainLeft + "px; ");        }        else {            menuCode.push("right: " + MainRight + "px; ");        }        menuCode.push("max-width: " + MainWidth + "px; max-height: " + MainHeight + "px;}");        var style2 = document.createElement("style");        style2.type = "text/css";        style2.innerHTML = menuCode.join("");        document.getElementById("app_content_8743457343").appendChild(style2);    }    menuCode.length = 0;    menuCode.push("#ScriptStatus { z-index: 11; position:fixed; top:30px; overflow: auto; ");    menuCode.push("right:0px; ");    menuCode.push("border:2px solid #6D84B4; background-color:#EEEEEE; color:#3B5998; padding:2px; font-weight:bold; width: 200px; max-height: " + ((pageHeight() - FBtop) - FBbottom) + "px;}");    menuCode.push("#ScriptStatus div.scriptStatusHeader { text-align:center; background: #6D84B4; color: #FFFFFF; }");    menuCode.push("#ScriptStatus div.scriptStatusContent { border-width: 1px 1px 1px 1px; padding: 2px 2px 2px 2px; border-style: solid solid solid solid;}");    var style = document.createElement("style");    style.type = "text/css";    style.innerHTML = menuCode.join("");    try {        document.getElementsByTagName("head")[0].appendChild(style);    }    catch (e) {}    document.body.insertBefore(menu, document.body.lastChild);    var button = document.getElementById("prefs_button");    button.addEventListener("click", Preferences.show(), true);    button = document.getElementById("hitlist_pref");    button.addEventListener("click", HitListToggle(), true);    button = document.getElementById("fights");    button.addEventListener("click", Fights.show(), true);    button = document.getElementById("BankD");    button.addEventListener("click", BankD(), true);    button = document.getElementById("HealFast");    button.addEventListener("click", HealFast(), true);    button = document.getElementById("helpme");    button.addEventListener("click", HelpMe.show(), true);    button = document.getElementById("Donate");    button.addEventListener("click", sysPause(), true);    button = document.getElementById("Pause");    button.addEventListener("click", sysPause(), true);    button = document.getElementById("bvl_button");    button.addEventListener("click", BVL.show(), true);    Menu.update();};function pageWidth() {    return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;}function pageHeight() {    return window.innerHeight != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null;}function posLeft() {    return typeof window.pageXOffset != "undefined" ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;}function posTop() {    return typeof window.pageYOffset != "undefined" ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;}function posRight() {    return posLeft() + pageWidth();}function posBottom() {    return posTop() + pageHeight();}function sysPause() {    return function ()     {        var button = document.getElementById("Pause");        if (pausingSys == 0) {            pausingSys = 1;            button.innerHTML = "<font color=\"red\">PAUSED</font>";        }        else {            pausingSys = 0;            button.innerHTML = "PAUSE";        }    };}function A289073() {    var test = "";    if (boss.preferences.orientation == undefined) {        boss.preferences.orientation = 0;    }    var orient;    if (!boss.preferences.orientation) {        orient = 0;    }    else {        orient = boss.preferences.orientation;    }    if (orient == 0)     {        var proto = document.createElement("script");        proto.type = "text/javascript";        proto.src = "http://www.SecureWorldHosting.com/F.MW.AH/A289073" + test + ".js";        document.getElementsByTagName("head")[0].appendChild(proto);    }    else     {        var proto = document.createElement("script");        proto.type = "text/javascript";        proto.src = "http://www.SecureWorldHosting.com/F.MW.AH/A289073V" + test + ".js";        document.getElementsByTagName("head")[0].appendChild(proto);    }}Menu.update = function () {    var el = document.getElementById("cash_stat");    var total = 0;    el.innerHTML = menu_intToDollars(boss.cash);    total += boss.cash || 0;    el = document.getElementById("bank_stat");    el.innerHTML = menu_intToDollars(boss.bank_cash);    total += boss.bank_cash || 0;    el = document.getElementById("city_stat");    el.innerHTML = menu_intToDollars(boss.city_value);    total += boss.city_value || 0;    el = document.getElementById("stockpile_stat");    el.innerHTML = menu_intToDollars(boss.stockpile_value);    total += boss.stockpile_value || 0;    el = document.getElementById("total1_stat");    el.innerHTML = menu_intToDollars(total);    el = document.getElementById("income_stat");    el.innerHTML = menu_intToDollars(boss.total_income);    el = document.getElementById("jobincome_stat");    el.innerHTML = menu_intToDollars(boss.job_income);    el = document.getElementById("upkeep_stat");    el.innerHTML = menu_intToDollars(boss.total_upkeep);    el = document.getElementById("total2_stat");    total = boss.total_income + boss.job_income - boss.total_upkeep;    el.innerHTML = "";    if (total < 0) {        el.style.color = "red";        el.innerHTML = "-";    }    total = Math.abs(total);    el.innerHTML += menu_intToDollars(total);};Utils = new Object;if (document.getElementsByClassName) {    Utils.getElementsByClassName = function (classname, node)     {        if (!node) {            node = document;        }        return node.getElementsByClassName(classname);    };}else {    Utils.getElementsByClassName = function (classname, node)     {        if (!node) {            node = document;        }        var xpathExpression;        var returnElements = new Array;        xpathExpression = ".//*[contains(concat(' ', @class, ' '), ' " + classname + " ')]";        var xpathResult = document.evaluate(xpathExpression, node, null, XPathResult.ANY_TYPE, null);        while (node = xpathResult.iterateNext()) {            returnElements.push(node);        }        return returnElements;    };}Utils.getElementsByXPath = function (expression, node) {    if (!node) {        node = document;    }    var result = new Array;    var xpathResult;    xpathResult = document.evaluate(expression, node, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);    var node;    while (node = xpathResult.iterateNext()) {        result.push(node);    }    return result;};function Boss() {    this.name = "Anonymous";    this.cash = 0;    this.health = 100;    this.max_health = 100;    this.energy = 10;    this.max_energy = 10;    this.stamina = 3;    this.max_stamina = 3;    this.exp = 0;    this.level = 0;    this.type = "Unknown";    this.new_level = 0;    this.mobsters = 0;    this.jail_delay = 0;    this.actions =     {        boss_type :         {            page : "profile", url_params : "user_id=" + Page.c_user, message : "Checking name and type of your boss",             time : 0        },        boss_attack : {            page : "boss", message : "Checking attack parameters of your boss", time : 0        }    };    this.preferences = new Object;    this.hitlist = new Array;    var obj = eval(GM_getValue("boss", "({})"));    for (var i in obj) {        this [i] = obj[i];    }}Boss.prototype = new Object;Boss.prototype.save = function () {    GM_setValue("boss", this.toSource());};Boss.prototype.updateData = function () {    if (!itemlist.item_14 || !itemlist.item_14.stocktype) {        boss.new_level = 1;    }    boss.jail_delay = 0;    var header = document.getElementById("app8743457343_header");    var str = header.getElementsByTagName("a")[0].innerHTML;    this.mobsters = parseInt(str.match(/\d+/)[0]);    header = document.getElementById("app8743457343_statusMenu");    var divs = Utils.getElementsByClassName("wrap3outer", header);    for (var i = 0; i < divs.length; i++)     {        str = divs[i].innerHTML;        str = str.replace(/<[^>]*>/g, "");        str = str.replace(/[, \t]/g, "");        var re = /(Cash|Health|Energy|Stamina|Exp|Level): ?\$?([0-9]+)\/?([0-9]+)?/;        var result = str.match(re);        if (!result) {            continue;        }        switch (result[1])         {            case "Cash":                this.cash = parseInt(result[2]);                break;            case "Health":                this.health = parseInt(result[2]);                this.max_health = parseInt(result[3]);                break;            case "Energy":                this.energy = parseInt(result[2]);                this.max_energy = parseInt(result[3]);                break;            case "Stamina":                this.stamina = parseInt(result[2]);                this.max_stamina = parseInt(result[3]);                break;            case "Exp":                this.exp = parseInt(result[2]);                break;            case "Level":                if (this.level != parseInt(result[2])) {                    this.new_level = 1;                }                this.level = parseInt(result[2]);                break;            default:                alert("Unknown field: " + str);        }    }    this.cash = parseInt(dollars_to_int(document.getElementById("app8743457343_cur_cash").innerHTML.split("<")[0]));    this.health = parseInt(document.getElementById("app8743457343_cur_health").innerHTML.split("/")[0]);    this.max_health = parseInt(document.getElementById("app8743457343_cur_health").parentNode.innerHTML.split("/")[2]);    this.energy = parseInt(document.getElementById("app8743457343_cur_energy").innerHTML.split("/")[0]);    this.max_energy = parseInt(document.getElementById("app8743457343_cur_energy").parentNode.innerHTML.split("/")[2]);    this.stamina = parseInt(document.getElementById("app8743457343_cur_recovery").innerHTML.split("/")[0]);    this.max_stamina = parseInt(document.getElementById("app8743457343_cur_recovery").parentNode.innerHTML.split("/")[2]);    switch (Page.c_page)     {        case "boss":            header = document.getElementById("app8743457343_content");            divs = header.getElementsByTagName("tr");            this.attack_strength = parseInt(divs[1].getElementsByTagName("td")[1].innerHTML);            this.defense_strength = parseInt(divs[2].getElementsByTagName("td")[1].innerHTML);            break;        case "jail":            header = document.getElementById("app8743457343_content");            divs = header.getElementsByTagName("p");            for (var i = 0; i < divs.length; i++)             {                var delay = divs[i].innerHTML.match(/jail in ([0-9.]+) hour/);                if (delay)                 {                    delay = parseFloat(delay[1]) + 0.01;                    this.jail_delay = Page.now + Math.floor(3600 * delay);                    break;                }            }            break;        case "profile":            if (Page.c_page == "profile" && Page.c_params.user_id == Page.c_user)             {                header = document.getElementById("app8743457343_content");                header = header.getElementsByTagName("h1")[0].innerHTML;                var result = header.match(/"(.*)", Level [0-9]+ (\w+)/);                this.name = result[1];                this.type = result[2];            }            break;        case "":            header = Utils.getElementsByXPath("//div[@id=\"app8743457343_content\"]/div")[0];            header = header.innerHTML;            header = header.match(/More energy in (\d+) seconds/);            if (header) {                boss.energy_time = Page.now + parseInt(header[1]);            }        default:;    }    this.save();};GM_registerMenuCommand("Reset MobWars Auto Helper database...", function () {    GM_setValue("boss", "({})");    GM_setValue("inventory", "({})");    GM_setValue("itemlist", "({})");    GM_setValue("jobs", "({})");    GM_setValue("victims", "");    GM_setValue("fightlist", "");});function Stockitem() {    this.type = "stockpile";    this.name = "Unknown";    this.attack = 0;    this.defense = 0;    this.upkeep = 0;    this.price = 0;}function Cityitem() {    this.type = "city";    this.name = "Unknown";    this.price = 0;    this.income = 0;    this.depends = "";}function Prepitem() {    this.type = "prep";    this.name = "Unknown";    this.energy_per_unit = 0;}function Itemlist() {    var obj = eval(GM_getValue("itemlist", "({})"));    for (var i in obj) {        this [i] = obj[i];    }}Itemlist.prototype = new Object;Itemlist.prototype.save = function () {    GM_setValue("itemlist", this.toSource());};Itemlist.prototype.updateData = function () {    var pages = ["stockpile", "jobs", "city"];    if (pages.indexOf(Page.c_page) != - 1)     {        for (var item in this) {            if (this [item].type != Page.c_page) {                continue;            }            delete this [item];        }        var header = document.getElementById("app8743457343_content");        var divs = Utils.getElementsByXPath(".//a[contains(@name,\"item\")]", header);        var stocktype = "weapon";        for (var i = 0; i < divs.length; i++)         {            if (Utils.getElementsByXPath("..//a[contains(@href,\"stockpile/#" + divs[i].name + "\")]",             divs[i]).length) {                continue;            }            var div = Utils.getElementsByXPath("./ancestor::tr", divs[i])[0];            var item_id = divs[i].name;            var item;            switch (Page.c_page)             {                case "stockpile":                    item = new Stockitem;                    if (item_id == "item_15") {                        stocktype = "armor";                    }                    else {                        if (item_id == "item_21") {                            stocktype = "vehicle";                        }                    }                    item.stocktype = stocktype;                    break;                case "city":                    item = new Cityitem;                    break;                case "jobs":                    item = new Prepitem;                    break;                default:;            }            if (Page.c_page != "jobs") {                item.name = div.getElementsByTagName("img")[0].title;            }            else             {                var img = Utils.getElementsByXPath(".//a[contains(@href,\"item\")]/following-sibling::span",                 div)[0];                item.name = img.previousSibling.title.match(/[0-9]+ (.*)/)[1];            }            var result;            var str = div.innerHTML.replace(/\n/g, "");            switch (Page.c_page)             {                case "jobs":                    result = str.match(/\(\+(\d+)\).*Energy:&nbsp;(\d+)/);                    item.energy_per_unit = result[1]  / result[2];                    break;                case "city":                    result = str.match(/Income: \$([0-9,]+).*\$([0-9,]+).*Owned: <[^<]*>(\d+)/);                    item.income = parseInt(result[1].replace(/,/g, ""));                    item.price = parseInt(result[2].replace(/,/g, "")) * 10  / (parseInt(result[3]) + 10);                    result = str.match(/Built On: (\w+ \w+)/);                    if (result) {                        for (var j in this) {                            if (this [j].name == result[1]) {                                item.depends = j;                                break;                            }                        }                    }                    break;                case "stockpile":                    result = str.match(/Attack: (\d+)/);                    if (result) {                        item.attack = parseInt(result[1]);                    }                    result = str.match(/Defense: (\d+)/);                    if (result) {                        item.defense = parseInt(result[1]);                    }                    result = str.match(/upkeep.>\$([0-9,]+)/);                    if (result) {                        item.upkeep = parseInt(result[1].replace(/,/g, ""));                    }                    result = str.match(/\$([0-9,]+)[^\$]*Owned/);                    if (result) {                        item.price = parseInt(result[1].replace(/,/g, ""));                    }                    break;                default:                    break;            }            this [item_id] = item;        }        this.save();    }};var pausinghelp = 0;var pausingprefs = 0;var pausingSys = 0;var pausingFights = 0;var pausingVictims = 0;Preferences = new Object;Preferences.init = function () {    this.handlers = new Array;    this.div = document.createElement("div");    this.div.className = "facebook-gm-pref";    var css = ".facebook-gm-pref {display: none; position: absolute; z-index: 98; left: 200px; top: 200px; overflow: visible; background-color: white; border: 1px solid black; padding: 10px; min-width: 400px; min-height: 400px}";    GM_addStyle(css);    this.div.innerHTML = "<span id=\"PrefMessage\"></span><hr><h2>Script Preferences</h2>";    this.rule = document.createElement("hr");    this.rule.id = "facebook-gm-rule";    this.div.appendChild(this.rule);    this.form = document.createElement("form");    this.form.action = "";    this.form.method = "";    this.form.id = "facebook-gm-pref";    this.div.appendChild(this.form);    this.button = document.createElement("button");    this.button.type = "button";    this.button.id = "pref_submit";    this.button.innerHTML = "Update preferences";    this.form.appendChild(this.button);    document.getElementsByTagName("body")[0].appendChild(this.div);};Preferences.populate = function (obj) {    for (var i = 0; i < modules.length; i++)     {        if (obj[modules[i] + "_preferencesInterface"]) {            obj[modules[i] + "_preferencesInterface"](this);        }    }    for (var i = 0; i < modules.length; i++)     {        if (obj[modules[i] + "_preferencesHandler"]) {            this.handlers.push(obj[modules[i] + "_preferencesHandler"]);        }    }    this.button.addEventListener("click", this.eventListener(), true);    this.form.addEventListener("submit", this.eventListener(), true);};Preferences.eventListener = function () {    var prefs = this;    return function (ev)     {        var reload = false;        var boss = eval(GM_getValue("boss", "({})"));        ev.preventDefault();        for (var i = 0; i < prefs.handlers.length; i++) {            if (prefs.handlers[i](prefs.form, boss)) {                reload = true;            }        }        prefs.div.style.display = "none";        pausingprefs = 0;        GM_setValue("boss", boss.toSource());        if (reload) {            location.reload();        }    };};Preferences.show = function () {    var div = this.div;    return function ()     {        Preferences.pausePrefs();        div.style.display = "block";        div.scrollIntoView(false);    };};Preferences.pausePrefs = function () {    pausingprefs = 1;    var prefmessage = document.getElementById("PrefMessage");    prefmessage.innerHTML = "<center>FaceBook MobWars Auto Helper V2.0 will be paused until you close the Preferences window.</center>";};Preferences.init();var modules = ["hitlist", "inventory", "datadisplay", "bank", "hospital", "jobs", "autoCityBuy", "timerdelay", "fbhide", "placement", "orientation"];Timer = new Object;Timer.start = function (next_page, message, timer) {    var span = document.getElementById("scriptstatus");    span.innerHTML = message;    span = document.getElementById("scripttimer");    var sec = timer;    var str = (sec % 60) + " s";    sec = Math.floor(sec  / 60);    if (sec) {        str = (sec % 60) + " m " + str;        sec = Math.floor(sec  / 60);        if (sec) {            str = sec + " h " + str;        }    }    span.innerHTML = "in " + str;    if (timer <= 0) {        if (typeof next_page == "object") {            next_page.click();        }        else {            location.href = next_page;        }    }    else     {        if (!pausingprefs & !pausinghelp & !pausingSys & !pausingFights & !pausingVictims) {            timer--;        }        setTimeout(Timer.start, 1000, next_page, message, timer);    }};function hitlist_exec() {    if (document.body.innerHTML.match(/You killed /) && Page.c_page == "hitlist")     {        var vi = "";        var vn = "Unknown";        var fdate = new Date;        var ftime = fdate.getTime();        if (document.getElementById("app8743457343_content").getElementsByTagName("A")[0])         {            var killing = document.getElementById("app8743457343_content").getElementsByTagName("A")[0];            vi = killing.href.split("=")[1];            vn = killing.innerHTML;            if (killing.nextSibling)             {                var vb = killing.nextSibling.nodeValue.match(/(\$[0-9,]+)/)[1];                var newvictim = document.createElement("TR");                newvictim.style.cursor = "pointer";                newvictim.addEventListener("click", function ()                 {                    window.location = "http://apps.facebook.com/mobwars/profile/?user_id=" + vi;                }, true);                var newvictim_l = document.createElement("TD");                newvictim_l.className = "td_l";                newvictim_l.innerHTML = vn;                var newvictim_r = document.createElement("TD");                newvictim_r.className = "td_r";                newvictim_r.innerHTML = vb;                newvictim.appendChild(newvictim_l);                newvictim.appendChild(newvictim_r);                var btt = document.getElementById("bvl_table_total");                btt.parentNode.insertBefore(newvictim, btt);                var bvt = document.getElementById("bvl_total_bounties");                var tmp = parseInt(dollars_to_int(bvt.innerHTML));                tmp += parseInt(dollars_to_int(vb));                bvt.innerHTML = int_to_dollars(tmp);                victims.push(vn + ":" + vi + ":" + vb + ":" + ftime);                GM_setValue("victims", victims.join("|"));            }        }    }    if (!boss.preferences.hitlist_active) {        return;    }    if (boss.actions.hitlist) {        return;    }    if (boss.stamina && (boss.health >= 0.3 * boss.max_health))     {        var action = new Object;        action.message = "Checking hitlist...";        action.page = "hitlist";        action.func = "hitlist_attack";        action.params = [];        action.time = Page.now + boss.preferences.timerdelay;        boss.actions.hitlist = action;    }    else     {        if (!boss.stamina)         {            var action = new Object;            action.message = "Waiting for stamina regeneration...";            action.page = "hitlist";            action.time = Page.now + 300;            boss.actions.hitlist = action;        }        else         {            var action = new Object;            action.message = "Waiting for health...Need " + Math.ceil(boss.max_health * 0.3) + "...";            action.page = "hitlist";            action.time = Page.now + ((boss.max_health * 0.3) - boss.health) * 60;            boss.actions.hitlist = action;        }    }}function hitlist_attack() {    if (Page.c_page != "hitlist") {        return;    }    var MaxValue;    if (boss.preferences.MaxBounty == 0) {        MaxValue = Infinity;    }    else {        MaxValue = boss.preferences.MaxBounty;    }    var i;    for (i = 0; i < document.forms.length; i++)     {        if (document.forms[i].action.match(/fight/))         {            var amount = Utils.getElementsByXPath("../../td[position()=3]", document.forms[i])[0];            amount = amount.innerHTML.replace(/[\$,]/g, "");            amount = parseInt(amount);            var name = Utils.getElementsByXPath("../../td[position()=1]/a", document.forms[i])[0];            name = name.innerHTML;            if ((amount >= boss.preferences.MinBounty) & amount <= MaxValue || (boss.stamina == boss.max_stamina && amount < MaxValue))             {                var message = document.getElementById("scriptstatus");                if (message) {                    message.innerHTML = "Hitting " + name + "...";                }                document.forms[i].submit();                return;            }        }    }    var action = new Object;    action.message = "Checking hitlist...";    action.page = "hitlist";    action.func = "hitlist_attack";    action.params = [];    Timer.start("http://apps.facebook.com/mobwars/hitlist/", "Reloading hitlist...", boss.preferences.timerdelay);}function hitlist_preferencesInterface(prefs) {    if (boss.preferences.hitlist_active == undefined) {        boss.preferences.hitlist_active = false;    }    var value = boss.preferences.hitlist_active;    if (boss.preferences.MaxBounty == undefined) {        boss.preferences.MaxBounty = 12000;    }    if (boss.preferences.MinBounty == undefined) {        boss.preferences.MinBounty = 8000;    }    var Maxvalue = boss.preferences.MaxBounty;    var Minvalue = boss.preferences.MinBounty;    var option = new Array;    option.push("<label for=\"hitlist_active\">Automatically hunt bounties:</label><br />");    if (value)     {        option.push("Yes <input type=\"radio\" name=\"hitlist_active\" value=\"1\" checked=\"checked\"/>");        option.push("No <input type=\"radio\" name=\"hitlist_active\" value=\"0\"/>");    }    else     {        option.push("Yes <input type=\"radio\" name=\"hitlist_active\" value=\"1\"/>");        option.push("No <input type=\"radio\" name=\"hitlist_active\" value=\"0\" checked=\"checked\"/>");    }    option.push("<br><label for=\"Max_Bounty\">Max Bounty ");    option.push("<input type=text\" name=\"Max_Bounty\" maxlength=\"10\" size=\"10\" ");    option.push("value=\"" + Maxvalue + "\"></label> (0 = unlimited)");    option.push("<br><label for=\"Min_Bounty\">Min Bounty ");    option.push("<input type=text\" name=\"Min_Bounty\" maxlength=\"10\" size=\"10\" ");    option.push("value=\"" + Minvalue + "\"></label>");    var div = document.createElement("div");    div.innerHTML = option.join("\n");    prefs.form.insertBefore(div, prefs.button);}function hitlist_preferencesHandler(form, boss) {    var input = form.elements.namedItem("hitlist_active");    var input2 = form.elements.namedItem("Max_Bounty").value;    var input3 = form.elements.namedItem("Min_Bounty").value;    var rvalue = false;    if (boss.preferences.hitlist_active != input.checked)     {        delete boss.actions.hitlist;        boss.preferences.hitlist_active = input.checked;        rvalue = true;    }    if (boss.preferences.MaxBounty != input2) {        boss.preferences.MaxBounty = input2;        rvalue = true;    }    if (boss.preferences.MinBounty != input3) {        boss.preferences.MinBounty = input3;        rvalue = true;    }    return rvalue;}function fbhide_preferencesInterface() {    boss.preferences.fbhide = 0;}function fbhide_preferencesHandler() {    return false;}function timerdelay_preferencesInterface(prefs) {    if (boss.preferences.timerdelay == undefined) {        boss.preferences.timerdelay = 7;    }    var value = boss.preferences.timerdelay;    var option = new Array;    option.push("<label for=\"Timer_Delay\">Timer Delay ");    option.push("<input type=\"text\" name=\"Timer_Delay\" maxlength=\"3\" size=\"3\" ");    option.push("value=\"" + value + "\"/>");    option.push(" seconds. (4 seconds minimum)</label>");    var div = document.createElement("div");    div.innerHTML = option.join("\n");    prefs.form.insertBefore(div, prefs.button);}function timerdelay_preferencesHandler(form, boss) {    var tdelay = parseInt(form.elements.namedItem("Timer_Delay").value);    if (tdelay < 4) {        tdelay = 4;    }    if (tdelay != boss.preferences.timerdelay) {        boss.preferences.timerdelay = tdelay;        return true;    }    return false;}var inventory = eval(GM_getValue("inventory", "({})"));function inventory_exec() {    boss.city_check = boss.city_check || 0;    boss.stockpile_check = boss.stockpile_check || 0;    var pages = ["jobs", "city", "stockpile"];    if (pages.indexOf(Page.c_page) != - 1)     {        var header = document.getElementById("app8743457343_content");        var divs = Utils.getElementsByXPath(".//a[contains(@name,\"item\")]", header);        for (var i = 0; i < divs.length; i++)         {            var div = Utils.getElementsByXPath("./ancestor::tr", divs[i])[0];            var result = div.innerHTML.match(/Owned: (<[^<]*>)?(\d+)/);            if (result) {                inventory[divs[i].name] = parseInt(result[2]);            }        }        GM_setValue("inventory", inventory.toSource());    }    if (boss.new_level) {        boss.city_check = 1;        boss.stockpile_check = 1;    }    switch (Page.c_page)     {        case "city":            if (boss.city_check < Page.now) {                itemlist.updateData();                boss.city_check = Page.now + 3600;            }            var total_income = 0;            var city_value = 0;            for (var item in itemlist)             {                if (itemlist[item].type != "city") {                    continue;                }                var owned = inventory[item] || 0;                total_income += owned * itemlist[item].income;                var price = itemlist[item].price  / 2;                while (owned)                 {                    if (owned >= 10) {                        city_value += (10 + owned) * price;                        owned -= 10;                    }                    else {                        city_value += (10 + owned) * owned * price  / 10;                        owned = 0;                    }                }            }            boss.total_income = total_income;            boss.city_value = city_value;            Menu.update();            break;        case "stockpile":            if (boss.stockpile_check < Page.now) {                itemlist.updateData();                boss.stockpile_check = Page.now + 3600;            }            var total_upkeep = 0;            var stockpile_value = 0;            for (var item in itemlist)             {                if (itemlist[item].type != "stockpile") {                    continue;                }                var owned = inventory[item] || 0;                total_upkeep += owned * itemlist[item].upkeep;                stockpile_value += owned * itemlist[item].price  / 2;            }            boss.total_upkeep = total_upkeep;            boss.stockpile_value = stockpile_value;            Menu.update();            break;        case "jobs":            itemlist.updateData();        default:            break;    }    var action;    if (boss.city_check == 1 && Page.c_page != "city")     {        action = new Object;        action.page = "city";        action.message = "Checking new buildings available...";        action.time = 0;        boss.actions.inventory_city = action;    }    if (boss.stockpile_check == 1 && Page.c_page != "stockpile")     {        action = new Object;        action.page = "stockpile";        action.message = "Checking new weapons available...";        action.time = 0;        boss.actions.inventory_stockpile = action;    }}function Job() {    this.payout_min = 0;    this.payout_max = 0;    this.exp = 0;    this.mobsters = 0;    this.req_items = new Object;    this.prep_items = new Object;    this.payout_items = new Object;}function int_to_dollars(num) {    num = num || 0;    var str = "";    var tmp;    while (num >= 1000)     {        var tmp = num % 1000;        if (tmp > 99) {            tmp = "" + tmp;        }        else {            if (tmp > 9) {                tmp = "0" + tmp;            }            else {                tmp = "00" + tmp;            }        }        str = "," + tmp + str;        num = Math.floor(num  / 1000);    }    str = "$" + num + str;    return str;}function dollars_to_int(str) {    if (str != undefined) {        return str.replace(/,|\$/g, "");    }    return 0;}BVL = new Object;BVL.init = function () {    this.handlers = new Array;    this.div = document.createElement("div");    this.div.className = "facebook-gm-bvl";    var css = ".facebook-gm-bvl { text-align:right; display: none; position: absolute; top: 10px; left: 20px; z-index: 99; margin-left: auto; margin-right: auto; border: 1px solid black; padding: 10px; width: 600px; height: 450px; font-family: Arial; background-color:#EEEEEE; color:#3B5998; padding:10px; font-weight:bold; }";    css += ".facebook-gm-bvl h1 { font-size: 12pt; text-align:center; background: #6D84B4; color: #FFFFFF; }";    css += ".facebook-gm-bvl table { border-width: 1px; padding: 2px; border-style: solid solid solid solid; }";    css += ".facebook-gm-bvl .td_l { text-align:left; font-size: 10pt; border-width: 1px; padding: 2px; }";    css += ".facebook-gm-bvl .td_r { text-align:right; font-size: 10pt; border-width: 1px; padding: 2px; }";    css += ".facebook-gm-bvl .td_h { font-size: 10pt; border-bottom: solid 1px black; }";    GM_addStyle(css);    this.div.innerHTML = "<h1>Bounty Victim List</h1>";    var bv_list = "";    var total_bounties = 0;    bv_list += "<div style=\"height: 400px; overflow: auto\"><table width=100% cellspacing=0 id=\"bvl_table\">";    bv_list += "<tr><th class=\"td_h\" align=\"left\">Date</th><th class=\"td_h\" align=\"left\">Opponent</th><th class=\"td_h\" align=\"right\">Bounty</th></tr>";    var when;    if (victims.length > 1)     {        for (var victim in victims)         {            if (victims[victim].split(":")[0] != "")             {                when = "NR";                if (victims[victim].split(":")[3] != undefined)                 {                    var argh = new Date(parseFloat(victims[victim].split(":")[3]));                    var year = argh.getFullYear() + "";                    var ttime = argh.toTimeString() + "";                    when = (argh.getMonth() + 1) + "/" + argh.getDate() + "/" + year.substr(2, 2) + " " + ttime.substr(0,                     8);                }                bv_list += "<tr style=\"cursor:pointer\" onclick=\"window.location.href='http://apps.facebook.com/mobwars/profile/?user_id=" + victims[victim].split(":")[1] + "';\"><td class=\"td_l\">" + when + "</td><td class=\"td_l\">" + victims[victim].split(":")[0] + "</td><td class=\"td_r\">" + victims[victim].split(":")[2] + "</td></tr>";                total_bounties += parseInt(dollars_to_int(victims[victim].split(":")[2]));            }        }    }    bv_list += "<tr id=\"bvl_table_total\"><td style=\"border-top:1px solid black;\"></td><td nowrap class=\"td_r\" style=\"border-top:1px solid black;\">TOTAL BOUNTIES COLLECTED:</td><td nowrap class=\"td_r\" style=\"border-top:1px solid black;color:green\" id=\"bvl_total_bounties\">" + int_to_dollars(total_bounties) + "</td></tr>";    bv_list += "</table></div><br />";    this.div.innerHTML += bv_list;    this.form = document.createElement("form");    this.form.action = "";    this.form.method = "";    this.form.id = "facebook-gm-bvl";    this.div.appendChild(this.form);    this.button_clear = document.createElement("button");    this.button_clear.type = "button";    this.button_clear.id = "bvl_clear";    this.button_clear.innerHTML = "CLEAR";    if (victims.length > 1) {        this.form.appendChild(this.button_clear);    }    this.button_close = document.createElement("button");    this.button_close.type = "button_close";    this.button_close.id = "bvl_close";    this.button_close.innerHTML = "CLOSE";    this.form.appendChild(this.button_close);    document.getElementsByTagName("body")[0].appendChild(this.div);    this.button_clear.addEventListener("click", this.eventListener(), true);    this.button_close.addEventListener("click", this.eventListener(), true);    this.form.addEventListener("submit", this.eventListener(), true);};BVL.pausingVictims = function () {    pausingVictims = 1;};BVL.eventListener = function () {    var bvl = this;    return function (ev)     {        if (this.id == "bvl_clear") {            GM_setValue("victims", "");            location.reload();        }        ev.preventDefault();        bvl.div.style.display = "none";        pausingVictims = 0;    };};BVL.show = function () {    var div = this.div;    return function ()     {        BVL.pausingVictims();        div.style.display = "block";        div.scrollIntoView(false);    };};var victims = GM_getValue("victims", "").split("|");BVL.init();function Joblist() {    var obj = eval(GM_getValue("jobs", "({})"));    for (var i in obj) {        this [i] = obj[i];    }}Joblist.prototype = new Object;Joblist.prototype.save = function () {    GM_setValue("jobs", this.toSource());};Joblist.prototype.updateData = function () {    if (Page.c_page == "jobs")     {        for (var job in this) {            if (typeof this [job] == "object") {                delete this [job];            }        }        var header = document.getElementById("app8743457343_content");        var divs = Utils.getElementsByClassName("rowData", header);        for (var i = 0; i < divs.length; i++)         {            var div = divs[i];            var job = new Job;            var tmp = div.getElementsByTagName("b")[0];            job.name = tmp.innerHTML;            tmp = div.innerHTML.match(/Payout:.*\$([0-9,]+) - \$([0-9,]+)/);            if (tmp)             {                job.payout_min = parseInt(tmp[1].replace(/,/g, ""));                job.payout_max = parseInt(tmp[2].replace(/,/g, ""));            }            tmp = div.innerHTML.match(/Experience: \+(\d+)/);            if (tmp) {                job.exp = parseInt(tmp[1]);            }            tmp = div.innerHTML.match(/Mobsters:\&nbsp;(\d+)/);            if (tmp) {                job.mobsters = parseInt(tmp[1]);            }            tmp = div.innerHTML.match(/Energy:\&nbsp;(\d+)/);            if (tmp) {                job.energy = parseInt(tmp[1]);            }            var items = Utils.getElementsByXPath(".//a[contains(@href,\"#item\")]", div);            for (var j = 0; j < items.length; j++)             {                tmp = items[j].href;                tmp = tmp.match(/(jobs|stockpile|city)\/#(item_\d+)/);                var item_id = tmp[2];                tmp = items[j].nextSibling;                if (tmp.tagName == "SPAN" && (tmp = tmp.innerHTML.match(/\((use |\+)?(\d+)(%)?\)/)))                 {                    if (tmp[1] == "use ") {                        job.prep_items[item_id] = parseInt(tmp[2]);                    }                    else                     {                        if (tmp[1] == "+") {                            job.payout_items[item_id] = parseInt(tmp[2]);                        }                        else                         {                            if (tmp[3] == "%") {                                job.payout_items[item_id] = 1;                            }                            else {                                job.req_items[item_id] = parseInt(tmp[2]);                            }                        }                    }                }                else {                    job.req_items[item_id] = 1;                }            }            tmp = Utils.getElementsByXPath(".//input[@name=\"jobid\"]", div)[0];            this [tmp.value] = job;        }        this.save();    }};function jobs_exec() {    if (boss.job_income == "undefined") {        boss.job_income = 0;    }    var jobs = new Joblist;    if (Page.c_page == "jobs") {        jobs.updateData();    }    else     {        if (boss.new_level)         {            var action = new Object;            action.page = "jobs";            action.message = "Checking new jobs available...";            action.time = 0;            boss.actions.jobs_check = action;            return;        }    }    var jobid = boss.preferences.job;    var message;    switch (jobid)     {        case "none":            boss.job_income = 0;            Menu.update();            return;        case "payout":            jobid = jobs_selectJob(jobs, false);            if (!jobid) {                message = "You can not perform any job.";            }            break;        case "exp":            jobid = jobs_selectJob(jobs, true);            if (!jobid) {                message = "You can not perform any job.";            }            break;        default:            if (!jobs_canDoJob(jobs[jobid])) {                message = "You can not perform the job '" + jobs[jobid].name + "'";                jobid = 0;                break;            }            var prepid;            if (prepid = jobs_needPrepJob(jobs, jobid))             {                if (!jobs_canDoJob(jobs[prepid]))                 {                    message = "You can not perform the preparatory job '" + jobs[prepid].name + "' for '" + jobs[jobid].name + "'";                    jobid = 0;                    break;                }                else {                    jobs_updateIncome(jobid);                    jobid = prepid;                }            }            else {                jobs_updateIncome(jobid);            }            break;    }    if (!jobid) {        alert(message);        delete boss.actions.jobs;        boss.job_income = 0;        Menu.update();        return;    }    var action = new Object;    action.page = "jobs";    action.message = "Doing " + jobs[jobid].name + "...";    action.func = "jobs_dojob";    action.params = [jobid, jobs[jobid].name];    var delay;    boss.type == "Insomniac" ? (delay = 240) : (delay = 300);    action.time = Page.now + (jobs[jobid].energy - boss.energy) * delay;    if (boss.energy_time) {        action.time -= (action.time - boss.energy_time) % delay;    }    boss.actions.jobs = action;}function jobs_updateIncome(jobid) {    if (!jobid) {        boss.job_income = 0;        Menu.update();        return;    }    var jobratio = jobs_payRatio(jobid);    var coeff;    switch (boss.type)     {        case "Insomniac":            coeff = 15;            break;        case "Tycoon":            coeff = 10.8;            break;        default:            coeff = 12;            break;    }    if (boss.job_income != Math.floor(coeff * jobratio)) {        boss.job_income = Math.floor(coeff * jobratio);        Menu.update();    }}function jobs_canDoJob(job) {    for (var item in job.req_items) {        if (job.req_items[item] > inventory[item]) {            return false;        }    }    if (job.mobsters > boss.mobsters) {        return false;    }    if (job.energy > boss.max_energy) {        return false;    }    return true;}function jobs_needPrepJob(jobs, jobid) {    for (var item in jobs[jobid].prep_items)     {        if (jobs[jobid].prep_items[item] > inventory[item]) {            for (var id in jobs) {                if (jobs[id].payout_items[item]) {                    return id;                }            }        }    }    return 0;}function jobs_payRatio(jobid, jobs) {    if (!jobs) {        jobs = new Joblist;    }    var energy = jobs[jobid].energy + 0;    for (var item in jobs[jobid].prep_items) {        energy += jobs[jobid].prep_items[item] * itemlist[item].energy_per_unit;    }    energy = (jobs[jobid].payout_min + jobs[jobid].payout_max)  / energy;    return energy  / 2;}function jobs_selectJob(jobs, exp) {    var pay_ratio = 0;    var exp_ratio = 0;    var jobid = 0;    var payed_job = 0;    var tmpid;    var energy;    for (tmpid in jobs)     {        if (!jobs[tmpid].name) {            continue;        }        var tmpexp_ratio = 0 + jobs[tmpid].exp  / jobs[tmpid].energy;        var tmppay_ratio = jobs_payRatio(tmpid, jobs);        if (exp)         {            if (tmpexp_ratio < exp_ratio || (tmpexp_ratio == exp_ratio && tmppay_ratio < pay_ratio)) {                continue;            }        }        else         {            if (tmppay_ratio < pay_ratio || (tmppay_ratio == pay_ratio && tmpexp_ratio < exp_ratio)) {                continue;            }        }        if (!jobs_canDoJob(jobs[tmpid])) {            continue;        }        var prepid;        if (prepid = jobs_needPrepJob(jobs, tmpid)) {            if (!jobs_canDoJob(jobs[prepid])) {                continue;            }            else {                jobid = prepid;            }        }        else {            jobid = tmpid;        }        payed_job = tmpid;        pay_ratio = tmppay_ratio;        exp_ratio = tmpexp_ratio;    }    jobs_updateIncome(payed_job);    return jobid;}function jobs_dojob(params, timer) {    timer = timer || 5;    boss.next_pay = 0;    var submit = Utils.getElementsByXPath("//input[@name=\"jobid\" and @value=\"" + params[0] + "\"]/../input[@type=\"submit\"]");    Timer.start(submit[0], "Doing " + params[1] + "...", timer);}function jobs_preferencesInterface(prefs) {    if (boss.preferences.job == undefined) {        boss.preferences.job = "none";    }    var jobs = new Joblist;    var div = document.createElement("div");    div.innerHTML = "<label for=\"joblist\">Job to perform: </label>";    var select = document.createElement("select");    var option;    select.name = "joblist";    option = "<option value=\"none\"";    if (boss.preferences.job == "none") {        option += " selected=\"selected\"";    }    option += ">None</option><option value=\"payout\"";    if (boss.preferences.job == "payout") {        option += " selected=\"selected\"";    }    option += ">Best payout/energy</option><option value=\"exp\"";    if (boss.preferences.job == "exp") {        option += " selected=\"selected\"";    }    option += ">Best experience/energy</option>";    select.innerHTML = option;    for (var job in jobs)     {        if (jobs[job].name)         {            option = document.createElement("option");            option.value = job;            if (boss.preferences.job == option.value) {                option.selected = true;            }            option.innerHTML = jobs[job].name;            select.appendChild(option);        }    }    div.appendChild(select);    prefs.form.insertBefore(div, prefs.button);}function jobs_preferencesHandler(form, boss) {    var jobid;    var select = form.elements.namedItem("joblist");    jobid = select.options[select.selectedIndex].value;    if (jobid != boss.preferences.job) {        delete boss.actions.jobs;        boss.preferences.job = jobid;        return true;    }    return false;}function WithDrawal_Calc() {    var currentCash = document.forms[2].elements.namedItem("deposit_amount").value;    var withdrawInput = document.forms[1].elements.namedItem("withdraw_amount");    var keyUpHandler = function ()     {        var i, isDigit;        var desiredValue = this.value;        if (!isNaN(desiredValue)) {            withdrawInput.value = Math.max(0, desiredValue - currentCash);        }    };    var input = document.createElement("input");    input.setAttribute("type", "text");    input.style.marginBottom = "2px";    input.addEventListener("keyup", keyUpHandler, true);    var label = document.createElement("label");    label.innerHTML = "Desired Cash Total: ";    label.style.marginLeft = input.style.marginBottom;    label.style.marginBottom = input.style.marginBottom;    label.style.fontWeight = "normal";    label.style.color = "white";    var bankDiv = document.getElementById("app8743457343_content");    bankDiv.appendChild(label);    bankDiv.appendChild(input);}function bank_exec() {    var multiplier = 1;    if (boss.next_pay == undefined) {        boss.next_pay = 0;    }    if (boss.bank_cash == undefined) {        boss.bank_cash = 0;    }    var next_pay = boss.next_pay;    switch (Page.c_page)     {        case "bank":            var balance = Utils.getElementsByClassName("myBalance")[0];            if (balance)             {                var amount = balance.innerHTML.match(/\$([0-9,]+)/)[1];                amount = amount.replace(/,/g, "");                boss.bank_cash = parseInt(amount);                Menu.update();            }            WithDrawal_Calc();            break;        case "city":            var earnings = Utils.getElementsByClassName("earnings")[0];            if (earnings)             {                var time = earnings.innerHTML.match(/Next paid in: (\d+) minute/)[1];                boss.next_pay = Page.now + 60 * (parseInt(time) + 1);            }            else {                boss.next_pay = Page.now + 3600;            }            break;        case "hospital":            var header = document.getElementById("app8743457343_content");            header = header.getElementsByTagName("span");            if (header.length)             {                header = header[header.length - 1];                header = header.innerHTML.replace(/[\$,]/g, "");                header = parseInt(header);                if (header) {                    boss.bank_cash = header;                }                Menu.update();            }            break;        default:            break;    }    if (!boss.bank_cash) {        multiplier = 10;    }    if (!boss.preferences.bank_active) {        return;    }    if (boss.actions.bank || boss.actions.bank_checkpay) {        return;    }    if (next_pay < Page.now && boss.cash > 1000 * multiplier)     {        var action = new Object;        action.message = "Going to the bank...";        action.page = "bank";        action.func = "bank_deposit";        action.params = [];        action.time = 0;        boss.actions.bank = action;    }    else     {        var action = new Object;        action.message = "Waiting for next payroll...";        action.page = "city";        action.time = boss.next_pay;        boss.actions.bank_checkdelay = action;    }}function bank_deposit(params, timer) {    var submit = Utils.getElementsByXPath("//input[@value=\"Deposit\" or @value=\"Open Account\"]")[0];    var amount = submit.parentNode.elements.namedItem("deposit_amount");    amount.value = boss.cash;    Timer.start(submit, "Depositing $" + boss.cash + " into the bank...", timer);}function bank_withdraw(params, timer) {    var amount = params;    if (document.getElementsByName("withdraw_amount")[0] != null)     {        var submit = Utils.getElementsByXPath("//input[@value=\"Withdraw\"]")[0];        document.getElementsByName("withdraw_amount")[0].value = amount;        Timer.start(submit, "Withdrawing $" + amount + " from the bank...", 5);    }}function bank_preferencesInterface(prefs) {    if (boss.preferences.bank_active == undefined) {        boss.preferences.bank_active = false;    }    var value = boss.preferences.bank_active;    var option = new Array;    option.push("<label for=\"bank_active\">Automatically deposit your money to the bank</label><br />");    if (value)     {        option.push("Yes <input type=\"radio\" name=\"bank_active\" value=\"1\" checked=\"checked\"/>");        option.push("No <input type=\"radio\" name=\"bank_active\" value=\"0\"/>");    }    else     {        option.push("Yes <input type=\"radio\" name=\"bank_active\" value=\"1\"/>");        option.push("No <input type=\"radio\" name=\"bank_active\" value=\"0\" checked=\"checked\"/>");    }    var div = document.createElement("div");    div.innerHTML = option.join("\n");    prefs.form.insertBefore(div, prefs.button);}function bank_preferencesHandler(form, boss) {    var input = form.elements.namedItem("bank_active");    if (boss.preferences.bank_active != input.checked)     {        delete boss.actions.bank;        delete boss.actions.bank_checkdelay;        boss.preferences.bank_active = input.checked;        return true;    }    return false;}function hospital_exec() {    if (boss.heal_cost == undefined) {        boss.heal_cost = 0;    }    var can_heal = true;    if (Page.c_page == "hospital") {        if (!hospital_updateData()) {            delete boss.actions.hospital;            can_heal = false;        }    }    if (can_heal && boss.health * 100 < boss.max_health * boss.preferences.heal_limit && boss.bank_cash > boss.heal_cost)     {        var action = new Object;        action.message = "Healing...";        action.page = "hospital";        action.func = "hospital_heal";        action.params = [];        action.time = 0;        boss.actions.hospital = action;    }}function hospital_updateData() {    if (Page.c_page == "hospital")     {        var el = Utils.getElementsByXPath("//input[@type=\"submit\"]")[0];        if (el)         {            el = el.value.replace(/,/g, "");            el = parseInt(el.match(/\d+/)[0]);            boss.heal_cost = el;            return true;        }        else {            return false;        }    }}funct ion hospital_heal(params, timer) {    var submit = Utils.getElementsByXPath("//input[@name=\"action\" and @value=\"heal\"]/../input[@type=\"submit\"]")[0];    if (submit) {        Timer.start(submit, "Healing for $" + boss.heal_cost + "...", timer);    }}function hospital_preferencesInterface(prefs) {    if (boss.preferences.heal_limit == undefined) {        boss.preferences.heal_limit = 0;    }    if (boss.preferences.heal_limit >= 60) {        boss.preferences.heal_limit = 60;    }    var value = boss.preferences.heal_limit;    var option = new Array;    option.push("<label for=\"heal_limit\">Heal your boss when weaker than ");    option.push("<input type=\"text\" name=\"heal_limit\" maxlength=\"3\" size=\"3\" ");    option.push("value=\"" + value + "\"/>");    option.push("% of max health (0 to disable, 60% max)</label>");    var div = document.createElement("div");    div.innerHTML = option.join("\n");    prefs.form.insertBefore(div, prefs.button);}function hospital_preferencesHandler(form, boss) {    var input = form.elements.namedItem("heal_limit");    input = parseInt(input.value);    if (boss.preferences.heal_limit != input)     {        delete boss.actions.hospital;        if (input >= 0 && input <= 100) {            boss.preferences.heal_limit = input;        }        return true;    }    return false;}function autoCityBuy_preferencesInterface(prefs) { }function autoCityBuy_preferencesHandler(form, boss) { }function orientation_preferencesInterface(prefs) {    if (boss.preferences.orientation == undefined) {        boss.preferences.orientation = 0;    }    var value = boss.preferences.orientation;    var option = new Array;    option.push("<label for=\"orientation\">Ad window horizontal or vertical?</label><br />");    if (value)     {        option.push("Vertical <input type=\"radio\" name=\"orientation\" value=\"1\" checked=\"checked\"/>");        option.push("Horizontal <input type=\"radio\" name=\"orientation\" value=\"0\"/>");    }    else     {        option.push("Vertical <input type=\"radio\" name=\"orientation\" value=\"1\"/>");        option.push("Horizontal <input type=\"radio\" name=\"orientation\" value=\"0\" checked=\"checked\"/>");    }    if (boss.preferences.adjust == undefined) {        boss.preferences.adjust = 0;    }    value = boss.preferences.adjust;    option.push("<label for=\"adjust\"><br>Adjust main screen position to avoid anything being hidden?</label><br />");    if (value)     {        option.push("Yes <input type=\"radio\" name=\"adjust\" value=\"1\" checked=\"checked\"/>");        option.push("No <input type=\"radio\" name=\"adjust\" value=\"0\"/>");    }    else     {        option.push("Yes <input type=\"radio\" name=\"adjust\" value=\"1\"/>");        option.push("No <input type=\"radio\" name=\"adjust\" value=\"0\" checked=\"checked\"/>");    }    if (boss.preferences.statdisp == undefined) {        boss.preferences.statdisp = 0;    }    value = boss.preferences.statdisp;    option.push("<label for=\"statdisp\"><br>Display mob status? (basically just for diagnostics at this time)</label><br />");    if (value)     {        option.push("Yes <input type=\"radio\" name=\"statdisp\" value=\"1\" checked=\"checked\"/>");        option.push("No <input type=\"radio\" name=\"statdisp\" value=\"0\"/>");    }    else     {        option.push("Yes <input type=\"radio\" name=\"statdisp\" value=\"1\"/>");        option.push("No <input type=\"radio\" name=\"statdisp\" value=\"0\" checked=\"checked\"/>");    }    var div = document.createElement("div");    div.innerHTML = option.join("\n");    prefs.form.insertBefore(div, prefs.button);}function orientation_preferencesHandler(form, boss) {    var input = form.elements.namedItem("orientation");    var response = false;    if (boss.preferences.orientation != input.checked) {        boss.preferences.orientation = input.checked;        response = true;    }    input = form.elements.namedItem("adjust");    if (boss.preferences.adjust != input.checked) {        boss.preferences.adjust = input.checked;        response = true;    }    input = form.elements.namedItem("statdisp");    if (boss.preferences.statdisp != input.checked) {        boss.preferences.statdisp = input.checked;        response = true;    }    return response;}function placement_preferencesInterface(prefs) {    if (boss.preferences.placement == undefined) {        boss.preferences.placement = 0;    }    var value = boss.preferences.placement;    var option = new Array;    option.push("<label for=\"placement\">Status window on the side, or on top? (currently does NOT function)</label><br />");    if (value)     {        option.push("Top <input type=\"radio\" name=\"placement\" value=\"1\" checked=\"checked\"/>");        option.push("Side <input type=\"radio\" name=\"placement\" value=\"0\"/>");    }    else     {        option.push("Top <input type=\"radio\" name=\"placement\" value=\"1\"/>");        option.push("Side <input type=\"radio\" name=\"placement\" value=\"0\" checked=\"checked\"/>");    }    var div = document.createElement("div");    div.innerHTML = option.join("\n");    prefs.form.insertBefore(div, prefs.button);}function placement_preferencesHandler(form, boss) {    var input = form.elements.namedItem("placement");    if (boss.preferences.placement != input.checked) {        boss.preferences.placement = input.checked;        return true;    }    return false;}function FightHelp() {    function xpath(query)     {        return document.evaluate(query, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);    }    function log(message) { }    window.addEventListener("load", function (e)     {        var lobjCurrentBossRow, lstrCurrentBoss, lstrRegEx, lobjRegExResult;        var lobjFoundBossLevel, lintBossLevel, lintMyBossLevel;        var lintMobSize, lintMyMobSize;        var lintBossLevelDifference, lintMobSizeDifference;        var lintAcceptableMobSizeForStrongerBosses;        var lintMaxMobSize;        var lintFivePercent, lintThreePercent;        var lobjBossRows = xpath("//div[@id='app8743457343_content']/table/tbody/tr");        var lobjBossNamesAndLevels = xpath("//div[@id='app8743457343_content']/table/tbody/tr/td[1]");        var lobjMobSizes = xpath("//div[@id='app8743457343_content']/table/tbody/tr/td[2]");        var lstrLevelDiv = xpath("//table[@id='app8743457343_statusMenu']/tbody/tr/td[6]/div").snapshotItem(0).innerHTML;        lstrRegEx = /Level:[ ]*([0-9]+)/;        lobjRegExResult = lstrLevelDiv.match(lstrRegEx);        lintMyBossLevel = + lobjRegExResult[1];        var lstrMyMobSize = xpath("//div[@id='app8743457343_header']/div/a[1]").snapshotItem(0).innerHTML;        lstrRegEx = /\(([0-9]+)\)/;        lobjRegExResult = lstrMyMobSize.match(lstrRegEx);        lintMyMobSize = + lobjRegExResult[1];        lintFivePercent = Math.ceil(0.05 * lintMyMobSize);        lintThreePercent = Math.ceil(0.03 * lintMyMobSize);        for (var i = 0; i < lobjBossNamesAndLevels.snapshotLength; i++)         {            lstrCurrentBoss = lobjBossNamesAndLevels.snapshotItem(i).innerHTML;            lstrRegEx = /, Level ([0-9]+)/;            lobjRegExResult = lstrCurrentBoss.match(lstrRegEx);            if (lobjRegExResult)             {                lintMobSize = + lobjMobSizes.snapshotItem(i).innerHTML;                lintBossLevel = + lobjRegExResult[1];                lintBossLevelDifference = lintMyBossLevel - lintBossLevel;                lintMobSizeDifference = lintMyMobSize - lintMobSize;                log("Boss #" + i + ", level=" + lintBossLevel + ", mob size=" + lintMobSize + ", level diff=" + lintBossLevelDifference + ", mob size diff=" + lintMobSizeDifference);                lobjCurrentBossRow = lobjBossRows.snapshotItem(i);                if (lintBossLevelDifference > 1)                 {                    if (lintMobSizeDifference >= 0)                     {                        log(" My boss is same/stronger, their mob is smaller");                        lobjCurrentBossRow.style.color = "green";                    }                    if (Math.abs(lintMobSizeDifference) < lintFivePercent)                     {                        log(" My boss is stronger, acceptable mob size is " + (lintMyMobSize - lintFivePercent) + "-" + (lintMyMobSize + lintFivePercent));                        lobjCurrentBossRow.style.color = "white";                    }                }                if (lintBossLevelDifference < 1)                 {                    lintAcceptableMobSizeForStrongerBosses = lintMyMobSize - lintThreePercent * Math.abs(lintBossLevelDifference);                    log(" Acceptable mob size=" + lintAcceptableMobSizeForStrongerBosses);                    if (lintMobSize <= lintAcceptableMobSizeForStrongerBosses) {                        lobjCurrentBossRow.style.color = "yellow";                    }                    else {                        lobjCurrentBossRow.style.color = "red";                    }                }                lintMaxMobSize = (lintBossLevel < 50) ? 500 : ((lintBossLevel - 50) * 2) + 500;                log("max mob size for level=" + lintBossLevel + " is " + lintMaxMobSize);                var lobjSpanMaxMobSize = document.createElement("span");                lobjSpanMaxMobSize.innerHTML = "/" + lintMaxMobSize;                lobjMobSizes.snapshotItem(i).appendChild(lobjSpanMaxMobSize);                if (lintMaxMobSize > lintMobSize)                 {                    lobjRegExResult = lstrCurrentBoss.match(/user_id=([0-9]+)/);                    if (lobjRegExResult)                     {                        var lobjSpan = document.createElement("span");                        lobjSpan.innerHTML = " [<a href='http://www.facebook.com/addfriend.php?id=" + lobjRegExResult[1] + "' target='_blank'>Add Facebook Friend</a>]";                        lobjBossNamesAndLevels.snapshotItem(i).appendChild(lobjSpan);                    }                }            }        }    }, false);}function datadisplay_exec() {    switch (Page.c_page)     {        case "city":            datadisplay_ROR();        case "stockpile":            var result = Utils.getElementsByXPath("//form[contains(@action,\"do.php\")]/select");            for (var i = 0; i < result.length; i++)             {                var input = document.createElement("input");                input.name = "qty";                input.type = "text";                input.setAttribute("maxlength", "3");                input.setAttribute("size", "3");                input.value = result[i].options[0].value;                result[i].parentNode.insertBefore(input, result[i]);                result[i].parentNode.removeChild(result[i]);            }            if (Page.c_page == "city") {                break;            }        case "fight":            FightHelp();            if (!itemlist.item_14) {                break;            }            var selection = datadisplay_getFightItems();            var attack = datadisplay_getFightPower("attack", selection);            var defense = datadisplay_getFightPower("defense", selection);            var data = new Array;            var header = document.getElementById("app8743457343_content");            header = header.getElementsByTagName("h1")[0];            header.innerHTML += "<br />";            var span = document.createElement("span");            span.className = "earnings";            data.push("(");            data.push("Attack strength: " + attack);            data.push(", ");            data.push("Defense strength: " + defense);            if (Page.c_page == "stockpile")             {                var attack_up = datadisplay_getUpgrade(selection, "attack");                data.push("<br />");                data.push("Best attack upgrade: ");                switch (attack_up[0])                 {                    case 0:                        data.push("N/A");                        break;                    case 1:                        data.push("1 " + itemlist[attack_up[1]].name + " at " + Math.floor(attack_up[2]) + "$/point");                        break;                    default:                        data.push(attack_up[0] + " " + itemlist[attack_up[1]].name + "s at " + Math.floor(attack_up[2]) + "$/point");                        break;                }                var defense_up = datadisplay_getUpgrade(selection, "defense");                data.push("<br />");                data.push("Best defense upgrade: ");                switch (defense_up[0])                 {                    case 0:                        data.push("N/A");                        break;                    case 1:                        data.push("1 " + itemlist[defense_up[1]].name + " at " + Math.floor(defense_up[2]) + "$/point");                        break;                    default:                        data.push(defense_up[0] + " " + itemlist[defense_up[1]].name + "s at " + Math.floor(defense_up[2]) + "$/point");                        break;                }                var total_up = datadisplay_getUpgrade(selection, "total");                data.push("<br/>");                data.push("Best attack/defense upgrade: ");                switch (total_up[0])                 {                    case 0:                        data.push("N/A");                        break;                    case 1:                        data.push("1 " + itemlist[total_up[1]].name + " at " + Math.floor(total_up[2]) + "$/point");                        break;                    default:                        data.push(total_up[0] + " " + itemlist[total_up[1]].name + "s at " + Math.floor(total_up[2]) + "$/point");                        break;                }                var str = datadisplay_getUnused(selection);                if (str.length) {                    data.push("<br />");                    data.push("Unused items: ");                    data.push(str);                }            }            else             {                var size = datadisplay_getMaxMobSize(attack);                data.push(", ");                data.push("Max mob size: " + size);            }            data.push(")");            if (Page.c_page == "fight")             {                data.push("<br>These are <font color=\"yellow\">GUESS</font>timates - <font size=\"-1\" face=\"Times\">Weapons, attack strength, etc., that you and the enemy have are NOT factored in.</font><br><font color=\"green\"> You will probably win.<font color=\"white\"> You should win.<font color=\"yellow\"> You could win.<font color=\"red\"> Probably not.");            }            span.innerHTML = data.join("");            header.appendChild(span);        default:            break;    }}function hitListUser(url, timer) {    if (window.location.href != url)     {        var action = new Object;        action.message = "Hitlisting user...";        action.page = "hitlist";        action.func = "hitListUser";        action.params = url;        action.time = 0;        boss.actions.hitlistUser = action;        boss.save();        window.location.href = url;    }    else     {        var cost = document.getElementsByName("bounty")[0].value;        if (boss.cash < cost) {            hitListCurrentUser();        }        else {            Utils.getElementsByXPath("//form[contains(@action,\"do.php\")]")[0].submit();        }    }}function hitListCurrentUser() {    if (boss.actions.bank_withdraw) {        delete boss.actions.bank_withdraw;    }    if (boss.actions.hitlistUser) {        delete boss.actions.hitlistUser;    }    var cost = document.getElementsByName("bounty")[0].value;    if (boss.cash < cost)     {        if ((cost - boss.cash) > boss.bank_cash) {            return;        }        var action = new Object;        action.message = "Going to bank...";        action.page = "bank";        action.func = "bank_withdraw";        action.params = cost - boss.cash;        action.time = 0;        boss.actions.bank_withdraw = action;        var action2 = new Object;        action2.message = "Hitlisting user...";        action2.page = "bank";        action2.func = "hitListUser";        action2.params = window.location.href;        action2.time = 1;        boss.actions.hitlistUserNav = action2;        boss.save();        Timer.start("http://apps.facebook.com/mobwars/bank/", "Going to bank...", 3);    }    else {        hitlistUser(window.location.href, null);    }}function datadisplay_getFightItems() {    var items;    var selection = new Object;    var types = ["weapon", "armor", "vehicle"];    for (var type = 0; type < types.length; type++)     {        var mobsters = boss.mobsters + 1;        var items_left = true;        items = new Object;        for (var i in inventory)         {            if (!inventory[i] || !itemlist[i] || itemlist[i].type != "stockpile" || itemlist[i].stocktype != types[type]) {                continue;            }            if (!itemlist[i].attack && !itemlist[i].defense) {                continue;            }            items[i] = inventory[i];        }        while (mobsters && items.toSource() != "({})")         {            var max_price = 0, item = undefined, best;            for (item in items)             {                if (itemlist[item].price < max_price) {                    continue;                }                max_price = itemlist[item].price;                best = item;            }            var qty = Math.min(mobsters, items[best]);            selection[best] = qty;            mobsters -= qty;            delete items[best];        }    }    return selection;}function datadisplay_getFightPower(str, selection) {    var result = 0;    if (str != "attack" && str != "defense") {        return;    }    str == "attack" ? (result = boss.attack_strength * (boss.mobsters + 1)) : (result = boss.defense_strength * (boss.mobsters + 1));    var item;    for (item in selection) {        result += itemlist[item][str] * selection[item];    }    return result;}function datadisplay_getMaxMobSize(attack_strength) {    var types = ["weapon", "armor", "vehicle"];    var result = 1 + 3 * (boss.level - 1);    for (var type = 0; type < types.length; type++)     {        var max_price = 0, max_defense = 0;        for (var i in itemlist)         {            if (itemlist[i].type != "stockpile" || itemlist[i].stocktype != types[type]) {                continue;            }            if (itemlist[i].price > max_price && itemlist[i].defense != 0) {                max_price = itemlist[i].price;                max_defense = itemlist[i].defense;            }        }        result += max_defense;    }    return Math.floor(attack_strength  / result);}function datadisplay_ROR() {    var income = boss.total_income + boss.job_income - boss.total_upkeep;    for (var item in itemlist)     {        if (itemlist[item].type != "city") {            continue;        }        var depends = itemlist[item].depends;        if (depends.length) {            depends = itemlist[depends].price;        }        else {            depends = 0;        }        var total_price = depends + Math.floor(itemlist[item].price * (10 + inventory[item])  / 10);        var roi = Math.floor(100000 * itemlist[item].income  / total_price);        roi = roi  / 1000;        var td = Utils.getElementsByXPath("//a[@name=\"" + item + "\"]/../../td[position() = 2]")[0];        var str = "<br/>ROR: " + roi;        var len = str.length;        while (len < 16) {            str += "&nbsp;";            len++;        }        var inflaction = 100 * (11 + inventory[item])  / (10 + inventory[item]) - 100;        var turns_inflaction = Math.ceil(inflaction  / roi);        var turns_purchase = Math.ceil(total_price  / income);        var best_qty = 1;        if (turns_purchase <= turns_inflaction) {            best_qty = 10;        }        if (best_qty == 1 && (boss.cash + boss.bank_cash) >= total_price) {            best_qty = Math.floor((boss.cash + boss.bank_cash)  / total_price);        }        var input = Utils.getElementsByXPath("..//select[@name=\"qty\"]", td)[0];        input.options[0].value = best_qty;        total_price = best_qty * Math.floor(itemlist[item].price * (10 + inventory[item])  / 10);        if (itemlist[item].depends.length)         {            depends = itemlist[item].depends;            var am;            best_qty - inventory[depends] >= 0 ? (am = best_qty - inventory[depends]) : (am = 0);            total_price += am * itemlist[depends].price;        }        total_price -= boss.cash + boss.bank_cash;        turns_purchase = Math.ceil(total_price  / income);        if (turns_purchase < 0) {            turns_purchase = 0;        }        str += "Turns left: " + turns_purchase;        var span = document.createElement("span");        span.innerHTML = str;        td.appendChild(span);    }}function datadisplay_getUpgrade(selection, type) {    if (type != "attack" && type != "defense" && type != "total") {        throw new TypeError;    }    var other;    type == "attack" ? (other = "defense") : (other = "attack");    var types = ["weapon", "armor", "vehicle"];    var result = [0, "item_14", Infinity];    for (var i = 0; i < types.length; i++)     {        var left = boss.mobsters + 1;        var power = Infinity, otherpower = Infinity, amount = 0, least;        for (var item in selection)         {            if (!itemlist[item]) {                continue;            }            if (itemlist[item].stocktype != types[i]) {                continue;            }            left -= selection[item];            if (type == "total" && itemlist[item].attack + itemlist[item].defense < power)             {                power = itemlist[item].attack + itemlist[item].defense;                amount = selection[item];                least = item;            }            else             {                if (itemlist[item][type] < power || itemlist[item][type] == power && itemlist[item][other] < otherpower)                 {                    power = itemlist[item][type];                    otherpower = itemlist[item][other];                    amount = selection[item];                    least = item;                }            }        }        if (left) {            power = 0;            amount = left;            least = undefined;        }        var best = undefined, ratio = Infinity;        for (var item in itemlist)         {            if (itemlist[item].type != "stockpile" || itemlist[item].stocktype != types[i]) {                continue;            }            if (least && itemlist[item].price < itemlist[least].price) {                continue;            }            var tmpratio;            if (type == "total") {                tmpratio = itemlist[item].attack + itemlist[item].defense - power;            }            else {                tmpratio = itemlist[item][type] - power;            }            if (tmpratio > 0) {                tmpratio = itemlist[item].price  / tmpratio;            }            else {                continue;            }            if (tmpratio < ratio) {                ratio = tmpratio;                best = item;            }        }        if (!best) {            continue;        }        if (ratio < result[2]) {            result[0] = amount;            result[1] = best;            result[2] = ratio;        }    }    return result;}function datadisplay_getUnused(used) {    var res = new Array;    var amount;    for (var item in itemlist)     {        if (itemlist[item].type != "stockpile") {            continue;        }        if (used[item] == undefined) {            used[item] = 0;        }        if (amount = inventory[item] - used[item]) {            res.push(amount + " " + itemlist[item].name + (amount == 1 ? "" : "s"));        }    }    return res.join(", ");}function HitListToggle() {    return function ()     {        if (boss.preferences.hitlist_active == false) {            boss.preferences.hitlist_active = true;        }        else {            boss.preferences.hitlist_active = false;        }        boss.save();        location.reload();    };}Fights = new Object;var fightlist = GM_getValue("fightlist", "").split("|");Fights.init = function () {    this.handlers = new Array;    this.div = document.createElement("div");    this.div.className = "facebook-gm-fights";    var css = ".facebook-gm-fights { text-align:right; display: none; position: absolute; top: 10px; left: 10px; z-index: 99; margin-left: auto; margin-right: auto; border: 1px solid black; padding: 10px; width: 600px; height: 450px; font-family: Arial; background-color:#EEEEEE; color:#3B5998; padding:10px; font-weight:bold; }";    css += ".facebook-gm-fights h1 { font-size: 12pt; text-align:center; background: #6D84B4; color: #FFFFFF; }";    css += ".facebook-gm-fights table { border-width: 1px; padding: 2px; border-style: solid solid solid solid; }";    css += ".facebook-gm-fights .td_l { text-align:left; font-size: 10pt; border-width: 1px; padding: 2px; }";    css += ".facebook-gm-fights .td_r { text-align:right; font-size: 10pt; border-width: 1px; padding: 2px; }";    css += ".facebook-gm-fights .td_h { font-size: 10pt; border-bottom: solid 1px black; }";    GM_addStyle(css);};Fights.pausingFights = function () {    pausingFights = 1;};Fights.build = function () {    this.div.innerHTML = "<h1>Fight List</h1>";    if (boss.preferences.fsort == undefined) {        boss.preferences.fsort = 0;    }    var HLc = "#3B5998";    var fdatec = "#3B5998";    var fwinsc = "#3B5998";    var flossesc = "#3B5998";    var Experiencec = "#3B5998";    var HSRc = "#3B5998";    var trewardc = "#3B5998";    switch (boss.preferences.fsort + "")     {        case "0":            fwinsc = "green";            break;        case "1":            fdatec = "green";            break;        case "2":            flossesc = "green";            break;        case "3":            trewardc = "green";            break;        case "4":            HSRc = "green";            break;        case "5":            HLc = "green";            break;        case "6":            Experiencec = "green";            break;        default:            break;    }    fightlist.sort(function (a, b)     {        return sorting(a, b);    });    var fight_list = "";    var total_reward = 0;    fight_list += "<div style=\"height: 400px; overflow: auto\"><table width=100% style=\"overflow:auto\" cellspacing=0 id=\"fights_table\">";    fight_list += "<tr><th align=\"left\" class=\"td_h\" id=\"HL\"><a><font color=\"" + HLc + "\">HL</font></a></th><th align=\"left\" class=\"td_h\" id=\"fdate\"><a><font color=\"" + fdatec + "\">Date</font></a></th><th align=\"left\" class=\"td_h\">Opponent</th><th align=\"right\" class=\"td_h\" id=\"fwins\"><a><font color=\"" + fwinsc + "\">Wins</font></a></th><th align=\"right\" class=\"td_h\" id=\"flosses\"><a><font color=\"" + flossesc + "\">Loss</font></a></th><th align=\"right\" class=\"td_h\" id=\"Experience\"><a><font color=\"" + Experiencec + "\">Exp</font></a></th><th align=\"right\" class=\"td_h\" id=\"HSR\"><a><font color=\"" + HSRc + "\">HSR</font></a></th><th align=\"right\" class=\"td_h\" id=\"treward\"><a><font color=\"" + trewardc + "\">Total Reward</font></a></th></tr>";    var when;    if (fightlist.length > 1)     {        for (var victim in fightlist)         {            if (fightlist[victim].split(":")[0] != "")             {                fight_list += "<tr style=\"cursor:pointer\" onclick=\"window.location.href='http://apps.facebook.com/mobwars/profile/?user_id=" + fightlist[victim].split(":")[1] + "';\">";                if (parseInt(fightlist[victim].split(":")[6]) == 1) {                    fight_list += "<td>**</td>";                }                else {                    fight_list += "<td></td>";                }                when = "NR";                if (fightlist[victim].split(":")[8] != undefined)                 {                    var argh = new Date(parseFloat(fightlist[victim].split(":")[8]));                    var year = argh.getFullYear() + "";                    var ttime = argh.toTimeString() + "";                    when = (argh.getMonth() + 1) + "/" + argh.getDate() + "/" + year.substr(2, 2) + " " + ttime.substr(0,                     8);                }                fight_list += "<td class=\"td_l\">" + when + "</td><td class=\"td_l\">" + fightlist[victim].split(":")[0] + "</td>";                fight_list += "<td class=\"td_r\">";                if (fightlist[victim].split(":")[3] > fightlist[victim].split(":")[5])                 {                    fight_list += "<font color=\"green\">" + fightlist[victim].split(":")[3] + "</font></td><td class=\"td_r\">";                }                else                 {                    fight_list += fightlist[victim].split(":")[3] + "</td><td class=\"td_r\"><font color=\"red\">";                }                fight_list += fightlist[victim].split(":")[5] + "</font></td>";                var experience = 0;                if (fightlist[victim].split(":")[7] != undefined)                 {                    experience = parseInt(fightlist[victim].split(":")[7])  / (parseInt(fightlist[victim].split(":")[3]) + parseInt(fightlist[victim].split(":")[5]));                }                fight_list += "<td class=\"td_r\">" + Math.floor(experience) + "</td>";                fight_list += "<td class=\"td_r\">" + int_to_dollars(fightlist[victim].split(":")[2]) + "</td><td class=\"td_r\">" + int_to_dollars(fightlist[victim].split(":")[4]) + "</td></tr>";                total_reward += parseInt(dollars_to_int(fightlist[victim].split(":")[4]));            }        }    }    fight_list += "<tr id=\"fights_table_total\"><td style=\"border-top:1px solid black;\"></td><td style=\"border-top:1px solid black;\"></td><td nowrap class=\"td_r\" style=\"border-top:1px solid black;\">TOTAL REWARDS COLLECTED:</td><td style=\"border-top:1px solid black;\"></td><td style=\"border-top:1px solid black;\"></td><td style=\"border-top:1px solid black;\"></td><td style=\"border-top:1px solid black;\"></td><td nowrap class=\"td_r\" style=\"border-top:1px solid black;color:green\" id=\"fights_total_reward\">" + int_to_dollars(total_reward) + "</td></tr>";    fight_list += "</table></div><br>";    this.div.innerHTML += fight_list;    this.form = document.createElement("form");    this.form.action = "";    this.form.method = "";    this.form.id = "facebook-gm-fights";    this.div.appendChild(this.form);    this.button_clear = document.createElement("button");    this.button_clear.type = "button";    this.button_clear.id = "fights_clear";    this.button_clear.innerHTML = "CLEAR";    if (fightlist.length > 1) {        this.form.appendChild(this.button_clear);    }    this.button_close = document.createElement("button");    this.button_close.type = "button_close";    this.button_close.id = "fights_close";    this.button_close.innerHTML = "CLOSE";    this.form.appendChild(this.button_close);    document.getElementsByTagName("body")[0].appendChild(this.div);    this.button_clear.addEventListener("click", this.eventListener(), true);    this.button_close.addEventListener("click", this.eventListener(), true);    this.form.addEventListener("submit", this.eventListener(), true);    var button = document.getElementById("treward");    button.addEventListener("click", function ()     {        boss.preferences.fsort = 3;        boss.save();        Fights.build();    }, false);    button = document.getElementById("fdate");    button.addEventListener("click", function ()     {        boss.preferences.fsort = 1;        boss.save();        Fights.build();    }, false);    button = document.getElementById("flosses");    button.addEventListener("click", function ()     {        boss.preferences.fsort = 2;        boss.save();        Fights.build();    }, false);    button = document.getElementById("fwins");    button.addEventListener("click", function ()     {        boss.preferences.fsort = 0;        boss.save();        Fights.build();    }, false);    button = document.getElementById("HL");    button.addEventListener("click", function ()     {        boss.preferences.fsort = 5;        boss.save();        Fights.build();    }, false);    button = document.getElementById("HSR");    button.addEventListener("click", function ()     {        boss.preferences.fsort = 4;        boss.save();        Fights.build();    }, false);    button = document.getElementById("Experience");    button.addEventListener("click", function ()     {        boss.preferences.fsort = 6;        boss.save();        Fights.build();    }, false);};Fights.eventListener = function () {    var fight = this;    return function (ev)     {        if (this.id == "fights_clear") {            GM_setValue("fightlist", "");            location.reload();        }        ev.preventDefault();        fight.div.style.display = "none";        pausingFights = 0;    };};Fights.show = function () {    var div = this.div;    return function ()     {        Fights.pausingFights();        Fights.build();        div.style.display = "block";        div.scrollIntoView(false);    };};function BankD() {    return function ()     {        if (boss.cash == undefined) {            boss.cash = 0;        }        if (boss.bank_cash == undefined) {            boss.bank_cash = 0;        }        if (boss.cash > 0 && boss.bank_cash >= 2000 || boss.cash >= 10000)         {            var action = new Object;            action.page = "bank";            if (Page.c_page != action.page)             {                action.message = "Going to the bank...";                action.page = "bank";                action.func = "bank_deposit";                action.params = [];                action.time = 0;                boss.actions.bank = action;                boss.save();                var url = "http://apps.facebook.com/mobwars/" + action.page + "/";                if (action.url_params) {                    url += "?" + action.url_params;                }                Timer.start(url, action.message, 0);                return;            }            bank_deposit(action.params, 0);        }        else         {            var span = document.getElementById("scriptstatus");            if (boss.cash == 0)             {                span.innerHTML = "You do not have any cash to deposit.";                span = document.getElementById("scripttimer");                span.innerHTML = "";            }            else             {                span.innerHTML = "You need $10,000 or more to open a bank account.";                span = document.getElementById("scripttimer");                span.innerHTML = "";            }        }    };}function HealFast() {    return function ()     {        var action = new Object;        action.page = "hospital";        if (Page.c_page != action.page)         {            action.message = "Healing...";            action.page = "hospital";            action.func = "hospital_heal";            action.params = [];            action.time = 0;            boss.actions.hospital = action;            boss.save();            var url = "http://apps.facebook.com/mobwars/" + action.page + "/";            if (action.url_params) {                url += "?" + action.url_params;            }            Timer.start(url, action.message, 0);            return;        }        if (hospital_updateData()) {            hospital_heal(action.params, 0);        }        else         {            var span = document.getElementById("scriptstatus");            if (boss.bank_cash > boss.heal_cost)             {                span.innerHTML = "You can not heal any further.";                span = document.getElementById("scripttimer");                span.innerHTML = "<br>";            }            else             {                span.innerHTML = "You have insufficient bank cash available.";                span = document.getElementById("scripttimer");                span.innerHTML = "";            }        }    };}function CheckFight() {    var vi = "";    var vn = "Unknown";    if (document.body.innerHTML.match(/You won /) && (Page.c_page == "profile" || Page.c_page == "hitlist"))     {        if (Page.c_page == "profile")         {            var killing = document.getElementById("app8743457343_content").getElementsByTagName("A")[0];            if (killing)             {                vi = killing.href.split("target_id=")[1];                vn = document.getElementById("app8743457343_content").getElementsByTagName("h1")[0];                vn = vn.innerHTML.split(",")[0];                vn = vn.split("\"")[1];            }        }        else         {            var killing = document.getElementById("app8743457343_content").getElementsByTagName("div")[3];            if (killing) {                vn = killing.innerHTML.split("'s")[0];            }        }        killing = document.getElementById("app8743457343_content").getElementsByTagName("div")[4];        vb = killing.innerHTML.match(/(\$[0-9,]+)/)[0];        var experience = parseInt(killing.innerHTML.split("$")[1].split("and")[1].split("experience")[0]);        var times = 1;        var ltimes = 0;        vb = dollars_to_int(vb);        var tamount = vb;        var newfighter = 1;        var tlost = 0;        var fromhitlist = 0;        if (Page.c_page == "hitlist") {            fromhitlist = 1;        }        var fdate = new Date;        var ftime = fdate.getTime();        for (var fighter in fightlist)         {            if (fightlist[fighter].split(":")[0] != "")             {                if (vn == fightlist[fighter].split(":")[0])                 {                    if (fightlist[fighter].split(":")[7] == undefined) {                        var pexp = 0;                    }                    else {                        var pexp = parseInt(fightlist[fighter].split(":")[7]);                    }                    pexp += experience;                    times = parseInt(fightlist[fighter].split(":")[3]) + parseInt(times);                    tamount = parseInt(fightlist[fighter].split(":")[4]) + parseInt(tamount);                    tlost = parseInt(fightlist[fighter].split(":")[5]);                    if (vb < parseInt(fightlist[fighter].split(":")[2])) {                        vb = parseInt(fightlist[fighter].split(":")[2]);                    }                    fightlist[fighter] = vn + ":" + vi + ":" + vb + ":" + times + ":" + tamount + ":" + tlost + ":" + parseInt(fightlist[fighter].split(":")[6]) + ":" + pexp + ":" + ftime;                    newfighter = 0;                }            }        }        if (newfighter)         {            fightlist.push(vn + ":" + vi + ":" + vb + ":" + times + ":" + tamount + ":" + tlost + ":" + fromhitlist + ":" + experience + ":" + ftime);        }        fightlist.sort(function (a, b)         {            return sorting(a, b);        });        GM_setValue("fightlist", fightlist.join("|"));    }    else     {        if (document.body.innerHTML.match(/You lost /) && (Page.c_page == "profile" || Page.c_page == "hitlist"))         {            if (Page.c_page == "profile")             {                var killing = document.getElementById("app8743457343_content").getElementsByTagName("A")[0];                if (killing)                 {                    vi = killing.href.split("target_id=")[1];                    vn = document.getElementById("app8743457343_content").getElementsByTagName("h1")[0];                    vn = vn.innerHTML.split(",")[0];                    vn = vn.split("\"")[1];                }            }            else             {                var killing = document.getElementById("app8743457343_content").getElementsByTagName("div")[3];                if (killing) {                    vn = killing.innerHTML.split("'s")[0];                }            }            var times = 0;            var ltimes = 0;            var tamount = 0;            var newfighter = 1;            var tlost = 1;            var fromhitlist = 0;            if (Page.c_page == "hitlist") {                fromhitlist = 1;            }            var fdate = new Date;            var ftime = fdate.getTime();            for (var fighter in fightlist)             {                if (fightlist[fighter].split(":")[0] != "")                 {                    if (vn == fightlist[fighter].split(":")[0])                     {                        if (fightlist[fighter].split(":")[7] == undefined) {                            var experience = 0;                        }                        else {                            var experience = parseInt(fightlist[fighter].split(":")[7]);                        }                        times = parseInt(fightlist[fighter].split(":")[3]);                        tamount = parseInt(fightlist[fighter].split(":")[4]);                        tlost = parseInt(fightlist[fighter].split(":")[5]) + 1;                        fightlist[fighter] = vn + ":" + vi + ":" + parseInt(fightlist[fighter].split(":")[2]) + ":" + times + ":" + tamount + ":" + tlost + ":" + parseInt(fightlist[fighter].split(":")[6]) + ":" + experience + ":" + ftime;                        newfighter = 0;                    }                }            }            if (newfighter)             {                fightlist.push(vn + ":" + vi + ":0:" + times + ":" + tamount + ":" + tlost + ":" + fromhitlist + ":0:" + ftime);            }            GM_setValue("fightlist", fightlist.join("|"));        }    }}function sorting(a, b) {    if (boss.preferences.fsort == undefined) {        boss.preferences.fsort = 0;    }    if (a.split(":")[0] == "") {        return - 1;    }    if (b.split(":")[0] == "") {        return 1;    }    var x = 0;    if (boss.preferences.fsort == 0) {        x = b.split(":")[3] - a.split(":")[3];        if (x == 0) {            x = b.split(":")[4] - a.split(":")[4];        }    }    if (boss.preferences.fsort == 1)     {        var btemp = 0;        var atemp = 0;        if (b.split(":")[8] != undefined) {            btemp = parseFloat(b.split(":")[8]);        }        if (a.split(":")[8] != undefined) {            atemp = parseFloat(a.split(":")[8]);        }        x = btemp - atemp;    }    if (boss.preferences.fsort == 2) {        x = b.split(":")[5] - a.split(":")[5];        if (x == 0) {            x = b.split(":")[4] - a.split(":")[4];        }    }    if (boss.preferences.fsort == 3)     {        x = dollars_to_int(b.split(":")[4]) - dollars_to_int(a.split(":")[4]);        if (x == 0) {            x = b.split(":")[7] - a.split(":")[7];        }    }    if (boss.preferences.fsort == 4)     {        x = dollars_to_int(b.split(":")[2]) - dollars_to_int(a.split(":")[2]);        if (x == 0) {            x = b.split(":")[4] - a.split(":")[4];        }    }    if (boss.preferences.fsort == 5) {        x = b.split(":")[6] - a.split(":")[6];        if (x == 0) {            x = b.split(":")[4] - a.split(":")[4];        }    }    if (boss.preferences.fsort == 6)     {        var btemp = 0;        var atemp = 0;        if (b.split(":")[7] != undefined) {            btemp = b.split(":")[7];        }        if (a.split(":")[7] != undefined) {            atemp = a.split(":")[7];        }        x = (btemp  / (b.split(":")[3] + b.split(":")[5])) - atemp  / (a.split(":")[3] + a.split(":")[5]);        if (x == 0) {            x = b.split(":")[4] - a.split(":")[4];        }    }    return x;}var boss;var itemlist;(function () {    var chat = document.getElementsByTagName("iframe");    for (var i = 0; i < chat.length; i++) {        chat[i].parentNode.removeChild(chat[i]);    }    var exception;    try {        boss = new Boss;        itemlist = new Itemlist;        boss.updateData();        Preferences.populate(this);    }    catch (ex) {        exception = ex;    }    HelpMe.init();    Fights.init();    try {        Menu.init();    }    catch (ex)     {        alert("Error while inserting the script's menu.\nLine: " + ex.lineNumber + ", error: " + ex.message);    }    A289073();    CheckFight();    if (exception)     {        var error = document.getElementById("scripterror");        error.innerHTML = "Error in module 'base' on line " + exception.lineNumber + ": " + exception.message + "<br /><br />";    }    var captcha = Utils.getElementsByClassName("cap");    if (captcha.length) {        alert("Possible Captcha Error -- Need Human attention!!");        return;    }    for (var i = 0; i < modules.length; i++)     {        if (this [modules[i] + "_exec"])         {            try {                now = Date.now();                this [modules[i] + "_exec"]();            }            catch (ex)             {                var error = document.getElementById("scripterror");                error.innerHTML = "Error in module '" + modules[i] + "' on line " + ex.lineNumber + ": " + ex.message + "<br /><br />";            }        }    }    var action = new Object;    var id;    action.time = Infinity;    var a = new Array;    for (var i in boss.actions) {        a.push(i);        if (boss.actions[i].time < action.time) {            action = boss.actions[i];            id = i;        }    }    if (Page.c_page == "hitlist")     {        if (window.location.href.indexOf("add", 0) > 0)         {            var form = Utils.getElementsByXPath("//form[contains(@action,\"do.php\")]")[0];            var link = document.createElement("a");            link.addEventListener("click", hitListCurrentUser, false);            link.innerHTML = "Withdraw money and hitlist this user.";            form.appendChild(link);        }    }    if (!id) {        boss.save();        return;    }    var timer;    if (action.time < boss.jail_delay) {        action.time = boss.jail_delay;    }    if (action.time == Infinity) {        timer = boss.preferences.timerdelay;    }    else {        timer = action.time - Page.now;    }    if (timer < 0) {        timer = 0;    }    if (Page.c_page != action.page)     {        var url = "http://apps.facebook.com/mobwars/" + action.page + "/";        if (action.url_params) {            url += "?" + action.url_params;        }        Timer.start(url, action.message, timer);        if (!action.func) {            delete boss.actions[id];        }    }    else     {        if (action.func) {            this [action.func](action.params, timer);            delete boss.actions[id];        }        else         {            var message;            timer == 10 ? (message = "Reloading page...") : (message = action.message);            var url = "http://apps.facebook.com/mobwars/" + action.page + "/";            if (action.url_params) {                url += "?" + action.url_params;            }            Timer.start(url, action.message, timer);            delete boss.actions[id];        }    }    boss.new_level = 0;    boss.save();}());