diff --git a/_locales/de/messages.json b/_locales/de/messages.json index 05526c9..8615e3c 100644 --- a/_locales/de/messages.json +++ b/_locales/de/messages.json @@ -272,7 +272,7 @@ "description": "Diese Zeichenfolge wird als Titel für die Schaltfläche zum Importieren auf der Einstellungsseite verwendet." }, "setting_log_limit_label": { - "message": "Limitiert das Protokoll auf $LIMIT$ Einträge. (-1 := ∞)", + "message": "Limitiert das Protokoll auf $LIMIT$ Einträge.", "description": "Diese Zeichenfolge wird als Name für das Protokolllimit verwendet.", "placeholders": { "limit": { diff --git a/_locales/en/messages.json b/_locales/en/messages.json index df08d8e..9290bd4 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -272,7 +272,7 @@ "description": "This string is used as title for the import button on the settings page." }, "setting_log_limit_label": { - "message": "Limit the log to $LIMIT$ entries. (-1 := ∞)", + "message": "Limit the log to $LIMIT$ entries.", "description": "This string is used as name for the log limit label.", "placeholders": { "limit": { diff --git a/_locales/es/messages.json b/_locales/es/messages.json index 9ebaca8..0637bc8 100644 --- a/_locales/es/messages.json +++ b/_locales/es/messages.json @@ -272,7 +272,7 @@ "description": "This string is used as title for the import button on the settings page." }, "setting_log_limit_label": { - "message": "Limitar el tamaño del registro a $LIMIT$ eventos. (-1 := ∞)", + "message": "Limitar el tamaño del registro a $LIMIT$ eventos.", "description": "This string is used as name for the log limit label.", "placeholders": { "limit": { diff --git a/_locales/fr/messages.json b/_locales/fr/messages.json index 8a1ec5c..e6b0bf7 100644 --- a/_locales/fr/messages.json +++ b/_locales/fr/messages.json @@ -272,7 +272,7 @@ "description": "Sert à afficher la signification de la fonction sur la page qui affiche les options." }, "setting_log_limit_label": { - "message": "Nombre d’éléments à enregistrer dans le journal, $LIMIT$ de -1 à l’infini (-1 := ∞)", + "message": "Nombre d’éléments à enregistrer dans le journal, $LIMIT$ de -1 à l’infini", "description": "Sert à afficher la signification de la fonction sur la page qui affiche les options.", "placeholders": { "limit": { diff --git a/_locales/it/messages.json b/_locales/it/messages.json index c6b8335..6bbb90f 100644 --- a/_locales/it/messages.json +++ b/_locales/it/messages.json @@ -272,7 +272,7 @@ "description": "This string is used as title for the import button on the settings page." }, "setting_log_limit_label": { - "message": "Limita le voci di log a $LIMIT$. (-1 := ∞)", + "message": "Limita le voci di log a $LIMIT$.", "description": "This string is used as name for the log limit label.", "placeholders": { "limit": { diff --git a/_locales/ru/messages.json b/_locales/ru/messages.json index a67e7ba..570f7f4 100644 --- a/_locales/ru/messages.json +++ b/_locales/ru/messages.json @@ -272,7 +272,7 @@ "description": "This string is used as title for the import button on the settings page." }, "setting_log_limit_label": { - "message": "Ограничивать журнал до $LIMIT$ записей (-1 := ∞)", + "message": "Ограничивать журнал до $LIMIT$ записей", "description": "This string is used as name for the log limit label.", "placeholders": { "limit": { diff --git a/_locales/sv_SE/messages.json b/_locales/sv_SE/messages.json index ba919e2..554ea96 100644 --- a/_locales/sv_SE/messages.json +++ b/_locales/sv_SE/messages.json @@ -272,7 +272,7 @@ "description": "This string is used as title for the import button on the settings page." }, "setting_log_limit_label": { - "message": "Begränsa loggfilen till $LIMIT$ poster. (-1 := ∞)", + "message": "Begränsa loggfilen till $LIMIT$ poster.", "description": "This string is used as name for the log limit label.", "placeholders": { "limit": { diff --git a/core_js/settings.js b/core_js/settings.js index 8cf6f11..332a003 100644 --- a/core_js/settings.js +++ b/core_js/settings.js @@ -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: [] diff --git a/core_js/tools.js b/core_js/tools.js index 676a530..d569502 100644 --- a/core_js/tools.js +++ b/core_js/tools.js @@ -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( diff --git a/html/settings.html b/html/settings.html index 481c4bf..ed5c26a 100644 --- a/html/settings.html +++ b/html/settings.html @@ -116,7 +116,7 @@ along with this program. If not, see .


- +