diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index f731a929f..55f512dde 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -714,8 +714,12 @@ function replaceNodeTextFn( const reNodeName = safe.patternToRegex(nodeName, 'i', true); const rePattern = safe.patternToRegex(pattern, 'gms'); const extraArgs = safe.getExtraArgs(Array.from(arguments), 3); - const reIncludes = safe.patternToRegex(extraArgs.includes || extraArgs.condition || '', 'ms'); - const reExcludes = safe.patternToRegex(extraArgs.excludes || '.^', 'ms'); + const reIncludes = extraArgs.includes || extraArgs.condition + ? safe.patternToRegex(extraArgs.includes || extraArgs.condition, 'ms') + : null; + const reExcludes = extraArgs.excludes + ? safe.patternToRegex(extraArgs.excludes, 'ms') + : null; const stop = (takeRecord = true) => { if ( takeRecord ) { handleMutations(observer.takeRecords()); @@ -728,10 +732,14 @@ function replaceNodeTextFn( let sedCount = extraArgs.sedCount || 0; const handleNode = node => { const before = node.textContent; - reIncludes.lastIndex = 0; - if ( safe.RegExp_test.call(reIncludes, before) === false ) { return true; } - reExcludes.lastIndex = 0; - if ( safe.RegExp_test.call(reExcludes, before) ) { return true; } + if ( reIncludes ) { + reIncludes.lastIndex = 0; + if ( safe.RegExp_test.call(reIncludes, before) === false ) { return true; } + } + if ( reExcludes ) { + reExcludes.lastIndex = 0; + if ( safe.RegExp_test.call(reExcludes, before) ) { return true; } + } rePattern.lastIndex = 0; if ( safe.RegExp_test.call(rePattern, before) === false ) { return true; } rePattern.lastIndex = 0;