Skip to content

Instantly share code, notes, and snippets.

@peacefulseeker
Last active April 8, 2019 17:31
Show Gist options
  • Select an option

  • Save peacefulseeker/eb90d398e699830a63b66b935a01a068 to your computer and use it in GitHub Desktop.

Select an option

Save peacefulseeker/eb90d398e699830a63b66b935a01a068 to your computer and use it in GitHub Desktop.

Revisions

  1. Alexey Vorobyov renamed this gist Apr 8, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. Alexey Vorobyov revised this gist Apr 8, 2019. No changes.
  3. Alexey Vorobyov created this gist Apr 8, 2019.
    18 changes: 18 additions & 0 deletions countPrices.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    //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)