Skip to content

Instantly share code, notes, and snippets.

@fanzeyi
Created April 26, 2012 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fanzeyi/2499221 to your computer and use it in GitHub Desktop.
Save fanzeyi/2499221 to your computer and use it in GitHub Desktop.
var count;
var fetching = false;
chrome.browserAction.onClicked.addListener(function(a) {
chrome.tabs.create({'url' : 'http://www.v2ex.com/notifications'});
});
function fetchNotify() {
if(!fetching) {
fetching = true;
$.get("http://www.v2ex.com/faq", function(r) {
count = r.match(/<title>V2EX \((.*)\)<\/title>/);
if(count !== null) {
chrome.browserAction.setBadgeText({
'text' : r.match(/<title>V2EX \((.*)\)<\/title>/)[1]
});
}else{
chrome.browserAction.setBadgeText({'text' : ''});
}
fetching = false;
});
}
}
fetchNotify();
setInterval(fetchNotify, 120000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment