Skip to content

Commit

Permalink
Fix crime and car success tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
Baelor committed Jul 4, 2020
1 parent 91408ce commit 6de5eac
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ob.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -1553,23 +1553,25 @@ if (document.getElementById('game_container') !== null) {
}

// car
var carAttempts = parseInt($('table.thinline:eq(5)>tbody>tr:eq(4)>td:last').text().replace(',', ''), 10);
var carSelector = $('table.thinline:eq(5)>tbody>tr>td:contains("Car nicking attempts"), table.thinline:eq(5)>tbody>tr>td:contains("Autojatpogingen")').parent().find('td:last');
var carAttempts = parseInt(carSelector.text().replace(',', ''), 10);
var successCars = parseInt(getV('carSuccess', 0), 10);
if (successCars >= 1) {
if (carSelector.length === 1 && successCars >= 1) {
var successRate = (successCars / carAttempts) * 100;
var earned = getV('carMoney', 0);
var newText = '<tr><td><b>Car nicking success</b></td><td>' + successCars + ' (' + successRate.toFixed(2) + '%, $' + commafy(earned) + ')</td></tr>';
$('table.thinline:eq(5)>tbody>tr:eq(3)').after(newText);
carSelector.parent().after(newText);
}

// crime stats
var crimeAttempts = parseInt($('table.thinline:eq(5)>tbody>tr:eq(3)>td:last').text().replace(',', ''), 10);
var crimeSelector = $('table.thinline:eq(5)>tbody>tr>td:contains("Crime attempts"), table.thinline:eq(5)>tbody>tr>td:contains("Misdaadpogingen")').parent().find('td:last');
var crimeAttempts = parseInt(crimeSelector.text().replace(',', ''), 10);
var successCrimes = parseInt(getV('crimeSuccess', 0), 10);
if (successCrimes >= 1) {
if (crimeSelector.length === 1 && successCrimes >= 1) {
var successRate = (successCrimes / crimeAttempts) * 100;
var earned = getV('crimeMoney', 0);
var newText = '<tr><td><b>Crime success</b></td><td>' + successCrimes + ' (' + successRate.toFixed(2) + '%, $' + commafy(earned) + ')</td></tr>';
$('table.thinline:eq(5)>tbody>tr:eq(2)').after(newText);
crimeSelector.parent().after(newText);
}

// Visual improvement
Expand Down

0 comments on commit 6de5eac

Please sign in to comment.