Skip to content

Instantly share code, notes, and snippets.

@hitorilabs
Last active February 2, 2024 17:27
Show Gist options
  • Save hitorilabs/020c0de15f4476a1a278e019c05972a2 to your computer and use it in GitHub Desktop.
Save hitorilabs/020c0de15f4476a1a278e019c05972a2 to your computer and use it in GitHub Desktop.
GPU_HUNTER.sh
: ${SKU:='16531651'}
: ${USER_AGENT:='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'}
read -r SHIPPING_STATUS QUANTITY <<< $(curl -s "https://www.bestbuy.ca/ecomm-api/availability/products?accept=application%2Fvnd.bestbuy.standardproduct.v1%2Bjson&postalCode=${POSTAL_CODE}&skus=${SKU}"\
-H 'accept: application/json' \
-H 'user-agent: $USER_AGENT' \
--compressed | jq -r '.availabilities[0].shipping.status, .availabilities[0].shipping.quantityRemaining')
echo "$(date '+%Y-%m-%d %H:%M:%S') - status=$SHIPPING_STATUS | quantity=$QUANTITY" >> "output.log"
tail -n 15 output.log
if [[ "$SHIPPING_STATUS" != "SoldOutOnline" ]]; then
# Action to perform when status changes, e.g., display a notification
osascript -e "on run {sku}" \
-e "tell application \"System Events\"" \
-e "display notification with title \"MAJOR BAG ALERT\" subtitle \"4090 AVAILABLE\" sound name \"Submarine\"" \
-e "end tell" \
-e "open location \"https://www.bestbuy.ca/en-ca/product/\" & sku" \
-e "end run" -- "$SKU"
fi

A simple little script that I ran on my macbook to notify me when bestbuy restocked the 4090 FE

In my personal experience, bestbuy is the only store that hasn't caused me many issues and have generally been good to me. If the link breaks, try finding the same type of endpoint and copying the curl command for the network request.

Usage

  • watch -n 10 ./alert.sh (every 10s or whatever frequency you want)
  • saves a timestamps and status in logs so you can feel bad about missing a drop
  • will open up the webpage exactly where it's specified so make sure it's the right link

requires watch, jq, curl


usage (e.g. 4080 SKU because it is always in stock)

SKU=16531650 watch -n 3 ./alert.sh

output looks like this

Every 3.0s: ./alert.sh                                                                                                       main: Tue Dec 12 22:12:50 2023

2023-12-12 22:04:21 - status=InStock | quantity=124
2023-12-12 22:04:53 - status=InStock | quantity=124
2023-12-12 22:05:04 - status=InStock | quantity=124
2023-12-12 22:05:18 - status=InStock | quantity=124
2023-12-12 22:07:13 - status=SoldOutOnline | quantity=0
2023-12-12 22:07:15 - status=SoldOutOnline | quantity=0
2023-12-12 22:07:21 - status=InStock | quantity=124
2023-12-12 22:08:28 - status=InStock | quantity=124
2023-12-12 22:09:03 - status=InStock | quantity=124
2023-12-12 22:12:07 - status=InStock | quantity=124
2023-12-12 22:12:13 - status=SoldOutOnline | quantity=0
2023-12-12 22:12:17 - status=SoldOutOnline | quantity=0
2023-12-12 22:12:23 - status=InStock | quantity=124
2023-12-12 22:12:47 - status=SoldOutOnline | quantity=0
2023-12-12 22:12:50 - status=SoldOutOnline | quantity=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment