Created
August 29, 2022 03:31
-
-
Save sonnyksimon/8890ec31293b1c1a29bd373fd3e89cab to your computer and use it in GitHub Desktop.
Calculate Google Spending from Chrome Console
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
// 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