1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-22 02:12:44 +01:00

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

View File

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