Improve `trusted-override-element-method` scriptlet

Support `debug` as valid `disposition` value: to trigger a `debugger`
statement, but only if uBO's logger is opened.

Related feedback:
https://github.com/uBlockOrigin/uAssets/issues/25510#issuecomment-2395446342
This commit is contained in:
Raymond Hill 2024-10-06 11:07:42 -04:00
parent 1f45902a61
commit 160d7f3c33
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 4 additions and 1 deletions

View File

@ -222,7 +222,7 @@ function safeSelf() {
safe.sendToLogger = (type, ...args) => {
const text = safe.toLogText(type, ...args);
if ( text === undefined ) { return; }
console.log(`uBO${text}`);
safe.log(`uBO ${text}`);
};
}
return safe;
@ -5286,6 +5286,9 @@ function trustedOverrideElementMethod(
}
safe.uboLog(logPrefix, 'Overridden');
if ( disposition === '' ) { return; }
if ( disposition === 'debug' && safe.logLevel !== 0 ) {
debugger; // eslint-disable-line no-debugger
}
if ( disposition === 'throw' ) {
throw new ReferenceError();
}