Wednesday, January 21, 2009

Ubiquity Commands I've "created"

If you're not using Firefox 3 and Ubiquity, this post may not be all that useful to you, but go check them out and then come back here and this might make more sense.

If you are using Ubiquity, you may have noticed that a nice feature is that you can create your own commands from right within the browser. There is a nice tutorial on how to get started on this on the Mozilla site.

The absolute easiest way to create a new Ubiquity command is to make a command from an existing bookmarklet. There is a video here that explains this. Basically, you just copy and paste some code snippets and bam, there's your nifty new command.

Commands I've made using this method are:

The 'page2rss' command:

CmdUtils.makeBookmarkletCommand({
name: "Add to Page2RSS",
url:"javascript:location.href='http://page2rss.com?url='+encodeURIComponent(location.href);"
});

I've gotten so used to clicking the RSS icon in Firefox to subscribe to sites I like, that when I come to a site with no RSS feed I feel really frustrated. So I use this bookmarklet/command that sends the page through page2rss.com which in turn monitors the page for changes and creates a feed for it. Then I subscribe. :)

The 'HuffDuff it' command:

CmdUtils.makeBookmarkletCommand({
name: "HuffDuff It",
url:"javascript:var%20w=window.open('http://huffduffer.com/add?popup=true&page='+encodeURIComponent(location.href),'huffduff','scrollbars=1,status=0,resizable=1,location=0,toolbar=0,width=360,height=480');"
});

This allows me to submit things to my huffduffer.com queue. For more on how I use huffduffer.com, see my last post.

Similarly, one for the 'easylistener player':

CmdUtils.makeBookmarkletCommand({
name: "easylistener",
url: "javascript:void(window.open(%22http://webjay.org/flash/xspf_player?playlist_url=%22+encodeURIComponent(location.href),%22easylistener%22,%22menubar=no,location=no,resizable=yes,scrollbars=no,status=yes%22));"
});


I used to use Google Notebook heavily until I heard it was being pseudo-discontinued. Now I use Evernote, and thus an Evernote command:

CmdUtils.makeBookmarkletCommand({
name: "evernote this",
url: "javascript:(function(){EN_CLIP_HOST='http://www.evernote.com';try{var%20x=document.createElement('SCRIPT');x.type='text/javascript';x.src=EN_CLIP_HOST+'/public/bookmarkClipper.js?'+(new%20Date().getTime()/100000);document.getElementsByTagName('head')[0].appendChild(x);}catch(e){location.href=EN_CLIP_HOST+'/clip.action?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);}})();"
});



This last one is one that I actually "wrote". I gradually figured out how the commands are normally written, and made this one mostly from scratch. It let's you type in a song name and it returns a list of songs from the tinysong.com service. I find it extremely useful when I want to hear a particular song. This makes it really easy to go from thinking about a song directly to listening to that song. Much less cumbersome than opening a new tab, browsing to the site, and typing it in there. The command could use a few improvements, but I'm still pretty happy with it.

CmdUtils.CreateCommand({
name: "tinysong",
takes: {"song to find": noun_arb_text},
preview: function( pblock, songToFind ) {
pblock.innerHTML = "song results...";
var baseUrl = 'http://tinysong.com/?';
var params = {s: songToFind.text, limit: 5 };
jQuery.get( baseUrl,
params,
function ( response ){
var results = eval( '(' + response + ')' );
pblock.innerHTML = results.Custom;
}
);
},
execute: function( songToFind ) {
var doc = Application.activeWindow.activeTab.document;
var url_dest = 'http://tinysong.com/?s='+songToFind.text+'&limit=10';
Application.activeWindow.open(Utils.url(url_dest));
}
});


It should be possible to copy and paste these directly into your Ubiquity command editor and they should work right away. Let me know if you try them out.