Skip to content

Instantly share code, notes, and snippets.

@peacefulseeker
Last active April 8, 2019 17:31
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 peacefulseeker/eb90d398e699830a63b66b935a01a068 to your computer and use it in GitHub Desktop.
Save peacefulseeker/eb90d398e699830a63b66b935a01a068 to your computer and use it in GitHub Desktop.
Calculate minimum and maximum expected total cart price on AliExpress my wishes page
//https://my.aliexpress.com/wishlist/wish_list_product_list.htm?&currentGroupId=0&page=1
const priceNodes = document.querySelectorAll('.price');
const pricesCollection = Array.from(priceNodes);
var prices = pricesCollection.reduce((total, prc) => {
const prices = prc.textContent.trim().replace(/[^\d,-]/g, '').replace(/,/g, '.').split('-');
const lowestPrice = Number(prices[0]);
const highestPrice = Number(prices[1]) || lowestPrice;
return {
min: Number((total.min + lowestPrice).toFixed(2)),
max: Number((total.max + highestPrice).toFixed(2)),
}
}, {min: 0, max: 0});
console.log(prices)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment