Created
August 11, 2016 05:45
-
-
Save nettofarah/00dd979b8d934ea9deb56fa2791ec739 to your computer and use it in GitHub Desktop.
Chase Credit Card Running Balance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:void(function() { | |
var $ = window.jQuery; | |
function floatValue(element) { | |
var text = $(element).text().trim().replace(",", "").replace("$", ""); | |
return parseFloat(text); | |
} | |
function updateCurrentBalance() { | |
var balanceElement = jQuery('div[data-attr="CREDIT_CARD_ACCOUNT.accountCurrentBalance"]'); | |
var balance = floatValue(balanceElement); | |
var pendingValueElement = jQuery('.pendingcharge-value'); | |
var pending = floatValue(pendingValueElement); | |
var realTotal = balance + pending; | |
var headerElement = jQuery('.accountSummary-dataLabel.HEADERLABEL:first'); | |
var currentElement = jQuery('.dataValue.HEADERNUMSTR:first'); | |
currentElement.text("$"+realTotal.toString()); | |
headerElement.text('Current + Pending'); | |
}; | |
function calculateRunningBalance() { | |
var rows = Array.from($('#pendingTrans tr').find('td:last')).reverse(); | |
var currentBalanceElement = $('div[data-attr="CREDIT_CARD_ACCOUNT.accountCurrentBalance"]'); | |
var initialBalance = floatValue(currentBalanceElement); | |
console.log('Initial Balance: ', initialBalance); | |
$('.running').empty(); | |
rows.reduce(function(currentBalance, row) { | |
var transactionValue = floatValue(row); | |
var runningBalance = currentBalance + transactionValue; | |
$(row).append(' <span style="font-size: 11px; display: block;" class="running">($'+ runningBalance.toFixed(2) + ')</span>'); | |
return runningBalance; | |
}, initialBalance); | |
}; | |
updateCurrentBalance(); | |
calculateRunningBalance(); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this snippet as a bookmarklet to get your credit card running balance alongside your pending transactions