Created
January 12, 2019 23:40
-
-
Save ethnt/2b06e3c00c9dbafa1870cc2246bb36b3 to your computer and use it in GitHub Desktop.
Aspiration current 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
var available = parseFloat(document.querySelector('.balance .numbers').innerHTML.replace('$', '')); | |
var pendingTransactionValues = Array.prototype.slice.call(document.querySelectorAll('.transaction-row.pending')).map(element => element.querySelector('.value .amount').innerHTML.split('$')); | |
var total = 0.0; | |
values.forEach(function (arr) { | |
var sign = arr[0]; | |
var value = parseFloat(arr[1]); | |
if (sign === "-") { | |
total += value | |
} else { | |
total -= value | |
} | |
}); | |
var currentBalance = available + total; | |
alert("Current balance: " + currentBalance) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment