mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-09 20:32:39 +01:00
Improve set-constant
scriptlet
Related feedback: https://github.com/uBlockOrigin/uBlock-discussions/discussions/881#discussioncomment-10072370
This commit is contained in:
parent
fd054176a8
commit
77feb25c4d
@ -485,9 +485,8 @@ builtinScriptlets.push({
|
|||||||
'safe-self.fn',
|
'safe-self.fn',
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
function validateConstantFn(trusted, raw) {
|
function validateConstantFn(trusted, raw, extraArgs = {}) {
|
||||||
const safe = safeSelf();
|
const safe = safeSelf();
|
||||||
const extraArgs = safe.getExtraArgs(Array.from(arguments), 2);
|
|
||||||
let value;
|
let value;
|
||||||
if ( raw === 'undefined' ) {
|
if ( raw === 'undefined' ) {
|
||||||
value = undefined;
|
value = undefined;
|
||||||
@ -587,7 +586,7 @@ function setConstantFn(
|
|||||||
};
|
};
|
||||||
if ( trappedProp === '' ) { return; }
|
if ( trappedProp === '' ) { return; }
|
||||||
const thisScript = document.currentScript;
|
const thisScript = document.currentScript;
|
||||||
let normalValue = validateConstantFn(trusted, rawValue);
|
let normalValue = validateConstantFn(trusted, rawValue, extraArgs);
|
||||||
if ( rawValue === 'noopFunc' || rawValue === 'trueFunc' || rawValue === 'falseFunc' ) {
|
if ( rawValue === 'noopFunc' || rawValue === 'trueFunc' || rawValue === 'falseFunc' ) {
|
||||||
normalValue = cloakFunc(normalValue);
|
normalValue = cloakFunc(normalValue);
|
||||||
}
|
}
|
||||||
@ -4772,7 +4771,7 @@ function trustedReplaceArgument(
|
|||||||
const logPrefix = safe.makeLogPrefix('trusted-replace-argument', propChain, argposRaw, argraw);
|
const logPrefix = safe.makeLogPrefix('trusted-replace-argument', propChain, argposRaw, argraw);
|
||||||
const argpos = parseInt(argposRaw, 10) || 0;
|
const argpos = parseInt(argposRaw, 10) || 0;
|
||||||
const extraArgs = safe.getExtraArgs(Array.from(arguments), 3);
|
const extraArgs = safe.getExtraArgs(Array.from(arguments), 3);
|
||||||
const normalValue = validateConstantFn(true, argraw);
|
const normalValue = validateConstantFn(true, argraw, extraArgs);
|
||||||
const reCondition = extraArgs.condition
|
const reCondition = extraArgs.condition
|
||||||
? safe.patternToRegex(extraArgs.condition)
|
? safe.patternToRegex(extraArgs.condition)
|
||||||
: /^/;
|
: /^/;
|
||||||
|
Loading…
Reference in New Issue
Block a user