1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-04 20:46:39 +02:00

Added pageAction to display the notifications.

This commit is contained in:
kkapsner 2017-06-29 07:21:36 +02:00
parent cba5680406
commit 5cec9781c2
10 changed files with 84 additions and 3 deletions

26
pageAction/pageAction.js Normal file
View file

@ -0,0 +1,26 @@
// console.log(window, browser, browser.runtime);
browser.tabs.query({active: true, currentWindow: true}).then(function(tabs){
if (!tabs.length){
throw new Error("noTabsFound");
}
var tab = tabs[0];
browser.runtime.onMessage.addListener(function(data){
if (Array.isArray(data["canvasBlocker-notifications"])){
var ul = document.getElementById("prints");
data["canvasBlocker-notifications"].forEach(function(notification){
var li = document.createElement("li");
li.className = "print";
li.textContent = notification.url + ": " + notification.messageId + " (" + notification.timestamp + ")" + "\n" + notification.errorStack;
ul.appendChild(li);
});
}
});
browser.tabs.sendMessage(
tab.id,
{
"canvasBlocker-sendNotifications": tab.id
}
);
}).catch(function(e){
console.error(e);
});