Here is my first Ubiquity command. It shares the content you've selected onto Google Reader. Of course you need to have a Google account to use it. If you use Google Reader with https, you should better subscribe to the share-on-reader-secure command. Read the blog entry about it.
September 3rd 2009: I've updated it to work with the Parser 2.
CmdUtils.CreateCommand({
names: [ "share on Reader", "note with Reader", "share using Reader", "note using reader" ],
homepage: "http://abauchu.net/",
icon: "http://www.google.com/reader/ui/favicon.ico",
author: { name: "Alexis Bauchu", email: "alexis.bauchu@gmail.com" },
license: "MPL",
description: "Shares content Google Reader's shared stuff page and allow you to add a note.",
help: "This uses Google Reader, so you need a Google account to use this command.",
arguments: [
{ role: 'object', nountype: noun_arb_text, label: 'extract' }
],
execute: function (args) {
var cmd = "var b=document.body;var GR________bookmarklet_domain='http://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='http://www.google.com/reader/ui/link-bookmarklet.js');void(b.appendChild(z));}else{}";
var doc = Application.activeWindow.activeTab.document;
var body = doc.body;
void (cript = doc.createElement('script'));
void (code = doc.createTextNode(cmd));
void (cript.appendChild(code));
void (body.appendChild(cript));
}
});
If you need a version working with the old parser, you can use this version instead.
CmdUtils.CreateCommand({
name: "share-on-reader",
homepage: "http://abauchu.net/",
icon: "http://www.google.com/reader/ui/favicon.ico",
author: { name: "Alexis Bauchu", email: "alexis.bauchu@gmail.com"},
license: "MPL",
description: "Shares content Google Reader's shared stuff page and allow you to add a note.",
help: "This uses Google Reader, so you need a Google account to use this command.",
takes: {"your selection": noun_arb_text},
preview: function( pblock, selection ) {
pblock.innerHTML = "Shares \"" + selection.html + "\" with Google Reader and allows to add a note";
},
execute: function(selection) {
var cmd = "var b=document.body;var GR________bookmarklet_domain='http://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='http://www.google.com/reader/ui/link-bookmarklet.js');void(b.appendChild(z));}else{}";
var doc = Application.activeWindow.activeTab.document;
var body = doc.body;
void (cript = doc.createElement('script'));
void (code = doc.createTextNode(cmd));
void (cript.appendChild(code));
void (body.appendChild(cript));
}
});