SOS

Shane O'Sullivan's technical blog… really ties the room together

Archive for the ‘search’ Category

QuickSearch:Google only faster

Posted by Shane O'Sullivan on August 11, 2009

Last week I realised that the process of searching for something on the web annoyed me –  it took too many key presses, too many clicks, and opened too many tabs.  To fix this, I came up with QuickSearch.

See the video below for a demo, or you can go to the QuickSearch Home Page to install it.

How I Search

My usual workflow is that I want to search for something but I don’t want to lose the page I’m currently looking at so I:

  • Press Ctrl-T to open a new tab
  • Press Tab to move the cursor to Firefox’s search box
  • Type in my query
  • Hit enter
  • Read through results. If I see what I want I open in a new tab in case I want to open another, if not I type in a new search and reload the search results.
  • Close the search tab.

So, I’ve opened a tab that I’ll probably only want for ten seconds, I’ve had to wait for my results until I stopped typing and loaded another page, and if I want to change my search query, I have to load the page again. Then close the search tab.

How I Want To Search

The workflow I want is

  • Press a key combination to start searching.  No new window or tab should be required.  I shouldn’t have to tab to, or click, any input box.  Since Ctrl-F is used to search within a page, I decided that Ctrl-Alt-F made a sensible key combination to search the whole web.
  • Start typing, and results should start appearing.  As I type I can keep an eye on the first one or two results, and if I see something interesting, I stop typing.
  • I click the link I want, with the option of opening the link in a new tab without having to right click it and choose that option from a menu.
  • When I’m finished using the search results, just press Esc to go back to my original page.

QuickSearch To The Rescue

I’ve implemented my desired workflow in QuickSearch, and it has really sped up my navigation around the web.

For convenience, I also added:

  • Search This Site: to search just the site you’re on, press Ctrl-Alt-S
  • Search Highlighted: to search for some term on the page, just highlight that word(s) and press Ctrl-Alt-F as normal.
  • More Results: If the quick results provided by QuickSearch still aren’t enough, and refining your query doesn’t work, you can click the “More Results” link to get many, many more results from Google, Yahoo, Microsoft and more using my search portal Chofter.com.

Cross Browser Goodness

QuickSearch works on

  • Firefox, as  a GreaseMonkey script
  • Google Chrome, as an extension
  • Every other browser as a Bookmarklet.

See the QuickSearch Home Page for installation instructions.  I think you’ll very quickly find it indespensible, especially in Firefox and Chrome where it is completely keyboard operated, no mouse required.

Fully Accessible

Another strong advantage of QuickSearch is that it is fully keyboard accessible.  No mouse is required:

  • The search is launched using keys
  • All link titles are correctly labelled
  • All search results can be navigated using the tab key
  • QuickSearch can be dismissed quickly using the Esc key.

I think users with sight impairments will especially like this.

Posted in Ajax, Javascript, search, Technical | 1 Comment »

Dojo & GreaseMonkey == DaftMonkey

Posted by Shane O'Sullivan on January 26, 2009

Given that I’m looking for a new apartment, and I live in Ireland, I use the property search website Daft.ie.  Everyone does.  However I wasn’t very happy with how slow it is to scan through the many results that match my meagre budget.  I realised that it could be readily fixed with GreaseMonkey, using the Dojo Ajax Toolkit to make life easier when it comes to parsing the page, adding effects etc.

The result is DaftMonkey.

I wasn’t even sure if Dojo could be used from within a GreaseMonkey script, as it sandboxes away the custom script code.  However, with a little hackery it was (more or less) possible.  The steps I took were:

  1. Set up the djConfig parameter in the host window to tell Dojo that the page had already loaded, using unsafeWindow.djConfig = {afterOnLoad: true};. unsafeWindow is what GreaseMonkey calls the normal, non-sandboxed window.
  2. Added the <script> tag for dojo.js to the head of the document.  In this case I used the dojo.js.file hosted on AOL’s CDN servers – see http://dev.aol.com/dojo .
  3. Now you have to wait for Dojo to load.  This can be done with a simple setInterval function call, checking if unsafeWindow.dojo exists or not.  (Update: thanks a comment from James, this has been changed to use the djConfig.addOnLoad function)
  4. Once Dojo is loaded, you can call a function kicking off whatever it is that you  script is supposed to do.  In this case, I wanted to add a bunch of DOM nodes to the page (which you can do without Dojo), and add some cool effects, so I also included the dojo.fx bundle.
  5. Copy the dojo variable back into the sandbox window using var dojo = unsafeWindow.dojo, otherwise you’ll have to refer to it as unsafeWindow.dojo all the time.

Screen Scraping With dojo.query

A lot of the features of DaftMonkey rely on asynchronously fetching remote HTML pages and scraping the required data from them.  The approach I used for this was:

  1. Perform a remote request using GreaseMonkey’s native Ajax function GM_xmlhttpRequest.  This works more or less the same as dojo.xhrGet, and I saw no reason to not use it.
  2. When the text is returned, create a DIV, and absolutely position it far to the left.  Fix it’s size to just one pixel so it doesn’t mess with the scroll bars.
  3. Set the innerHTML of the DIV to the text you have retrieved.  Congratulations, you can now use dojo.query to find whatever nodes you need.  e.g. to find all images inside anchor tags, use dojo.query(“a img”, tempDiv).  Note the second parameter, this tells Dojo to only search inside the temporary DIV we created, and not the whole document.

Some other site-specific things were required as part of the screen scraping process.  Many of the sites had iframes included, and as soon as you add those to the temporary DIV, they start loading another page.  This was a nasty performance hit, so I had to remove them from the HTML string before setting the innerHTML of the temporary DIV.

Problems

One problem I found is that calling dojo.declare didn’t work from inside a GreaseMonkey script.  I don’t know why.  Therefore widgets had to be defined the old fashioned way.

A second problem was more related to the website I was writing the script for, Daft.ie.  The entire site is programmed using TABLES!  Seriously, there’s barely one or two DIVs on the page, with practically no CSS either.  This makes it quite difficult and brittle to screen scrape using dojo.query, as there’s really no classes to match.  Still it was possible, but could break relatively easily if the site layout is changed.

Get the Source

You can get the entire source for the script at http://userscripts.org/scripts/show/41105 .

To read a bit more about DaftMonkey, I’ve put up a page about it at http://www.chofter.com/apps?n=daftmonkey .

Posted in Ajax, Dojo, dojo.query, greasemonkey, Javascript, open source, search, widget | 8 Comments »

Search Dojo, Prototype, PHP, Java & .NET with Chofter.com

Posted by Shane O'Sullivan on November 6, 2008

The Technical search category of my next-gen search portal Chofter.com has been a bit underpowered for a while now, and it was definitely time to strengthen it. So…… the following search sources have now been added, all of which are programming language references:

  • PHP
  • Java
  • .NET
  • Dojo Ajax Toolkit
  • Prototype Ajax Toolkit

For example, a search for “array” will bring up each language’s methods and objects for dealing with arrays. More languages on the way, probably.

Any suggestions?

Posted in Ajax, chofter, Dojo, Javascript, search, Technical | 1 Comment »

Chofter.com: Expanded views added

Posted by Shane O'Sullivan on August 9, 2008

I’ve added expanded views to Chofter.com, my Dojo/Ajax-powered search portal. See the blog post on it at http://chofter.com/blog/?p=18, and check out the changes at http://chofter.com

Up next – multiple language support. Time to hit facebook as see what friends speak which languages!!

Posted in chofter, dojox.data, search | Leave a Comment »

Chofter.com – A Next-Gen Search Portal is launched

Posted by Shane O'Sullivan on August 4, 2008

For quite a while, I had been working with various REST services, e.g. Flickr, the Google search services and more, as part of my contributions to the Dojo Ajax Toolkit, when it occurred to me that no one had done a good job of bringing all these various sources of information together in a usable way.

Cut to four months later, and I have launched my new search portal, Chofter.com.

To add it to the search bar in your browser, click here.

Immodest as it may sound, Chofter.com provides a better search experience than Google, Yahoo or Microsoft Live, because it incorporates search results from all of them, and much more.

The entire application is written using the Dojo toolkit, utilising

  • Layouts, Dialogs, Menus and ContentPanes for the user interface.
  • dojo.data and dojo.rpc for data transfer.
  • dojox.dtl (Django Templating Library) for transforming search data into visuals.
  • dojo.fx and FisheyeLite for eye candy
  • …. and a chunk of custom code.

As of writing, the following search sources are available, arranged into a number of categories:

  • Google – web, news, image, blog, video and book search.
  • Yahoo – web, news and image search.
  • Microsoft Live – web and news search.
  • YouTube – video search.
  • Flickr – image search.
  • BBC News – news and sports search.
  • Digg – web, news and video search.
  • Amazon.com – book search.
  • Wikipedia – web search.
  • IMDB – video search.
  • Technorati – blog search.
  • DZone – technical search.

I will be adding more as time goes on.  A forum is being set up, and I welcome all feedback on the site.  I’ve also set up a blog for the site at http://www.chofter.com/blog.

Posted in chofter, dijit, Dojo, dojo.data, dojox, dojox.data, Javascript, json, search, Technical | 4 Comments »

 
Follow

Get every new post delivered to your Inbox.

Join 533 other followers

%d bloggers like this: