Skip to content

Instantly share code, notes, and snippets.

@segphault
Created May 22, 2009 09:33
Show Gist options
  • Save segphault/116032 to your computer and use it in GitHub Desktop.
Save segphault/116032 to your computer and use it in GitHub Desktop.
A Jetpack plugin that will show the Digg count for a web page
jetpack.statusBar.append({
html: '<span id="count">Digg</span>',
width: 55,
onReady: function(doc) {
var url = jetpack.tabs.focused.contentWindow.location.href;
function updateDiggs() {
if (url != jetpack.tabs.focused.contentWindow.location.href) {
url = jetpack.tabs.focused.contentWindow.location.href;
console.log(url);
$.getJSON("http://services.digg.com/stories",
{"type": "json", "appkey": "http://arstechnica.com", "link": url},
function(data) {
console.log(data);
if (data.stories)
$(doc).find("#count").text(data.stories[0].diggs).css(
"background", data.stories[0].status == "popular" ? "red" : "green")
else $(doc).find("#count").text("None").css({"background": ""});
});
}
}
jetpack.tabs.onReady(function() {updateDiggs()});
setInterval(function() {updateDiggs()}, 5000);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment