Created
November 25, 2009 01:39
-
-
Save harlemblues/242397 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* INBOX */ | |
CmdUtils.CreateCommand({ | |
name: "inbox", | |
homepage: "http://www.phoque.de/projekte/ubiquity/", | |
author: { name: "Nils Werner", email: "nils.werner@gmail.com"}, | |
license: "GPL", | |
icon: "http://mail.google.com/mail/images/favicon.ico", | |
description: "Displays the number of unread emails in your inbox. Requires a <a href=\"http://mail.google.com\">Google Mail</a> account.", | |
preview: function( pBlock ) { | |
pBlock.innerHTML = "<i>loading</i> unread emails. Hit return to open your Google Mail inbox."; | |
gmailCounter(function(obj) { | |
pBlock.innerHTML = "<b>" + (obj.number > 0 ? obj.number : "No") + "</b> unread email" + (obj.number != 1 ? "s" : "") + ". Hit return to open your Google Mail inbox."; | |
}); | |
}, | |
execute: function(){ | |
Utils.openUrlInBrowser("https://mail.google.com/mail/#inbox"); | |
} | |
}); | |
function gmailCounter(callback) { | |
var url = "https://mail.google.com/mail/feed/atom"; | |
Utils.ajaxGet(url, function(rss) { | |
CmdUtils.loadJQuery(function(jQuery) { | |
callback({number: jQuery(rss).find("fullcount").text() }); | |
}); | |
}); | |
} | |
/* READER */ | |
CmdUtils.CreateCommand({ | |
name: "reader", | |
homepage: "http://www.phoque.de/projekte/ubiquity/", | |
author: { name: "Nils Werner", email: "nils.werner@gmail.com"}, | |
license: "GPL", | |
icon: "https://www.google.com/reader/ui/favicon.ico", | |
description: "Displays the number of unread articles in your Google Reader. Requires a <a href=\"http://mail.google.com\">Google Mail</a> account.", | |
preview: function( pBlock ) { | |
pBlock.innerHTML = "<i>loading</i> unread articles. Hit return to open Google Reader."; | |
readerCounter(function(obj) { | |
pBlock.innerHTML = "<b>" + (obj.number > 0 ? (obj.number == 50 ? "50+" : obj.number) : "No") + "</b> unread article" + (obj.number != 1 ? "s" : "") + ". Hit return to open Google Reader."; | |
}); | |
}, | |
execute: function(){ | |
Utils.openUrlInBrowser("https://www.google.com/reader/view/#overview-page"); | |
} | |
}); | |
function readerCounter(callback) { | |
var url = "https://www.google.com/reader/atom/user/-/state/com.google/reading-list?n=50"; | |
// todo: loadJQuery not defined here!! | |
Utils.ajaxGet(url, function(rss) { | |
CmdUtils.loadJQuery(function(jQuery) { | |
callback({number: jQuery(rss).find("entry:not(:has(category[label=read]))").length }); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment