Skip to content

Instantly share code, notes, and snippets.

@ahirschberg
Last active February 23, 2020 19:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ahirschberg/1b3f2f33bd3954a3b4f38e261b222775 to your computer and use it in GitHub Desktop.
Creates a {Name: Sum} mapping of all the transactions on a Barclays bank statement page for a desired month
(month_desired => {
let store = {}
let transactions = document.querySelectorAll('.panel');
for (let t of transactions) {
let name = t.querySelector('.description').innerText;
let amt = parseInt(t.querySelector('.amount').innerText.replace(/[^0-9.]/g, ''));
let date = t.querySelector('.date').innerText;
if (date.toLowerCase().substring(0,3) != month_desired) {
console.log("Skipping", date);
} else {
let prev_amt = store[name] || 0;
store[name] = prev_amt + amt;
}
}
console.log(store);
})("dec")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment