Last active
April 14, 2020 14:54
-
-
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)
This file contains 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
// ==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); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add items to your cart and then go to checkout page