Skip to content

Instantly share code, notes, and snippets.

@natalan
Last active April 14, 2020 14:54
Show Gist options
  • Save natalan/ecfd79099db249098cf19a30f1aa2ba4 to your computer and use it in GitHub Desktop.
Save natalan/ecfd79099db249098cf19a30f1aa2ba4 to your computer and use it in GitHub Desktop.
Prime Now pickup slot finder (UserScript to be used with https://www.tampermonkey.net/ in Chrome)
// ==UserScript==
// @name Prime Now pickup slot finder
// @namespace AZ
// @version 1.0
// @description Find available slots for Whole Foods order pickup
// @author Andrei Zharov
// @match https://primenow.amazon.com/checkout/enter-checkout*
// @grant GM_notification
// ==/UserScript==
// settings
const delay = 30; // In seconds
const alertAudioUrl = "https://soundbible.com/grab.php?id=2154&type=mp3";
const alertDurationSec = 5;
(async() => {
console.log("Whole Foods pickup: ", new Date());
let noPickupAvailable = false;
try {
noPickupAvailable = document.getElementById("delivery-slot-form").innerText === "No pickup times available";
} catch (err) {
console.error(err);
}
if (noPickupAvailable) {
console.log(`No pickup/delivery, refreshing in ${delay} seconds.`);
setTimeout(() => {
console.log("Refreshing");
window.location.reload();
}, delay * 1000);
} else {
GM_notification({
text: "Pickup slots available. Order now",
title: "Prime Now pickup slot finder",
timeout: 5000,
onclick() { window.focus(); }
});
console.log("Pickup/delivery slots found, playing alert");
const alertSound = document.createElement("audio");
alertSound.src = alertAudioUrl;
alertSound.preload = "auto";
alertSound.loop = true;
alertSound.play();
alert("Found slot. Order now!");
setTimeout(() => { alertSound.loop = false; }, alertDurationSec * 1000);
}
})();
@natalan
Copy link
Author

natalan commented Apr 14, 2020

Add items to your cart and then go to checkout page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment