Last active
April 30, 2020 17:45
-
-
Save smaharj1/374adc9d5c61c1a863bb4311e58c13c3 to your computer and use it in GitHub Desktop.
Shoprite Script that will keep flipping between pickup and delivery until you get the timeslot during covid
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
function timeout(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
let isPickup = true | |
let isBreak = false | |
const interval = setInterval(async function() { | |
let pickups = document.getElementsByClassName('fulfillmentHeader__fulfillmentOption--pickup'); | |
let deliveries = document.getElementsByClassName('fulfillmentHeader__fulfillmentOption--delivery'); | |
if (isPickup) { | |
console.log("Changing to DELIVERY tab") | |
deliveries[0].click(); | |
} | |
else { | |
console.log("Changing to PICKUP tab") | |
pickups[0].click(); | |
} | |
isPickup = !isPickup | |
console.log("Waiting for page to load") | |
await timeout(3000); | |
console.log("Page should be loaded...") | |
let timeslots = document.getElementsByClassName('timeslotPicker__timeslotButton'); | |
console.log("Checking if all tabs are sold out") | |
for(var i = 0; i < timeslots.length; i++) { | |
const content = timeslots[i].textContent; | |
if(content.trim() !== 'Sold Out') { | |
console.log("Found open timeslot", content.trim()); | |
isBreak = true; | |
window.open('https://www.youtube.com/watch?v=_MFuY-Drr70'); | |
} | |
} | |
if (isBreak) { | |
clearInterval(interval) | |
} | |
else { | |
console.log("All are sold out! :()") | |
} | |
}, 20000); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment