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;