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

Only display 250 notifications for one type

More will be counted but not rendered.

Fixes #234.
This commit is contained in:
kkapsner 2018-08-27 22:09:51 +02:00
parent 9a7d3d4230
commit 40677bd2c6
5 changed files with 46 additions and 22 deletions

View File

@ -29,6 +29,10 @@
"message": "weniger", "message": "weniger",
"description": "" "description": ""
}, },
"pleaseWait": {
"message": "Bitte warten...",
"description": ""
},
"input": { "input": {
"message": "Eingabe", "message": "Eingabe",

View File

@ -29,6 +29,10 @@
"message": "less", "message": "less",
"description": "" "description": ""
}, },
"pleaseWait": {
"message": "Please wait...",
"description": ""
},
"input": { "input": {
"message": "input", "message": "input",

View File

@ -13,6 +13,7 @@
const addToContainer = function(){ const addToContainer = function(){
const container = document.getElementById("prints"); const container = document.getElementById("prints");
container.querySelector("li").textContent = browser.i18n.getMessage("pleaseWait");
var first = true; var first = true;
return function addToContainer(domainNotification){ return function addToContainer(domainNotification){
@ -27,6 +28,7 @@
const DomainNotification = function DomainNotification(domain, messageId){ const DomainNotification = function DomainNotification(domain, messageId){
this.domain = domain; this.domain = domain;
this.messageId = messageId; this.messageId = messageId;
this.extraNotifications = 0;
addToContainer(this); addToContainer(this);
this.update(); this.update();
}; };
@ -40,10 +42,23 @@
}; };
DomainNotification.prototype.addNotification = function addNotification(notification){ DomainNotification.prototype.addNotification = function addNotification(notification){
this.notifications().push(notification); if (this.notifications().length > 250){
this.notificationsNode().appendChild(notification.node()); this.addMore();
}
else {
this.notifications().push(notification);
this.notificationsNode().appendChild(notification.node());
}
this.update(); this.update();
}; };
DomainNotification.prototype.addMore = function addMore(){
this.notificationsNode().appendChild(document.createTextNode("..."));
this.extraNotifications += 1;
this.addMore = function addMore(){
this.extraNotifications += 1;
};
};
// DOM node creation functions // DOM node creation functions
@ -100,16 +115,16 @@
}).filter(function(url, i, urls){ }).filter(function(url, i, urls){
return urls.indexOf(url) === i; return urls.indexOf(url) === i;
}).join("\n"); }).join("\n");
node.querySelectorAll(".url").forEach(function(urlSpan){ node.querySelectorAll(".url").forEach((urlSpan) => {
urlSpan.title = urls; urlSpan.title = urls + (this.extraNotifications? "\n...": "");
}); });
node.title = notifications.map(function(notification){ node.title = notifications.map(function(notification){
return notification.timestamp + ": " + notification.functionName; return notification.timestamp + ": " + notification.functionName;
}).join("\n"); }).join("\n") + this.extraNotifications? "\n...": "";
node.querySelectorAll(".count").forEach(function(countSpan){ node.querySelectorAll(".count").forEach((countSpan) => {
countSpan.textContent = notifications.length; countSpan.textContent = notifications.length + this.extraNotifications;
}); });
}; };

View File

@ -1,24 +1,24 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>CanvasBlocker page action</title> <title>CanvasBlocker page action</title>
<link href="pageAction.css" rel="stylesheet" type="text/css"> <link href="pageAction.css" rel="stylesheet" type="text/css">
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head> </head>
<body> <body>
<div id="globalActions"></div> <div id="globalActions"></div>
<ul id="prints"> <ul id="prints">
<li>...</li> <li>...</li>
</ul> </ul>
<script src="../lib/require.js"></script> <script src="../lib/require.js"></script>
<script src="../lib/settingDefinitions.js"></script> <script src="../lib/settingDefinitions.js"></script>
<script src="../lib/settings.js"></script> <script src="../lib/settings.js"></script>
<script src="../lib/logging.js"></script> <script src="../lib/logging.js"></script>
<script src="../lib/lists.js"></script> <script src="../lib/lists.js"></script>
<script src="../lib/callingStack.js"></script> <script src="../lib/callingStack.js"></script>
<script src="gui.js"></script> <script src="gui.js"></script>
<script src="domainNotification.js"></script> <script src="domainNotification.js"></script>
<script src="notification.js"></script> <script src="notification.js"></script>
<script src="pageAction.js"></script> <script src="pageAction.js"></script>
</body> </body>
</html> </html>

View File

@ -1,6 +1,7 @@
Version 0.5.3: Version 0.5.3:
changes: changes:
- removed active support for Firefox < 60 - removed active support for Firefox < 60
- maximal 250 notifications per domain and type will be rendered
new features: new features:
- display version in options page - display version in options page