1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 04:40:20 +01:00

Render notifications in junks

Fixes #234.
This commit is contained in:
kkapsner 2018-08-21 21:37:21 +02:00
parent 43b43d858e
commit 454873b6df
2 changed files with 21 additions and 8 deletions

View File

@ -185,14 +185,26 @@
browser.runtime.onMessage.addListener(function(data){
if (Array.isArray(data["canvasBlocker-notifications"])){
message("got notifications");
data["canvasBlocker-notifications"].forEach(function(notification){
verbose(notification);
notification.url = new URL(notification.url);
domainNotification(
notification.url.hostname,
notification.messageId
).addNotification(new Notification(notification));
});
const notifications = data["canvasBlocker-notifications"];
let i = 0;
const length = notifications.length;
const tick = window.setInterval(function(){
if (i >= length){
window.clearInterval(tick);
}
else {
for (var delta = 0; delta < 20 && i + delta < length; delta += 1){
let notification = notifications[i + delta];
verbose(notification);
notification.url = new URL(notification.url);
domainNotification(
notification.url.hostname,
notification.messageId
).addNotification(new Notification(notification));
}
i += delta;
}
}, 1);
}
});
message("request notifications from tab", tab.id);

View File

@ -14,6 +14,7 @@ Version 0.5.3:
- detection if the options page was displayed in a separate tab did not work reliably
- popup text not readable in some dark themes
- display conditions for notification settings
- page action not useable with a lot of notifications
known issues:
- if a data URL is blocked the page action button does not appear