I'm new to Extensions and I want to make an extension for my website that displays how many PMs I receive. It should show up as a Chrome Icon, like this: http://puu.sh/5U4xv.png, where the number can be any number that's on my inbox. It also changes colors when there's no PMs (basic icon, no changes), when there's a couple of PMs it becomes yellow and when there's a lot of PMs it becomes red. The problem is, it doesn't work and I don't know how to receive the amount of PMs in my inbox and display it in the icon.
What I have right now:
case "getQuestions":
var timeNow = new Date().getTime();
if( (timeNow - questionsTimer) >= 15000 || questions == null ) {
sendResponse('update');
} else {
sendResponse(reports);
}
break;
case "setQuestions":
questions= request.questions;
questionsTimer = new Date().getTime();
var Total = questions.match(/total: ([0-9]+)/)[1];
var Large = questions.match(/large: ([0-9]+)/)[1];
if( Large > 0 ) {
chrome.browserAction.setIcon({path: chrome.extension.getURL('Style/Images/icon_red.png')});
} else {
if( Total > 0 ) {
chrome.browserAction.setIcon({path: chrome.extension.getURL('Style/Images/icon_yellow.png')});
} else {
chrome.browserAction.setIcon({path: chrome.extension.getURL('Style/Images/icon_green.png')});
Total = "";
}
}