Monday, October 20, 2008

Ubiquity Command: Note in Reader

Update: Monday, August 18, 2009 9:54 am
Updated script to work with newer framework.

Update: Monday, October 20, 2008 2:52 pm
Updated the script to actually work. Also you can now enter your note on the command line itself.



Here is a Ubiquity script to note a page in Google Reader.
note-in-reader.js
CmdUtils.CreateCommand({
name: ["note-in-reader", "add-to-reader", "share-to-reader"],
homepage: "http://pynej.blogspot.com/",
author: { name: "Jeremy Pyne", email: "jeremy.pyne@gmail.com"},
description: "Note this page in Google Reader.",
arguments: [ {role: 'object', nountype: noun_arb_text, label: 'note'} ],
execute: function( note ) {
var document = Application.activeWindow.activeTab.document;
var gc = "var b=document.body;var GR________bookmarklet_domain='https://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='https://www.google.com/reader/ui/link-bookmarklet.js');void(b.appendChild(z));}else{}";

void(z=document.createElement('script'));
z.appendChild(document.createTextNode(gc));
document.body.appendChild(z);

if(note.text)
{
var timer = Components.classes["@mozilla.org/timer;1"]
.createInstance(Components.interfaces.nsITimer);
timer.initWithCallback(
function() {
document.getElementById("GR________link_bookmarklet_frame").contentDocument.getElementById("annotation").innerHTML= note.text;
},
1500,
Components.interfaces.nsITimer.TYPE_ONE_SHOT);
}
}
})

2 comments:

Kiran Prasad said...

I updated this to support the .5 release of ubiquity you can find it here:

http://www.subtlysimple.com/?page_id=56

Kiran Prasad said...

Thanks for making such a great script, i use it a ton and i just updated it.