Instead of paying a monthly fee for a powerful change detection service, here I outline a quick and easy method to alert you to the presence or absence of a regex string specifically in JSON data using just a free Chrome browser extension. As a bonus, you don’t need to set (spoof) headers or set cookies, and you can even be logged in to a site. You will likely avoid reCAPTCHA as well. Plus you likely won’t tread over the TOS as you aren’t using a third-party service.
I’ll go through two case studies where I actually use this technique:
- BestBuy Item In-Stock Notification – Know when an item is in-stock
- Expired Domain Availability Notification – Know when an expired domain is available
With Auto Refresh Plus you can set an interval to reload the current web page tab (thus your headers and cookies are persisted) and be alerted to a regex string that is either absent or present. This alert can be music that plays continuously until you stop it. JSON Viewer just makes JSON pretty to look at so it is optional.
Case Study 1: BestBuy Item In-Stock Notification
BestBuy had a Boxing Week sale on some memory cards I had my eye on. The problem is that the stores nearest to me were out of stock and often stayed out of stock. I suspect this was by design because Amazon also had sales on the the same cards and BestBuy will price match (there is no price-match for online orders). However, when an item comes in stock, only those with eagle eyes or luck will notice and reserve one for in-store pickup. Let’s automate some eagle eyes.
Step 1. Find the JSONP feed
You should have a look at both the XHR and JS panel. Look at the preview for obvious URLs and investigate further. Sometimes JSON is consumed by the site in the same domain, and other times it is JSONP to get around CORS1. Here our target is JSONP. Notice that the item is out of stock.
Step 2. Isolate the JSONP in a new tab
The JSONP here contains the location and the inventory status. In this case Richmond and OutOfStock. I use the JSON Viewer extension to get a feel for the formatted JSON structure so I can visually look for clues to lock on to. For example, what would the “In Stock” value look like? By looking around I know it is InStock.
When you have a rough idea what the target string should look like, switch to raw mode and isolate the exact string. Copy this to the clipboard for the next step.
Step 3. Set the Auto Refresh Plus settings once
This step only needs to be done once. Be sure to enable the Page Monitor and choose to alert you when it finds or can’t find a string/regex. I usually select Find. Then select a sound, make sure your speakers are on and test it, then set it to play until you dismiss the alert.
Step 4. Set the search regex string
Paste in the target string from step two, but change OutOfStock to InStock.
Since this is a regex field, be sure to escape special characters like brackets. Select a kind refresh rate, and click Start. You can experiment with regex strings, but this is sufficient for this case. Notice that an interval timer is initiated. The page will refresh when this timeout reaches zero and the timer will start again. This will continue until the target string is found.
Step 5. Wait for the alert
When the item is in stock, you should be treated to an alert like the one below. You can also test the alert with variants of the regex string to confirm they act as expected.
Case Study 2: Expired Domain Availability Notification
I had my eye on a long-held domain that was in a redemption period. From experience I calculated when the redemption period ends (about 1.5 months from expiry) and the domain goes into deletion. When it is deleted the various registrars have no Whois records2. While the deletion event is propagating the domain is “available” but no one can register it just yet. It is here that luck (or pressing F5 repeatedly for days) would come into play. Let’s automate a watchdog.
Step 1. Find the JSON feed
I use Namecheap.com because they saved me a lot of money when a big-name domain registrar tried to gouge me on domain renewals. For that I continue to give Namecheap my business. In this example let’s pretend someexample.com is in deletion. I’ll head to namecheap.com, open the Network inspector panel and search for the JSON feed. In this case the XHR tab rewards us with the JSON URL we seek.
Step 2. Isolate the JSON in a new tab
You don’t need to use the JSON Viewer pretty view here to notice that the .com domain is missing from the JSON. In fact, when you look at the home page in step one you can see that .net, .ai, .to, and .travel are available, just as in the JSON data below. What we should search for is plain and simple: someexample.com (Actually, someexample\.com for regex).
Step 3. Set the search string
Simply search for someexample\.com. Set a kind refresh interval again, and click Start.
Step 4. Wait for the alert
When the domain is truly available for purchase, it will appear in the JSON content and an alert will appear with the music. You should test the regex with a string that is already present.
This is easy and fun, especially because it requires a little detective work and puzzle solving. Please be considerate of the target website with the refresh interval. Some sites use a timestamp as a querystring parameter, so YMMV3. Finally. this is likely within the TOS of most websites because this technique is performed in your home Chrome browser, not a third-party web service.