Last active
April 8, 2019 17:31
-
-
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
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
//https://my.aliexpress.com/wishlist/wish_list_product_list.htm?¤tGroupId=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