Facebook MobWars Helper

By Piotr P. Karwasz Last update Dec 23, 2008 — Installed 91,001 times.

Mobwars Page Layout Changed

in
Subscribe to Mobwars Page Layout Changed 19 posts, 7 voices



J. M. Coward User

I found I was getting an error from the script after the devs changed the mobwars Jobs page to add the new job (they also added a typo to their code, but moving on). I traced it to the itemslist.updateData function, where I saw that the regular expression for getting the Experience and Energy for a job no longer worked.

I opted for quick and dirty, 'cause I'm late for work; my solution:

Replace result = str.match(/\(\+(\d+)\).*Energy: (\d+)/); with
result = str.match(/Experience:.*\+(\d+).*Energy: (\d+)/);

Optimize away.

 
Kemm User

J.M,

I have also noticed the new jobs, properties and weapons available on the new page. I'm using Piotr release 12/23/08 script, and the script displays "resting" when its on the jobs page. Which version of this mod did you put in? I did search and replace the code you suggested but it's does not solve my problem. do you have any other suggestions?

Thanks!!

 
J. M. Coward User

Kemm,
This appears to be caused by the latest Greasemonkey release. I experienced the same issues on my work machine on both scripts that I run (one is built for a different app using the FMWH code). It seems Greasemonkey doesn't like treating objects like arrays anymore. I've downloaded both Greasemonkey releases (the latest and the one we were running prior to that), and I'll diff 'em to see what changed, but it appears to have nothing to do with the Mobwars script.

 
Kemm User

something weird is going on.. whenever I turn on the mobwars helper script, I see the browser contacting www.freecause.com for some info or something, and it's extremely slow to load the page. when I turn the Greasemonkey off and refresh the page, it doesn't contact www.freecause.com at all, and the page loads faster.. am I being hijacked?

 
J. M. Coward User

Kemm,
Unless your script has the word freecause in it, I don't see how it could be trying to connect to that site. Are you using any other GM scripts?

 
VoiceX User

@kemm: have you got installed the mobwars toolbar? i think, that she is contacting freecause.com

my helper script is also resting in jobs page. if my new job "Shipping Docks Raid" causes the problem? On other pages, helper says "Doing Shipping Docks Raid". But when it changes to jobs page, it change to "resting".

 
Icefalkon User

What's happening to Kemm is happening to me also...no idea why it's contacting that page.

 
TheDruidsKeeper Scriptwright

The mob wars toolbar is from freecause.com. Occasionally some images from there are pulled to the page for sponsors / toolbar advertisement, but greasemonkey wont be contacting that site unless you have a script that specifically does it (like the one I posted to get the godfather posts).

@VoiceX: Check your error console to see if anything useful is posted there from the script when you are on the jobs page.

 
VoiceX User

@Druid: where 2 find the error console?

 
TheDruidsKeeper Scriptwright

In firefox go to Tools -> Error Console

Or hit ctrl+shift+J

 
J. M. Coward User

Ok, so I note the layout changed again. I can't tell what the major differences are yet, but for now, it looks like the mob size moved to a parenthetical on top of the Mob button on the nav. So I did the following in the Boss.prototype.updateData method:

I replaced:


  var header = document.getElementById('app8743457343_header');
  var str = header.getElementsByTagName('a')[1].innerHTML;

with:

var header = document.getElementById('app8743457343_navMenu');
header = Utils.getElementsByXPath('//a[@href="http://apps.facebook.com/mobwars/mob/"]/span', header)[0];
var str = header.innerHTML;

As always, this is brittle as hell and could stand some refactoring.

 
J. M. Coward User

And yet another change to jobs & stockpiles. I've got my jobs working again using the following replacement to the item ID regex in Joblist.prototype.updateData:


tmp = tmp.match(/(jobs|stockpile|city)\/#(item_\d+)/);
var item_id = tmp[2];

replaced with:


tmp = tmp.match(/(jobs|stockpile|city)\/(\?show_type\=)?(weapon|power_item|vehicle)?#(item_\d+)/);
var item_id = tmp[4];

I've noticed that the weapon/power_item/vehicle and pawn shop are new stockpile areas. I'll see if I can figure something out there, but in the meantime, that fixed my auto-jobs functionality.

 
TheDruidsKeeper Scriptwright

@J. M. Coward,

You will also need to update the Itemlist.prototype.updateData function since the different items are split to separate pages.

Personally, I changed the beginning of that function to be like this:

Itemlist.prototype.updateData = function() {
  var pages = ['stockpile', 'jobs', 'city'];
  if (pages.indexOf(Page.c_page) != -1) {
	var pageStocktype;
	if (Page.c_page == 'stockpile'){
		if (document.location.href.indexOf("show_type=") > -1)
			pageStocktype = document.location.href.substring(document.location.href.indexOf("show_type=") + 10)
		else if (document.location.href.indexOf("pawn_shop") == -1)
			pageStocktype = "weapon";
		if (document.location.href.indexOf("power_item") > -1) pageStocktype = "weapon";
	}
    for (var item in this) {
      if (this[item].type != Page.c_page) continue;
	  if (this[item].stocktype != pageStocktype) continue;
      delete this[item];
    }
    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 = divs[i].parentNode.parentNode;
      var item_id = divs[i].name;
      var item;
      switch(Page.c_page) {
        case 'stockpile':
          item = new Stockitem();
          item.stocktype = pageStocktype;
          break;

 
J. M. Coward User

That's a good start. I'm finding that my upkeep value is incorrect, however, so I'm tracing through using upkeep to see why it isn't being calculated correctly.

 
TheDruidsKeeper Scriptwright

maybe try using this in function inventory_exec instead of calculating upkeep per owned item:

if (document.getElementsByClassName("upkeep").length > 0)
		boss.total_upkeep = document.getElementsByClassName("upkeep")[0].innerHTML.match(/[\d,]+/)[0].replace(/,/g, "");

 
fart man User

looks good. how do i apply, what do i replace? u guys rule

 
fart man User

J.M. COWARD i undertsnad your directions, im applying the fix now. ill let ya know how it works for me. is this fix for fbmw* or fbmw++?

 
J. M. Coward User

japes, you're not going to like the answer to that. I've been clinging to the original script, old schooler that I am. I've glanced at the new stuff in both those scripts, but since I prefer to handle fighting myself, and I agreed with Piotr's original insistence in not having an auto-hitlister, I've been updating his script since October. I've added some tweaks of my own (I occasionally sell undeveloped land, so I want the max number of properties I can sell in the sell box to be 10 instead of 1, &c.).

Thus, I'm unfamiliar with specifics of how those scripts work. I *am* considering a switch to take advantage of the up-to-date Greasemonkey features. I ported my modified version of Piotr's script to a largely incompatible FB app, so I'll have to make sure that I can port either the ++ or the * script before making the switch final.

 
newb5000 Scriptwright

New jobs weren't showing up for me in the preferences screen (I just unlocked a new job by reaching a new level).

I had to replace the following:

      /* Drops */
      tmp = div.innerHTML.match(/(\d+\%)/);

with this:
      /* Drops */
      tmp = div.innerHTML.match(/(\(\d+\%\))/);

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel