mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-16 06:05:37 +07:00
Hard limit for the log of 5000 entries
This commit is contained in:
@@ -65,7 +65,7 @@ function save()
|
||||
.then(() => saveData("ruleURL", $('input[name=ruleURL]').val()))
|
||||
.then(() => saveData("hashURL", $('input[name=hashURL]').val()))
|
||||
.then(() => saveData("types", $('input[name=types]').val()))
|
||||
.then(() => saveData("logLimit", $('input[name=logLimit]').val()))
|
||||
.then(() => saveData("logLimit", Math.max(0, Math.min(5000, $('input[name=logLimit]').val()))))
|
||||
.then(() => browser.runtime.sendMessage({
|
||||
function: "setBadgedStatus",
|
||||
params: []
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
* This script is responsible for some tools.
|
||||
*/
|
||||
|
||||
// Max amount of log entries to prevent performance issues
|
||||
const logThreshold = 5000;
|
||||
|
||||
/*
|
||||
* To support Waterfox.
|
||||
*/
|
||||
@@ -293,8 +296,6 @@ function handleError(error) {
|
||||
/**
|
||||
* Function to log all activities from ClearUrls.
|
||||
* Only logging when activated.
|
||||
* The log is only temporary saved in the cache and will
|
||||
* permanently saved with the saveLogOnClose function.
|
||||
*
|
||||
* @param beforeProcessing the url before the clear process
|
||||
* @param afterProcessing the url after the clear process
|
||||
@@ -302,11 +303,10 @@ function handleError(error) {
|
||||
*/
|
||||
function pushToLog(beforeProcessing, afterProcessing, rule) {
|
||||
const limit = storage.logLimit;
|
||||
if (storage.loggingStatus && limit !== 0) {
|
||||
if (limit > 0 && !isNaN(limit)) {
|
||||
while (storage.log.log.length >= limit) {
|
||||
storage.log.log.shift();
|
||||
}
|
||||
if (storage.loggingStatus && limit !== 0 && !isNaN(limit)) {
|
||||
while (storage.log.log.length >= limit
|
||||
|| storage.log.log.length >= logThreshold) {
|
||||
storage.log.log.shift();
|
||||
}
|
||||
|
||||
storage.log.log.push(
|
||||
|
||||
Reference in New Issue
Block a user