Skip to content

Instantly share code, notes, and snippets.

@rutger1140
Last active September 27, 2016 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rutger1140/c55c9322f2598f4a0cf3fd9a2d6a81ba to your computer and use it in GitHub Desktop.
Save rutger1140/c55c9322f2598f4a0cf3fd9a2d6a81ba to your computer and use it in GitHub Desktop.
Spotify total cost
var t = 0;
$(".receipt-price").each(function() {
// EU version - comma decimal separator
t += parseFloat($(this).text().substring(1).replace(',','.'));
// US version - dot decimal separator
// t += parseFloat($(this).text().substring(1));
});
console.log(t.toFixed(2));
@rutger1140
Copy link
Author

Want to know how much money you spend on Spotify?
Run this snippet it in your browsers console on the invoices page.

@yoeran
Copy link

yoeran commented Sep 27, 2016

The ES6 variant 😛

console.log(
  Array.from(document.querySelectorAll(".receipt-price"))
    .reduce( (total, el) => total += parseFloat(el.innerHTML.substring(1).replace(',','.')), 0)
    .toFixed(2)
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment