From 90ae3b8d8878421019559dd8c87728ead738f920 Mon Sep 17 00:00:00 2001 From: Jason Barnabe Date: Fri, 7 Feb 2014 21:49:08 -0600 Subject: [PATCH] fix missing badge text after style install --- messaging.js | 10 ++++++++-- storage.js | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/messaging.js b/messaging.js index 9f7a3925..3b5cedf9 100644 --- a/messaging.js +++ b/messaging.js @@ -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}); } diff --git a/storage.js b/storage.js index 0d78ab5b..a37b1b9e 100644 --- a/storage.js +++ b/storage.js @@ -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;