a tiny script that reloads a page for me and screams when something finally changes.
So it was انتخاب واحد day at Sharif. Courses. Scarce ones. The kind where if you blink, the seat is gone and you're spending a semester in a class you didn't want at 8am on a Saturday.
The website was supposed to open at 8:00. It didn't. I'm pretty sure an admin somewhere forgot to hit a button.
Meanwhile, every other student was doing the thing: refresh, nothing, refresh, nothing, refresh, sigh. Some gave up and went back to sleep. A few probably refreshed until their fingers filed a complaint.
Me? I was too lazy to sit there refreshing... and also not lazy enough to just miss it. Those two feelings, at the exact same time. So instead of refreshing a page for an hour, I spent a suspiciously similar amount of time making my laptop do it for me. Worth it. Obviously.
Every ~30 seconds it:
- reloads the انتخاب واحد page in Chrome
- presses Enter (the page is a form POST, so Chrome asks "Confirm Form Resubmission" — Enter says "yeah, continue")
- checks if the phrase "اکنون زمان ثبت نام شما نمی باشد." ("it's not your registration time yet") is still there
- if that phrase is gone → registration is probably open → it blasts a loud, obnoxious alarm on repeat until I drag myself to the keyboard and hit
Ctrl+C
Basically: a personal "wake up, it's open" pager. For free. In AppleScript. Don't judge.
osascript watch-courses.applescriptBetter version for the "I'm going to sleep" scenario (keeps the Mac awake so it doesn't doze off and miss the moment):
caffeinate -dimsu osascript watch-courses.applescriptStop it with Ctrl+C, or:
pkill -f watch-courses.applescript- Chrome: turn on
View → Developer → Allow JavaScript from Apple Events(this is how the script peeks at the page text). - Accessibility: give your terminal app permission in
System Settings → Privacy & Security → Accessibility(this is how it presses Enter). First run will also pop an "allow Terminal to control Chrome" prompt — say yes.
- Interval: change the
delay 27.8line near the bottom. Smaller = checks more often = catches the opening faster (but hammers the server more).~10sis a reasonable "I'm serious about this course" setting. - Watching a different site? Swap the Persian phrase in the script for whatever "it's closed" text your page shows.
- Alarm sound: it uses
Sosumibecause it's nice and piercing. Any file in/System/Library/Sounds/works.
It's a hack. It worked for me. If a course gets away from you, that's between you and the registrar, not me. 🫡
