Created
December 30, 2013 19:34
-
-
Save jeffreytgilbert/8186879 to your computer and use it in GitHub Desktop.
A little script to show the running balance on the chase cc page because they decided it's not important to keep a running balance...
This file contains hidden or 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
(function(){ | |
var amounts = document.querySelectorAll('#Posted tbody .amount'); | |
var balance = Number(document.querySelector('#AccountDetailTable .card-accountdetailcol tbody tr td:nth-child(2)').innerText.substr(1).replace(',','')); | |
var iii=0; | |
var amount = ''; | |
var element = null; | |
var elementsArray = []; | |
for(iii=0; iii < amounts.length; iii++) { | |
element = amounts[iii]; | |
amount = element.innerText; | |
if(amount.substr(0,1) === '-'){ | |
amount = amount.substr(2, amount.length-3); | |
amount = amount.replace(',',''); | |
amount = amount * -1; | |
} else { | |
amount = amount.substr(1, amount.length-2); | |
amount = amount.replace(',',''); | |
} | |
elementsArray.push({ | |
'element':element, | |
'amount':Number(amount), | |
'order':iii | |
}); | |
} | |
elementsArray.map(function(el){ | |
el.element.style.whiteSpace = 'pre'; | |
balance = Number(balance) - Number(el.amount); | |
el.element.innerHTML = '$'+el.amount.toFixed(2).toString()+' : $'+balance.toFixed(2).toString(); | |
}); | |
})(); |
Fixed "Uncaught TypeError: Cannot read property 'innerText' of null at :3:116 at :31:3" with updated selectors:
var amounts = document.querySelectorAll("#activityTableslideInActivity > tbody > tr > td.sm-aligned-right.amount.BODY > span");
var balance = Number(document.querySelector('#activityContainerslideInActivity > div.overview-activity-container.util.print-hide.print-border-none > div > div > div.col-xs-12.recon-header-container > div.current-balance-section > dl > dd:nth-child(2)').innerText.substr(1).replace(',',''));
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I run the script, here is an error:
Uncaught TypeError: Cannot read property 'innerText' of null at :3:116 at :31:3