Skip to content

Instantly share code, notes, and snippets.

@sonnyksimon
Created August 29, 2022 03:31
Show Gist options
  • Save sonnyksimon/8890ec31293b1c1a29bd373fd3e89cab to your computer and use it in GitHub Desktop.
Save sonnyksimon/8890ec31293b1c1a29bd373fd3e89cab to your computer and use it in GitHub Desktop.
Calculate Google Spending from Chrome Console
// Google Activity URL: https://pay.google.com/gp/w/u/0/home/activity
// add the id `x-payments-hist` to the tbody
// containing the payments after viewing
// all records (i.e. it says "No more transactions")
let payments = [];
let rows = document.querySelectorAll("#x-payments-hist > tr");
rows.forEach(function(node) {
let r = {};
r.title = node.querySelector("td.b3-widget-table-cell-main-content").textContent;
r.value = node.querySelector("td.b3-widget-table-cell-numeric span").textContent;
r.parsed = parseFloat(r.value.split('$')[1]);
payments.push(r);
});
let totalSpending = payments.map(x => x.parsed).reduce((partialSum, a) => partialSum + a, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment