Skip to content

Instantly share code, notes, and snippets.

@nickcaballero
Last active March 3, 2021 23:56
  • 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
Embed
What would you like to do?
Babylist sum of registry items
// Run this in console
[...document.querySelectorAll('.mtm')]
.map(group => [...group.querySelectorAll('.offer-price')]
.map(element => parseFloat(element.textContent.substring(1)))
.reduce((agg, value, i) => (agg + value) / (i ? 2 : 1), 0)) // Take average when product is available on multiple sites
.reduce((sum, value) => sum + value, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment