fix missing badge text after style install

This commit is contained in:
Jason Barnabe 2014-02-07 21:49:08 -06:00
parent ecc3bf18a9
commit 90ae3b8d88
2 changed files with 8 additions and 3 deletions

View File

@ -11,11 +11,17 @@ function notifyAllTabs(request) {
function updateBadgeText(tab) {
if (localStorage["show-badge"] == "true") {
chrome.extension.sendMessage({method: "getStyles", matchUrl: tab.url, enabled: true}, function(styles) {
function stylesReceived(styles) {
var t = getBadgeText(styles);
console.log("Tab " + tab.id + " (" + tab.url + ") badge text set to '" + t + "'.");
chrome.browserAction.setBadgeText({text: t, tabId: tab.id});
});
}
// if we have access to this, call directly. a page sending a message to itself doesn't seem to work right.
if (typeof getStyles != "undefined") {
getStyles({matchUrl: tab.url, enabled: true}, stylesReceived);
} else {
chrome.extension.sendMessage({method: "getStyles", matchUrl: tab.url, enabled: true}, stylesReceived);
}
} else {
chrome.browserAction.setBadgeText({text: "", tabId: tab.id});
}

View File

@ -1,6 +1,5 @@
var stylishDb = null;
function getDatabase(ready, error) {
console.log("getting tha db");
if (stylishDb != null && stylishDb.version == "1.5") {
ready(stylishDb);
return;