Facebook Mafia Wars Exp Remaining

By ThatOneGuy Last update Apr 24, 2010 — Installed 57,540 times.

added rate of properties

in
Subscribe to added rate of properties 10 posts, 2 voices



Juraj Petrovic Scriptwright
Hi I added function to compute rate of properties so you know which to buy (calculating price/income of property) and displaying this on property page.
 
function addRate(){
  var searchNodes;
  var totalTr;
  var listOfTr;
  var income;
  var income2;
  var nodes;
  var price;
  var xxx;
  var rate;
            
            if(!document.getElementById('done')){
            searchNodes=document.getElementsByTagName('tr');
              for(var p=0; p<searchnodes><(totalTr-p); i++){
                        nodes=listOfTr[p+i].childNodes[3];

                        if(nodes){
                          income=nodes.childNodes[3];
                          if(income)
                            income=income.childNodes[1];
                            if(income){
                             income=income.childNodes[0].nodeValue.split("$")[1].split(",");
                             income2=income[0];
                             if(income[1]!=null)
                                income2=income[0]*1000;
                             else
                                income2=income[0]*1;
                            }}
                          nodes=listOfTr[p+i].childNodes[0];
                          if(nodes){
                            income=nodes.childNodes[3];
                            if(income)
                              income=income.childNodes[0];
                              xxx=income;
                              if(income){
                                if(income=income.nodeValue.split("$")[1]){
                                  income=income.split(",");
                                  if(income[2]!=null)
                                    price=income[0]+income[1]+income[2];
                                  else if(income[1]!=null)
                                    price=income[0]+income[1];
                                  else
                                    price=income[0]*1;                                  
                                  rate=price/income2;
                                  xxx.parentNode.parentNode.innerHTML=xxx.parentNode.parentNode.innerHTML + " <br /> Rate: <strong class="\\"money\">" + rate.toFixed(1) +"</strong><strong>";
                                }
                                
                                }
                           }
                    }
                  
                  }

                }
              }

          }

}
and you have to change function nodeInserted to :
 
function nodeInserted(event) {
	DoCalcExp(event.currentTarget);
	addRate();
}
I really dont have good enough skills to doit proper way so this is how I can do it.It could be done much better and it could include price of Undeveloped Space as well , feel free to improve it :)... and want to say THANKS for your script ;)
 
ThatOneGuy Script's Author

Your code is quite broken... throwing errors left and right.

Too many brackets... that's no big deal, but then it doesn't understand this line:
for(var p=0; p<searchnodes><(totalTr-p); i++)

then, listOfTr is undefined...

I may add this on my own later, but just wanted to let you know why I wasn't putting it in my version.</searchnodes>

 
ThatOneGuy Script's Author

Ok, I re-did the code and have it working...

I also did some general speed improvements on the rest of the code... need to test out a couple more things which require me to level again) before I can post it though... keep an eye out :)

 
ThatOneGuy Script's Author

Posted...

-T1G

 
Juraj Petrovic Scriptwright

wow I am glad that you improved my code and added it to the script ;) and script is now after last update really much faster its gr8...dont take it that I dont like the script..but I made another change..for myself...so when I click any of new added links healing,upgrades I dont invoke original ajax request but I added new function so you get result only in alert box and dont have to reload most of the page ;) again it could be probably done much better if you dont like it leave it be...but just have a look , bye keep doing good work.

ps. about the errors ..obviously I forgot to write < and > as & l t ; and & g t ;

so here is whole script
changes:
var userHealthMax = -1; is again global
added clickF, handle, ajaxrequest functions and in main function I added some lines to add onclick functions and I deleted part about original onclick function.

http://userscripts.org/scripts/source/50509.use...

 
ThatOneGuy Script's Author

Looks good, I will add it to the orig code when I get a bit more time to test it.

I don't mind code changes/suggestions at all... the whole reason I wrote this script is because I wanted to enhance the interface. It's a utility to help you enjoy the game, without playing it for you. Any more suggestions then let me hear them.
-T1G

 
Juraj Petrovic Scriptwright

I got an idea, that there shouldnt be alert boxes with results but just some DIV tabs so you wouldnt have to click OK so often :) and they would disappear automatically after some time..

 
ThatOneGuy Script's Author

Done, try the latest code :)

 
Juraj Petrovic Scriptwright

gr8 man, u have bring it to the perfection :-D, I was thinking about changing those stats on screen but, u have seen my code :-D it would get really messy and I was so lazy to do it :-D

 
ThatOneGuy Script's Author

It's all good, glad you like it :)

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