Skip to content

Instantly share code, notes, and snippets.

@ethnt
Created January 12, 2019 23:40
Show Gist options
  • Save ethnt/2b06e3c00c9dbafa1870cc2246bb36b3 to your computer and use it in GitHub Desktop.
Save ethnt/2b06e3c00c9dbafa1870cc2246bb36b3 to your computer and use it in GitHub Desktop.

Revisions

  1. ethnt created this gist Jan 12, 2019.
    20 changes: 20 additions & 0 deletions expanded.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    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)