Merge branch 'master' into jquery-removal

This commit is contained in:
Kevin Röbert 2020-06-05 21:51:52 +02:00
commit 08b62c0d94
10 changed files with 16 additions and 16 deletions

View File

@ -272,7 +272,7 @@
"description": "Diese Zeichenfolge wird als Titel für die Schaltfläche zum Importieren auf der Einstellungsseite verwendet." "description": "Diese Zeichenfolge wird als Titel für die Schaltfläche zum Importieren auf der Einstellungsseite verwendet."
}, },
"setting_log_limit_label": { "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.", "description": "Diese Zeichenfolge wird als Name für das Protokolllimit verwendet.",
"placeholders": { "placeholders": {
"limit": { "limit": {

View File

@ -272,7 +272,7 @@
"description": "This string is used as title for the import button on the settings page." "description": "This string is used as title for the import button on the settings page."
}, },
"setting_log_limit_label": { "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.", "description": "This string is used as name for the log limit label.",
"placeholders": { "placeholders": {
"limit": { "limit": {

View File

@ -272,7 +272,7 @@
"description": "This string is used as title for the import button on the settings page." "description": "This string is used as title for the import button on the settings page."
}, },
"setting_log_limit_label": { "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.", "description": "This string is used as name for the log limit label.",
"placeholders": { "placeholders": {
"limit": { "limit": {

View File

@ -272,7 +272,7 @@
"description": "Sert à afficher la signification de la fonction sur la page qui affiche les options." "description": "Sert à afficher la signification de la fonction sur la page qui affiche les options."
}, },
"setting_log_limit_label": { "setting_log_limit_label": {
"message": "Nombre déléments à enregistrer dans le journal, $LIMIT$ de -1 à linfini (-1 := ∞)", "message": "Nombre déléments à enregistrer dans le journal, $LIMIT$ de -1 à linfini",
"description": "Sert à afficher la signification de la fonction sur la page qui affiche les options.", "description": "Sert à afficher la signification de la fonction sur la page qui affiche les options.",
"placeholders": { "placeholders": {
"limit": { "limit": {

View File

@ -272,7 +272,7 @@
"description": "This string is used as title for the import button on the settings page." "description": "This string is used as title for the import button on the settings page."
}, },
"setting_log_limit_label": { "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.", "description": "This string is used as name for the log limit label.",
"placeholders": { "placeholders": {
"limit": { "limit": {

View File

@ -272,7 +272,7 @@
"description": "This string is used as title for the import button on the settings page." "description": "This string is used as title for the import button on the settings page."
}, },
"setting_log_limit_label": { "setting_log_limit_label": {
"message": "Ограничивать журнал до $LIMIT$ записей (-1 := ∞)", "message": "Ограничивать журнал до $LIMIT$ записей",
"description": "This string is used as name for the log limit label.", "description": "This string is used as name for the log limit label.",
"placeholders": { "placeholders": {
"limit": { "limit": {

View File

@ -272,7 +272,7 @@
"description": "This string is used as title for the import button on the settings page." "description": "This string is used as title for the import button on the settings page."
}, },
"setting_log_limit_label": { "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.", "description": "This string is used as name for the log limit label.",
"placeholders": { "placeholders": {
"limit": { "limit": {

View File

@ -65,7 +65,7 @@ function save()
.then(() => saveData("ruleURL", $('input[name=ruleURL]').val())) .then(() => saveData("ruleURL", $('input[name=ruleURL]').val()))
.then(() => saveData("hashURL", $('input[name=hashURL]').val())) .then(() => saveData("hashURL", $('input[name=hashURL]').val()))
.then(() => saveData("types", $('input[name=types]').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({ .then(() => browser.runtime.sendMessage({
function: "setBadgedStatus", function: "setBadgedStatus",
params: [] params: []

View File

@ -24,6 +24,9 @@
// Needed by the sha256 method // Needed by the sha256 method
const enc = new TextEncoder(); const enc = new TextEncoder();
// Max amount of log entries to prevent performance issues
const logThreshold = 5000;
/* /*
* To support Waterfox. * To support Waterfox.
*/ */
@ -296,8 +299,6 @@ function handleError(error) {
/** /**
* Function to log all activities from ClearUrls. * Function to log all activities from ClearUrls.
* Only logging when activated. * 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 beforeProcessing the url before the clear process
* @param afterProcessing the url after the clear process * @param afterProcessing the url after the clear process
@ -305,11 +306,10 @@ function handleError(error) {
*/ */
function pushToLog(beforeProcessing, afterProcessing, rule) { function pushToLog(beforeProcessing, afterProcessing, rule) {
const limit = storage.logLimit; const limit = storage.logLimit;
if (storage.loggingStatus && limit !== 0) { if (storage.loggingStatus && limit !== 0 && !isNaN(limit)) {
if (limit > 0 && !isNaN(limit)) { while (storage.log.log.length >= limit
while (storage.log.log.length >= limit) { || storage.log.log.length >= logThreshold) {
storage.log.log.shift(); storage.log.log.shift();
}
} }
storage.log.log.push( storage.log.log.push(

View File

@ -116,7 +116,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<br /> <br />
<p> <p>
<label id="logLimit_label"></label><br /> <label id="logLimit_label"></label><br />
<input type="number" id="logLimit" value="" name="logLimit" class="form-control" min="-1"> <input type="number" id="logLimit" value="" name="logLimit" class="form-control" min="0" max="5000">
</p> </p>
<br /> <br />
<p> <p>