enhancement suggestion - calculate total price of missing inventory to start a job
![]() ![]() |
I always have to click each missing item and calculate in mind the needed cash in Moscow to find out how much cash i need to start a new job. So here's what I did. Maybe you could add such a feature in official version :) I use couple of my modifications, so it would be hard to post a patch here, so I'll try to describe it.
var elCells = elRows[r].getElementsByTagName("td");
for(var c=0; c<elCells.length; c++) ...
After the block if(elCells[c].className == "job_reward" && ElementCheck(elCells[c],'job reward'))I've added one more condition:
//calculating a total price of missing items to finish job
else if (elCells[c].className == "job_required_items" && ElementCheck(elCells[c],"job_required_items"))
{
//the price and number of needed stuff can be found in onclick event handler in function create_buy_item_lbox
var icons = elCells[c].getElementsByTagName("a");
var suma =0;
var price = 0, number = 0;
var regexp = /.*create_buy_item_lbox\(\".*\", *\".*\", *(\d+), *\d+, *(\d+)\).*/
for(var i=0; i<icons.length; i++)
{
if (icons[i].getAttribute("onclick").match(regexp) == null)
continue;
price = parseInt(RegExp.$1);
number = parseInt(RegExp.$2);
if (!isNaN(price) && !isNaN(number)) {
suma += price * number;
}
}
if (suma != 0 ){ //adding commas
suma = suma.toString();
var rgx = /(\d+)(\d{3})/;
while (rgx.test(suma)) {
suma = suma.replace(rgx, '$1' + ',' + '$2');
}
elCells[c].innerHTML += '<br /><div>'+suma+'</div>'
}
}
It was only tested in Moscow and probably will need some fine-tuning |
![]() ![]() |
Good idea owiec! |
![]() ![]() |
Added. It took me so long because the first time I tried it I couldn't get it to work but I figured out what I was missing. Thanks for your contribution. :)
|
![]() ![]() |
I like that it shows the cost of the items that are still red, but what does the smaller number under the experience ratio mean? |
![]() ![]() |
That was from another thread, that's the money/energy ratio for the job by Erinol |
![]() ![]() |
First of all, great job with all this, respect T1G :)
In function:
if (moneyGain != -1 && expGain != -1 && energyNeed != -1 && editContainer != null && foundRequiredItems)
{
var cashRatio = cashGain / energyNeed;
var ratio = expGain / energyNeed;
var hrElement = document.createElement('br');
var ratioElement = document.createElement('span');
var cashRatioElement = document.createElement('span');
ratioElement.textContent = ratio.toFixed(3);
ratioElement.style.color = "black";
ratioElement.style.align = "center";
cashRatioElement.textContent = "$"+cashRatio.toFixed(0);
//configurables:
var colorMin = 1.7; // lowest exp ratio painted in red
var colorMax = 2.1; //higest exp ratio - painted in green
var cashColorMin = 2000; // see exp ratio
var cashColorMax = 5000; // see exp ratio
if (ratio < colorMin) {
ratioElement.style.backgroundColor = "red";
} else if ( ratio >= colorMin && ratio <= colorMax ) {
var color = ((ratio - colorMin)/(colorMax-colorMin))*255;
colorRGB = "rgb(" + (255 - color).toFixed(0) + ',' + color.toFixed(0) + ",0)";
ratioElement.style.backgroundColor = colorRGB;
} else {
ratioElement.style.backgroundColor = "green";
}
if (cashRatio < cashColorMin) {
cashRatioElement.style.backgroundColor = "red";
} else if ( cashRatio >= cashColorMin && cashRatio <= cashColorMax ) {
var color = ((cashRatio - cashColorMin)/(cashColorMax-cashColorMin))*255;
colorRGB = "rgb(" + (255 - color).toFixed(0) + ',' + color.toFixed(0) + ",0)";
cashRatioElement.style.backgroundColor = colorRGB;
} else {
cashRatioElement.style.backgroundColor = "green";
}
editContainer.appendChild(hrElement);
editContainer.appendChild(ratioElement);
editContainer.appendChild(hrElement);
editContainer.appendChild(cashRatioElement);
editContainer = null; //not to add ratios any more
}
Like in previous case, it's kind of POC (although, works for me). Try it, it and if you like, feel free to make use of it.
|
![]() ![]() |
owiec, Tell you what: pick different colors (10% of the male population is colorblind, most of which are red/green, including yours truly) and I'll add it to the code :) Thanks,
|
![]() ![]() |
I agree with the Ratio change.
After every update, I go into my script and change all of the 100s to 10000s.elExp[h].innerHTML = "Exp (" + ((neededExp - curExp) * -1) + ") [" + Math.round(10000 * (neededExp - curExp) / userEnergy) / 10000 + "]After level 300 or so, it takes forever for the Ratio to change. Sometimes my ratio would show 2.11, but the Settle a Beef job would not level me up. It was nice to find out that my ratio was actually 2.1157 and the Settle a Beef job is only 2.1143. Doesn't sound like much, but at 3000 energy, .007 is 21 energy points, which could leave you waiting up to 2 hours to level up. Also, I take the 100s off of the Money calculation since I'm not worried about fractions of a dollar and it makes it look cleaner. var moneyResult = "" + Math.round(moneyGain / energyNeed);
|
![]() ![]() |
You will now find the following options to make updating a bit easier for you guys: var showHealInNYOnly = false;
-T1G |
![]() ![]() |
Ok, color has been implemented, with an option to turn it off. In the future I'll try to remember to turn it back on, but I may forget. Somewhere on the "todo" list is to create an options screen and save the options off, not sure when I'll have time to get to that though. Enjoy guys, thanks again for everybody's help.
|
![]() ![]() |
T1G,
|
![]() ![]() |
Hi,
if((elCells[c].className == "job_reward" || elCells[c].className == "job_reward job_no_border") && ElementCheck(elCells[c],'job reward')) else if block at line 488: else if ((elCells[c].className == "job_required_items" || elCells[c].className =="job_required_items job_no_border") && ElementCheck(elCells[c],'job required items'))
{
//calculating a total price of missing items to finish job -- By owiec
foundRequiredItems = true;
// the total price taken from div with id "popup_inner_text". There are multiple divs with this id, so it's necessary to iterate over the set of divs inside the table cell
var icons = elCells[c].getElementsByTagName("div");
var suma =0;
var price = 0, number = 0;
//var regexp = /.*create_buy_item_lbox\(\".*\", *\".*\", *(\d+), *\d+, *(\d+)\).*/
var regexp = /.*Buy.*for.*\$([0-9,]+).*/
for (var i = 0; i<icons.length; i++)
{
if ("popup_inner_text"==icons[i].getAttribute("id"))
{
GM_log(icons[i].innerHTML);
if (icons[i].innerHTML.match(regexp) == null)
continue;
price = parseInt(RegExp.$1.replace(",", ""));
GM_log(RegExp.$1);
if (!isNaN(price))
suma += price;
}
}
GM_log(suma);
if (suma != 0 ){ //adding commas
suma = suma.toString();
var rgx = /(\d+)(\d{3})/;
while (rgx.test(suma)) {
suma = suma.replace(rgx, '$1' + ',' + '$2');
}
elCells[c].innerHTML += '<br /><div>['+suma+']</div>'
}
}
line 522: else if ((elCells[c].className == "job_energy" || elCells[c].className == "job_energy job_no_border") && ElementCheck(elCells[c],'job energy')) |
![]() ![]() |
Can I request a small addition to the quick links.
elLinksDivs[p].innerHTML += ' ' + getLinkCode('R', null, myMafiaStyle, 'robbing', 'view');
It can be put anywhere in that section but it's handy to go straight to the Robbing page. Cool script, can't even begin to estimate the amount of time it's saved me!
|


