From e8f6f3ddffd14887120bfe552b823816945aeda6 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 17 Sep 2024 17:33:06 -0400 Subject: [PATCH] Throttle down repeated scriptlet logging information Related feedback https://github.com/uBlockOrigin/uBlock-issues/issues/3378#issuecomment-2356422784 --- assets/resources/scriptlets.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index b12580db4..dbdab8102 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -176,9 +176,18 @@ function safeSelf() { const bc = new self.BroadcastChannel(scriptletGlobals.bcSecret); let bcBuffer = []; safe.logLevel = scriptletGlobals.logLevel || 1; + let lastLogType = ''; + let lastLogText = ''; + let lastLogTime = 0; safe.sendToLogger = (type, ...args) => { if ( args.length === 0 ) { return; } const text = `[${document.location.hostname || document.location.href}]${args.join(' ')}`; + if ( text === lastLogText && type === lastLogType ) { + if ( (Date.now() - lastLogTime) < 300000 ) { return; } + } + lastLogType = type; + lastLogText = text; + lastLogTime = Date.now(); if ( bcBuffer === undefined ) { return bc.postMessage({ what: 'messageToLogger', type, text }); }