Created
May 22, 2009 09:33
-
-
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
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
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