mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-05 18:32:30 +01:00
Improve trusted-replace-node-text
scriptlet
Related discussion: https://github.com/uBlockOrigin/uAssets/discussions/23769#discussioncomment-10102276
This commit is contained in:
parent
f2c4328a2e
commit
8afd9e233d
@ -714,7 +714,8 @@ function replaceNodeTextFn(
|
||||
const reNodeName = safe.patternToRegex(nodeName, 'i', true);
|
||||
const rePattern = safe.patternToRegex(pattern, 'gms');
|
||||
const extraArgs = safe.getExtraArgs(Array.from(arguments), 3);
|
||||
const reCondition = safe.patternToRegex(extraArgs.condition || '', 'ms');
|
||||
const reIncludes = safe.patternToRegex(extraArgs.includes || extraArgs.condition || '', 'ms');
|
||||
const reExcludes = safe.patternToRegex(extraArgs.excludes || '', 'ms');
|
||||
const stop = (takeRecord = true) => {
|
||||
if ( takeRecord ) {
|
||||
handleMutations(observer.takeRecords());
|
||||
@ -727,8 +728,10 @@ function replaceNodeTextFn(
|
||||
let sedCount = extraArgs.sedCount || 0;
|
||||
const handleNode = node => {
|
||||
const before = node.textContent;
|
||||
reCondition.lastIndex = 0;
|
||||
if ( safe.RegExp_test.call(reCondition, before) === false ) { return true; }
|
||||
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; }
|
||||
rePattern.lastIndex = 0;
|
||||
if ( safe.RegExp_test.call(rePattern, before) === false ) { return true; }
|
||||
rePattern.lastIndex = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user