function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
const buy = async function () {
let totalWithVat = 0;
while (!totalWithVat) {
const resp = await fetch("https://www.proshop.fi/api/MiniBasket", {
"credentials": "include",
"headers": {
"Accept": "application/json, text/javascript, */*; q=0.01",
"Accept-Language": "fi",
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest",
"Alt-Used": "www.proshop.fi",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin"
},
"referrer": "https://www.proshop.fi/Naeytoenohjaimet",
"body": "{\"productId\":\"2958600\"}",
"method": "POST",
"mode": "cors"
});
const json = await resp.json();
totalWithVat = json.TotalWithVat;
if (totalWithVat) {
alert('GO! GO!');
window.location = 'https://www.proshop.fi/Basket';
}
await sleep(1200);
}
}
buy();