diff --git a/lib/intercept.js b/lib/intercept.js index 85677df..2eb3446 100644 --- a/lib/intercept.js +++ b/lib/intercept.js @@ -81,7 +81,7 @@ case "fake": setRandomSupplyByType(prefs("rng")); var fake = changedFunction.fakeGenerator(prefs, function(messageId){ - notify({url, errorStack: error.stack, messageId, timestamp: new Date()}); + notify({url, errorStack: error.stack, messageId, timestamp: new Date(), functionName: name}); }, window, original); switch (fake){ case true: diff --git a/lib/main.js b/lib/main.js index 0b8551b..39a0fba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -13,10 +13,33 @@ console.log("got port", port); port.postMessage({tabId: port.sender.tab.id}); port.onMessage.addListener(function(data){ - browser.pageAction.show(port.sender.tab.id); + browser.storage.local.get("showNotifications").then(function(data){ + // TODO: handle ignore list + if (!data.hasOwnProperty("showNotifications") || data.showNotifications){ + browser.pageAction.show(port.sender.tab.id); + } + }) console.log("got data", data, "from port", port); }); }); + + // hide all page actions when showNotifications is set to false + browser.storage.onChanged.addListener(function(change, area){ + if (area === "local" && change.hasOwnProperty("showNotifications") && !change.showNotifications.newValue){ + browser.tabs.query({}).then(function(tabs){ + tabs.forEach(function(tab){ + browser.pageAction.hide(tab.id); + }); + }); + } + }); + + // hide page action when a tab is refreshed + browser.tabs.onUpdated.addListener(function(tabId, data){ + if (data.status === "loading"){ + browser.pageAction.hide(tabId); + } + }); console.log("end main script"); return null; diff --git a/lib/require.js b/lib/require.js index 642832a..cf33e87 100644 --- a/lib/require.js +++ b/lib/require.js @@ -15,7 +15,7 @@ function require(module){ on: function(key, callback){ browser.storage.onChanged.addListener(function(changes, area){ if (area === "local"){ - if (changes[key]){ + if (changes.hasOwnProperty(key)){ callback(); } } diff --git a/pageAction/pageAction.css b/pageAction/pageAction.css index eb9bcb4..cf62b45 100644 --- a/pageAction/pageAction.css +++ b/pageAction/pageAction.css @@ -1,10 +1,13 @@ -.template { - display: none; +.actions { + display: block; +} + +body { + margin: 5px; } #prints { - min-width: 400px; -} -.print { - white-space: pre; + list-style: none; + padding: 0; + margin: 0; } \ No newline at end of file diff --git a/pageAction/pageAction.html b/pageAction/pageAction.html index 0dc3c84..af79f81 100644 --- a/pageAction/pageAction.html +++ b/pageAction/pageAction.html @@ -3,10 +3,16 @@