Skip to content

Instantly share code, notes, and snippets.

@nettofarah
Created August 11, 2016 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nettofarah/00dd979b8d934ea9deb56fa2791ec739 to your computer and use it in GitHub Desktop.
Save nettofarah/00dd979b8d934ea9deb56fa2791ec739 to your computer and use it in GitHub Desktop.
Chase Credit Card Running Balance
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();
}());
@nettofarah
Copy link
Author

Add this snippet as a bookmarklet to get your credit card running balance alongside your pending transactions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment