-
-
Save rchasman/2dc018d3015babf5fdf21d311422cdf6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const quantityInput = document.getElementsByClassName('product-quantity-input')[0]; | |
const unitPriceElement = document.getElementsByClassName('unit-price item')[0].getElementsByClassName('value')[0]; | |
const totalPriceElement = document.getElementsByClassName('subtotal item')[0].getElementsByClassName('value')[0]; | |
const setQty = val => { | |
const e = document.createEvent('HTMLEvents'); | |
e.initEvent('change', false, false); | |
quantityInput.dispatchEvent(e); | |
quantityInput.value = val; | |
} | |
const currUnitPrice = () => Number(unitPriceElement.textContent.replace("$", "")) || 0; | |
const currTotalPrice = () => Number(totalPriceElement.textContent.replace("$", "")) || 0; | |
const NUMBER_RANGE = [...Array(2976).keys()]; | |
const getNewPriceMap = x => | |
new Promise(resolve => { | |
setQty(x + 25); | |
setTimeout(() => { | |
resolve({ [currUnitPrice()]: currTotalPrice() }) | |
}, 20000) | |
}); | |
async function allPrices() { | |
return NUMBER_RANGE.map(getNewPriceMap); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment