Refreshing a sold-out page every morning is a chore a bot does better. This one reads the page every hour, notices when the shop starts offering it again, and sends you one email at that moment, not one every hour.
Find the words that change
Open the product page. Find text that only shows up when the item is available, such as Add to cart, or only when it isn't, such as Out of stock.
Now check the shop sends that text in the page itself: right-click the page, choose View page source, and search for it with Ctrl+F (Cmd+F on a Mac). If it isn't there, the shop builds the page with JavaScript and this simple version won't see it; use the agent version instead.
Start a new script
Go to script.google.com, click New project and name it Stock alert.
Paste the script
Replace everything in the editor with this. Put the product address and the words you found on the first two lines:
const PAGE_URL = 'https://example.com/product'; const LOOK_FOR = 'Add to cart'; // text that appears only when it's in stock function checkStock() { const html = UrlFetchApp.fetch(PAGE_URL, { muteHttpExceptions: true }).getContentText(); const inStock = html.indexOf(LOOK_FOR) !== -1; const props = PropertiesService.getScriptProperties(); const wasInStock = props.getProperty('inStock') === 'yes'; if (inStock && !wasInStock) { MailApp.sendEmail( Session.getActiveUser().getEmail(), 'Back in stock', 'The page now says "' + LOOK_FOR + '":\n' + PAGE_URL, ); } props.setProperty('inStock', inStock ? 'yes' : 'no'); }Run it once and allow access
Click Run and allow the script to fetch web pages and send email as you. If the item is already in stock you'll get an email right away, which proves it works.
Check every hour
Open Triggers (the clock icon), click Add trigger, choose
checkStock, Time-driven, Hour timer, Every hour, and save. Delete the trigger once you've bought the thing.
Paste this into Claude Code, Codex or any coding agent. The agent writes and sets up the automation, then tells you what to click.
I want an email when a product comes back in stock. Here is the page: <PASTE THE PRODUCT URL> 1. Fetch the page and work out how it shows availability. If the stock status is in the HTML, find a reliable phrase. If it is loaded by JavaScript, find the JSON or API request the page uses for availability (often a product .json endpoint or embedded JSON-LD "availability" field) and use that instead. 2. Write a Google Apps Script that checks it, remembers the last state in Script Properties, and emails me only when it changes from unavailable to available. 3. Add an hourly time-driven trigger, and a function that removes it. 4. Tell me exactly where to paste it on script.google.com and what to click.
You still need to
- Give the agent the product page address.
- Sign in to Google and click Allow when the script first runs.
Things that trip people up
- Many shops build their pages with JavaScript, so the words you see aren't in the page source. Check the source first (step 1) or use the agent version.
- Some shops block automated visits. If the script gets an error page, it can't watch that shop.
- Pick words that only appear when the item is buyable. "In stock" can also appear in "Not in stock".