Skip to content

Instantly share code, notes, and snippets.

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