Sunday, March 28, 2010

Launching Quix in Chrome via Address Bar (Installing it as a Search Engine)

I just found out about Quix recently, and it reminds me of Yubnub. The thing I like about Quix is that you aren't competing with commands in a single namespace with every other developer as you do with Yubnub. You can define what each command does for you. So for example, gm in Yubnub is defined as a Google maps search. You cannot define gm to mean anything else in Yubnub (e.g. Gmail). With Quix, however, you can.

My browser of choice is Chrome, so I wanted to integrate Quix with it. Unfortunately, the recommended installation method requires an extension for a keyboard shortcut to work. This got me thinking... why not utilize the extensible address bar that is already built into Chrome?

I started messing around with the search engine feature of Chrome. I tried a simple Hello World application:

I quickly found out that the open curly brace character is not allowed. However, it does work if you encode it as %7B, so this now works:

Note: It seems like this issue is about to get fixed. If you notice the OK button disabled when you try to save the search engine in later steps, you will need to replace all opening curly braces with %7B.

Now that I figured out that using this feature would be possible, I wanted to make it so that instead of popping up an input dialog, it uses whatever I type into the address bar. I used the JavaScript unpacker to format the bookmarklet's source code so that I can see what's going on. If you look at it yourself, you will notice this line:

  var c = window.prompt('Quix: Type `help` for a list of commands:');
... if you simply replace it with this line:
  var c = "%s";
... it will use whatever you type in the address bar and not popup a dialog. Here's the finished code:
javascript:Quix();function Quix()%7Bvar e=encodeURIComponent;var t=window.getSelection?window.getSelection():(document.getSelection?document.getSelection():(document.selection?document.selection.createRange().text:''));var c="%s";if(t!='')%7Bif(c)%7Bc+=' '+t}else%7Bc=''+t}}if(c)%7Bvar u=''+e(c)+'&t='+(document.title?e(document.title):'')+'&s='+'&v=080'+'&u='+(document.location?e(document.location):'');d=''+document.location;if(d.substr(0,4)!='http')%7Bwindow.location=u+'&mode=direct'}else%7Bheads=document.getElementsByTagName('head');if(c.substring(0,1)==' ')%7Bvar'&mode=direct');w.focus()}else if(heads.length==0)%7Bwindow.location=u+'&mode=direct'}else%7Bq=document.getElementById('quix');if(q)%7Bq.parentNode.removeChild(q)}sc=document.createElement('script');sc.src=u;'quix';sc.type='text/javascript';void(heads[0].appendChild(sc))}}}}

Update: If you want to use it with your own commands, use this version:

javascript:Quix();function Quix()%7Bvar e=encodeURIComponent;var t=window.getSelection?window.getSelection():(document.getSelection?document.getSelection():(document.selection?document.selection.createRange().text:''));var c="%s";if(t!='')%7Bif(c)%7Bc+=' '+t}else%7Bc=''+t}}if(c)%7Bvar u=''+e(c)+'&t='+(document.title?e(document.title):'')+'&s=YOUR_URL_GOES_HERE'+'&v=080'+'&u='+(document.location?e(document.location):'');d=''+document.location;if(d.substr(0,4)!='http')%7Bwindow.location=u+'&mode=direct'}else%7Bheads=document.getElementsByTagName('head');if(c.substring(0,1)==' ')%7Bvar'&mode=direct');w.focus()}else if(heads.length==0)%7Bwindow.location=u+'&mode=direct'}else%7Bq=document.getElementById('quix');if(q)%7Bq.parentNode.removeChild(q)}sc=document.createElement('script');sc.src=u;'quix';sc.type='text/javascript';void(heads[0].appendChild(sc))}}}}
... just replace "YOUR_URL_GOES_HERE". (Thanks open0source)

Note: If you want to manually create your own version of the bookmarklet, after replacing the single line, the next step is to take the code and put it in a javascript packer. Next run a simple replace on "{" to "%7B". Then use the code you just created in the following steps for installation.

Now that the code is ready, all that's left is to install it:

  1. In Chrome, go to Tools > Options
  2. In the Basics tab, click Manage next to Default search
  3. Press Add...
  4. For the name and keyword, you can enter "quix"
  5. For the URL, paste the bookmarklet code from above
  6. Press OK
    Note: if the OK button is disabled, make sure there are no open curly braces in the URL field. Also ensure that the name and keyword fields are filled in.
  7. Press Make Default in the Search Engines window
    Making it the default search engine will make it so you don't need to type a keyword before using this search engine.
  8. Press Close in the Search Engines window
  9. Press Close in the Google Chrome Options window
  10. To try it out, press Ctrl+K
  11. Type a query, e.g.: w hello world
If everything was installed correctly, this should have taken you to Wikipedia's Hello World article.

To easily get to the address bar and use Quix, use Ctrl+K which will insert a leading "?" in the address bar. This leading "?" forces the address bar to use the Quix search engine you added (without the leading "?", if you type something that looks like a URL, it will navigate to that URL). However, since commands in Quix do not look like URLs, any command you type into the address bar will be resolved correctly even without the leading "?". Thus, you can also use the Alt+D shortcut to focus on the address bar and start typing immediately.

I hope you found this post useful. I still haven't started customizing Quix, but so far it looks promising.


  1. Great! Thanks for your tip.

  2. So simple, yet so genius.

    Lifehacker has an article on this, FYI:

  3. This is fantastic! Thanks.

  4. Is there a way to set one's extended version of quix as the default search engine? I have the basic version working and I can use my extensions in the bookmarklet, but I'm not sure how to set that as a search engine.


  5. This may be related to seatdistrict's post: I have a customized Quix file with my own commands on Dropbox. Can I access that with your method? Thanks.

  6. Another option for this: if you follow the above instructions, but make the keyword "q", then you can run this simply by prefixing q to anything in the address bar. Then all Quix commands become "q ", so "q gs " in the address bar will do a Google Site search of the current site.

    I find this version more useful since if I'm planning on using a Quix command, it's trivial to start with a q when I'm already thinking in "command language" and it leaves the default functionality of the OmniBar in place the way I expect it to be.

  7. Another thing was annoying me, I like the default search to be google's, I'm so used to just type the criteria and keep forgetting to add the 'g'. So I went to quix page, see how to extend it, placed the extension file at google sites and repeated the procedure of this great tip. This is the resulting javascript for chrome:

    javascript:Quix();function Quix() %7Bvar e=encodeURIComponent;var t=window.getSelection?window.getSelection():(document.getSelection?document.getSelection():(document.selection?document.selection.createRange().text:''));var c="%s";if(t!='')%7Bif(c)%7Bc+=' '+t;}else%7Bc=''+t;}}if(c)%7Bvar u=''+e(c)+'&t='+(document.title?e(document.title):'')+'&s='+'&v=080'+'&u='+(document.location?e(document.location):'');d=''+document.location;if(d.substr(0,4)!='http')%7Bwindow.location=u+'&mode=direct';}else%7Bheads=document.getElementsByTagName('head');if(c.substring(0,1)==' ')%7Bvar'&mode=direct');w.focus();}else if(heads.length==0)%7Bwindow.location=u+'&mode=direct';}else%7Bq=document.getElementById('quix');if(q)%7Bq.parentNode.removeChild(q);}sc=document.createElement('script');sc.src=u;'quix';sc.type='text/javascript';void(heads[0].appendChild(sc));}}}}

  8. if you are prefixing your quix commands with a "q", even better is to use the "`" character. It'll save a space keystroke since no url will ever start with that character.

    Cheers for the tutorial!

  9. great blog entry, thanks, and special thanks also to henrique above for solving my extension problem

  10. Thanks for the comments everyone, I'm glad you found this post useful! I'll look into customizing the search engine soon.

  11. Fantastic, thank you! Was able to use my own command file by changing




  12. Would you mind update your code for the latest version?

  13. I'd like to second the request for an update. Quix updated several months ago and I haven't been able to tweak this to work with the new version. I've tried what little I know but failed. I'd really appreciate any help to get it going again.

  14. If you want an update to the latest, do this:

    Part 1.

    For customized version
    2. type or paste your URL
    3. enter
    4. CTRL+SHIFT+B to toggle on the Chrome bookmarks bar
    5. drag the auto-generated customized bookmarklet to the Chrome bookmarks bar

    For the regular version
    2. CTRL+SHIFT+B to toggle on the Chrome bookmarks bar
    3. drag the bookmarklet to the Chrome bookmarks bar

    Part 2:

    1. highlight bookmarklet on the address bar
    2. right click
    3. select edit
    4. click in the URL field
    5. CTRL+A
    6. CTRL+C
    7. open a text editor
    8. CTRL+V
    9. replace window.prompt('Quix: Type `help` for a list of commands:') with %s
    10. replace all { with %7B
    11. CTRL+A
    12. CTRL+C

    Part 3.
    1. go to chrome://chrome/settings/searchEngines
    2. add or edit your old version by CTRL+V