Skip to content

Instantly share code, notes, and snippets.

@zhiboz
Created April 16, 2020 19:54
Show Gist options
  • Save zhiboz/950a8224b7db0ac14ad8c46f36634adb to your computer and use it in GitHub Desktop.
Save zhiboz/950a8224b7db0ac14ad8c46f36634adb to your computer and use it in GitHub Desktop.
Automatic delivery time finder for Costco Instacart

Costco.js - An automatic Costco delivery time finder

Usage

  1. Install Tampermonkey
  2. Install the script from GreasyFork: Link
  3. Shop!

Notes

  1. The script refreshes every 5 minutes.
  2. Try checking the console if the script doesn't seem to be running.
  3. The script will log "Loading..." and "Running..." if properly working.
// ==UserScript==
// @name Costco Delivery Time Finder
// @namespace https://www.github.com/kizjkre
// @version 1.0
// @description Automatic Costco delivery time finder
// @author Kizjkre
// @match https://sameday.costco.com/store/checkout_v3
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
// Your code here...
console.log('Loading...');
window.onload = function() {
console.log('Running...');
const error = 'No delivery times available\n\nRight now, all shoppers are busy and working hard to get to every order. Please check back later to see if delivery times are available.';
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.removedNodes.length !== 0 && mutation.target.innerText.substring(0, 5) === 'Today') {
const target = mutation.target;
const dayTab = target.children[0].children[0].children[0].children;
if (dayTab.length === 1) {
setTimeout(function() { location.reload(); }, 300000);
}
dayTab[1].click();
setTimeout(function() { document.querySelectorAll('input[name=delivery_option]')[0].parentElement.children[1].children[2].children[0].click(); }, 1000);
setTimeout(function() { document.querySelector('.rmq-28f9c13a.rmq-8e4e203').children[2].children[0].children[3].children[0].click(); }, 1000);
setTimeout(function() { document.getElementsByClassName('rmq-3774bba5')[7].children[0].children[0].children[0].click(); }, 1000);
} else if (mutation.addedNodes.length !== 0 && mutation.target.innerText === error) setTimeout(function() { location.reload(); }, 300000);
});
});
observer.observe(document.querySelector('body'), { childList: true, subtree: true });
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment