diff --git a/lib/main.js b/lib/main.js index 9bf67fd..5c12f0e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -52,6 +52,8 @@ var prefs = preferences.prefs; var URL = require("sdk/url").URL; var _ = require("sdk/l10n").get; + var tabUtils = require("sdk/tabs/utils"); + var windowUtils = require("sdk/window/utils"); // preferences Object.keys(prefs).forEach(function(pref){ @@ -184,23 +186,49 @@ // display notifications worker.port.on("accessed readAPI", function(status){ + function log(title, object){ + console.log(title); + for (var name in object){ + console.log(name, object[name]); + } + } switch (status){ case "fake": + var contentURL = new URL(worker.contentURL); var url = contentURL.href; var domain = contentURL.hostname; var message = "Faked readout on " + url; + // log(" worker.tab", worker.tab); + // log(" windowUtils", windowUtils); + // log(" ", windowUtils.windows("navigator:browser", {includePrivate: true})[0][0]); + // log(" ", windowUtils.windows("navigator:browser", {includePrivate: true})[0][1]); + // log(" ", windowUtils.windows("navigator:browser", {includePrivate: true})[0][2]); + // log(" tabs", tabUtils.getTabs()); + // console.log(worker.tab.id); + // for each (let tab in tabUtils.getTabs()){ + // console.log(tabUtils.getTabId(tab)); + // } - var notifyBox = gWindow.getNotificationBox(); - var notification = notifiyBox.getNotificationBoxWithValue("fake-readout"); + var tab = tabUtils.getTabForId(worker.tab.id); + var tabBrowser = tabUtils.getTabBrowserForTab(tab); + var browser = tabUtils.getBrowserForTab(tab); + var ownerBrowser = windowUtils.getOwnerBrowserWindow(tab); + + // var notifyBox = ownerBrowser.gBrowser.getNotificationBox(); + var notifyBox = tabBrowser.getNotificationBox(); + // log(" chrome window", require("sdk/windows").browserWindows); + // var notifyBox = windowUtils.getXULWindow(browser.contentWindow).XULBrowserWindow.getNotificationBox(windowUtils.getDOMWindow(browser.contentWindow)); + var notification = notifyBox.getNotificationWithValue("fake-readout"); if (notification){ notification.label = message; } else { var buttons = [ { - label: 'whitelist URL', + label: "whitelist URL", + accessKey: "", callback: function(){ prefs.whiteList += "," + url; prefService.set("extensions.CanvasBlocker@kkapsner.de.whiteList", prefs.whiteList); @@ -209,7 +237,8 @@ } }, { - label: 'whitelist domain', + label: "whitelist domain", + accessKey: "", callback: function(){ prefs.whiteList += "," + domain; prefService.set("extensions.CanvasBlocker@kkapsner.de.whiteList", prefs.whiteList); @@ -219,8 +248,8 @@ } ]; - let priority = box.PRIORITY_WARNING_MEDIUM; - box.appendNotification( + let priority = notifyBox.PRIORITY_WARNING_MEDIUM; + notifyBox.appendNotification( message, 'fake-readout', 'chrome://browser/skin/Info.png',