Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var bidResponse;
- var lotId = document.getElementById('lotId');
- if (lotId) {
- clearInterval(inAuction);
- var inAuction = setInterval(() => {
- var inCountdown = document.querySelector('.timer-countdown-label');
- return fetch('/api.json?1570646780373&m=getLotDetails&v=1570646777453&js=1', {
- 'credentials': 'include',
- 'headers': {
- 'accept': '*/*',
- 'cache-control': 'no-cache',
- 'content-type': 'application/json',
- 'pragma': 'no-cache',
- 'sec-fetch-mode': 'cors',
- 'sec-fetch-site': 'same-origin'
- },
- 'referrerPolicy': 'no-referrer-when-downgrade',
- 'body': '{\"api\":\"catalog\",\"method\":\"getLotDetails\",\"lotId\":' + lotId.innerHTML + '}',
- 'method': 'POST',
- 'mode': 'cors'
- })
- .then(response => {
- return response.json();
- })
- .then(data => {
- let { data: { hasWinner, bidHistory } } = data;
- let timeLeft = inCountdown ? parseFloat(inCountdown.innerHTML) : null;
- if (!hasWinner) {
- if (!inCountdown) {
- bidResponse = 'waiting for countdown'
- console.log('waiting for countdown');
- completion(bidReponse);
- return;
- }
- if (timeLeft < 20) {
- let bidInput = document.getElementById('jsActiveBidInput');
- if (bidHistory[0]) {
- bidResponse = `Plaats bod, ${bidHistory[0].customer.firstName}`;
- console.log(`Plaats bod, ${bidHistory[0].customer.firstName}`);
- completion(bidReponse);
- if( bidInput ) {
- bidInput.value = bidHistory[0].customer.price + 1;
- }
- } else {
- bidResponse = 'Er is nog niet geboden, bied 1';
- console.log('Er is nog niet geboden, bied 1');
- completion(bidReponse);
- if( bidInput ) {
- bidInput.value = 1;
- }
- }
- } else if (timeLeft != NaN) {
- bidResponse = 'Nog niet binnen de tijd';
- console.log(`Nog niet binnen de tijd`);
- completion(bidReponse);
- }
- } else {
- clearInterval(inAuction);
- bidResponse = 'Bieden afgelopen';
- console.log('Bieden afgelopen');
- completion(bidReponse);
- }
- });
- }, 50);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement