Twitter Search Bookmarklet

Throughout the day, I’m likely to search Twitter a number of times. Being the lazy person that I am, I got sick of opening a new tab, typing search.twitter.com, hitting enter, waiting for the page, then typing my term and waiting for results. I already have a couple of other bookmarklets that I use all the time (one for loading up a Google Map, one for jumping to a PHP function name in the online reference), so I figured I’d knock up something to search Twitter. I’m using Firefox on a Mac, YMMV.

  1. Bookmark any page (seriously, any page).
  2. Put that bookmark into your Bookmarks Toolbar.
  3. Right click it and select Properties
  4. Change the Name to something like “Search Twitter”
  5. Change the Location to this (copy and paste it):
    javascript:var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0));if(!s.length){s=prompt('Search%20Twitter:','');}if(s){document.location.href='http://search.twitter.com/search?q='+escape(s);}else{void(0);}
  6. Save Changes

That’s it. Now click that link in your Bookmark Toolbar and it’ll prompt you for a search string. Enter anything and hit OK. If you happen to have some text on the page selected, it’ll automatically search for that text. Voila – Twitter Search.

    • beaulebens said:

      I guess, but I prefer to leave my search box always on Google, andnever actually bother adding custom search engines to that list.Adding a “smart keyword” would probably be a good way to go about it,but since I already have a couple other bookmarklets like this itworks with my flow.

  1. eric said:

    how about grabbing the current selection and using that as the search term?

    • Beau Lebens said:

      I've just updated the code above so that if you have something on the page selected, it'll try searching for that, otherwise it'll prompt you to enter a search phrase.

Comments are closed.