Creating a Custom Chrome Search Engine
Custom search engines in Chrome are a pretty cool feature. For example, Jimmy Theis has a great blog post about using them to look up someone’s Rose-Hulman class schedule. The one shortcoming I’ve found is that you can’t do any processing of the actual search term. In other words, you have to blindly jump to the search engine URL without evaluating the actual query.
In the case of the Rose-Hulman lookup page, there are actually two parameters that it would be nice to query on.
The first is the username of the person you’re looking up, and the second is which quarter (Fall, Winter, Spring, Summer) to show.
With Chrome’s custom search engines, you can’t specify multiple parameters, so you have to hardcode the quarter parameter (which is hardly convenient).
To resolve this problem, I wrote a simple PHP script that takes in the search a search query (like anderswc 1
or jetheis 201130
) and translates it to the correct schedule lookup page query (my fall schedule, or Jimmy’s spring schedule last year).
Here’s the script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
Now you can create a custom search engine to point to this script (I’ve got a copy running at http://itsananderson.com/schedule.php), and specify “?search=%s”. For example, this is the custom search engine definition I have:
http://itsananderson.com/schedule.php?search=%s
Search syntax is pretty simple.
- “<username>” to look up a user’s current schedule.
- “<username> <quarter>” to look up a user’s schedule for a specific quarter this year.
Specify quarters as either 1, 2, 3, 4 or 10, 20, 30, 40 - “<username> <year><quarter>” to look up a user’s schedule for a specific quarter and academic year.
Quarters must be formatted with a trailing zero. Example: 201220 is Winter quarter, 2011-2012