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.
- Bookmark any page (seriously, any page).
- Put that bookmark into your Bookmarks Toolbar.
- Right click it and select Properties
- Change the Name to something like “Search Twitter”
- 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);}
- 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.
Isn't it easier to create a Firefox twitter search engine or save it as a keyworded bookmark?
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.
how about grabbing the current selection and using that as the search term?
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.