Skip to main content

Amazon sort by price dropped by

12th October, 2022

Updated: 12th October, 2022

    const allItems = document.getElementById('g-items');
    allItems.style.display = 'flex';
    allItems.style.flexDirection = 'column';
    allItems.style.flexFlow = 'column-reverse';
    const items = allItems.querySelectorAll('li');
    [...items].forEach((item) => {
        const $priceDrop = item.querySelector('span[id^="itemPriceDrop_"]');
    	  /* Price dropped 27% */
        const priceDropText = ($priceDrop) ? $priceDrop.innerHTML.trim() : ''; 
        const r = /\d+/;
        const priceDroppedPercentage = (r.exec(priceDropText)) ? r.exec(priceDropText)[0] : 0;
        item.style.order = priceDroppedPercentage;
    })

    9c0d6d9a-a728-4233-9ab3-2c8419272cde

    Created on: 12th October, 2022

    Last updated: 12th October, 2022

    Tagged With: