Conditional search engine selection in Firefox?
August 7, 2008 1:35 PM   Subscribe

Conditional search engine selection in Firefox search box based on contents (in particular, character set) of the search query?

I would like Firefox to use a different search engine depending on the type of string I enter into the search box. I think that regex matching, if possible, would do the trick.

I like using the search box in Firefox.

I like Google for most searches, but I want to use Yandex by default for any search that contains Cyrillic (Russian) characters.

For example, if I'm searching for "keys wallet phone", Firefox should use Google, but if I'm searching for "ключи бумажник телефон", it should switch to Yandex. (Yandex should be used even if Latin characters are present, as long as at least one Cyrillic character is there.)

How do I make Firefox switch search engines depending on the charset of the text I enter?
posted by qvtqht to Computers & Internet (5 answers total)
One approach would be to write an html page of your own with some suitable javascript. The javascript would need to check the search text for Cyrillic characters and then pass the text as a parameter to the appropriate search page.

an example you could modify. Maybe someone else could help with some code for detecting Cyrillic characters...
posted by le morte de bea arthur at 2:12 PM on August 7, 2008

Best answer: You could also create your own "intermediate" search engine, which would redirect based on the detected querystring, which would come from own custom search provider.
posted by wongcorgi at 2:34 PM on August 7, 2008

Write it in greasemonkey. Intercept requests, then rewrite the URL if cyrillic content is found in search terms (a regex should work fine).

Secure Gmail provides a good template to work from.
posted by benzenedream at 3:51 PM on August 7, 2008

How about Firefox's built-in special searches?

I use these for near everything, and it saves the time of clicking back and forth, selecting the search engine, etc, and I always get the results from sites I want. Here for a quick how-to. It's as easy as right clicking in the search box on a given page, and choosing "Add a keyword for this search..."

Like it says in the walkthrough above, there are some built in searches by default so you can try those out and see if they help at all or are even a suitable solution for you.

eg. typing "wp astronomy" into your location bar and then hitting enter should take you right to the astronomy page on The Wikis. You could essentially use a different "term" (in this case 'wp') for every language in the wikis, etc. A few I have set up on my machine at home are "imdb", "yt" (youtube), "cc" (creative commons) "w3", etc. You can make the search terms whatever you want, so that they're easy for you to remember. The only downfall I've found from using this method is that if you're ever at a computer that isn't yours, you may find yourself "quick searching" and failing. All the time.
Otherwise I hope it helps.
posted by disorder at 4:06 PM on August 7, 2008

Response by poster: Thanks for everyone's suggestions. I ended up going the "intermediate search engine" route, and I've posted the result at

Here is the key code snippet:

preg_match('/[\x{0400}-\x{045f}]/u', $q)
posted by qvtqht at 5:02 PM on August 7, 2008

« Older Look on my reference works, ye mighty, and despair   |   Is this webhost vilation GPL? Newer »
This thread is closed to new comments.