Skip to content

Instantly share code, notes, and snippets.

@rchasman
Created December 30, 2019 07:43
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 rchasman/2dc018d3015babf5fdf21d311422cdf6 to your computer and use it in GitHub Desktop.
Save rchasman/2dc018d3015babf5fdf21d311422cdf6 to your computer and use it in GitHub Desktop.
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