mirror of https://github.com/gorhill/uBlock.git
Convert `abort-current-script` to variable paramater list
Related feedback: - https://github.com/uBlockOrigin/uAssets/discussions/19154
This commit is contained in:
parent
334a7440f3
commit
ba31d3c898
|
@ -225,6 +225,7 @@ builtinScriptlets.push({
|
||||||
dependencies: [
|
dependencies: [
|
||||||
'pattern-to-regex.fn',
|
'pattern-to-regex.fn',
|
||||||
'get-exception-token.fn',
|
'get-exception-token.fn',
|
||||||
|
'get-extra-args.fn',
|
||||||
'safe-self.fn',
|
'safe-self.fn',
|
||||||
'should-debug.fn',
|
'should-debug.fn',
|
||||||
'should-log.fn',
|
'should-log.fn',
|
||||||
|
@ -233,19 +234,16 @@ builtinScriptlets.push({
|
||||||
// Issues to mind before changing anything:
|
// Issues to mind before changing anything:
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/2154
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/2154
|
||||||
function abortCurrentScriptCore(
|
function abortCurrentScriptCore(
|
||||||
arg1 = '',
|
target = '',
|
||||||
arg2 = '',
|
needle = '',
|
||||||
arg3 = ''
|
context = ''
|
||||||
) {
|
) {
|
||||||
const details = typeof arg1 !== 'object'
|
|
||||||
? { target: arg1, needle: arg2, context: arg3 }
|
|
||||||
: arg1;
|
|
||||||
const { target = '', needle = '', context = '' } = details;
|
|
||||||
if ( typeof target !== 'string' ) { return; }
|
if ( typeof target !== 'string' ) { return; }
|
||||||
if ( target === '' ) { return; }
|
if ( target === '' ) { return; }
|
||||||
const safe = safeSelf();
|
const safe = safeSelf();
|
||||||
const reNeedle = patternToRegex(needle);
|
const reNeedle = patternToRegex(needle);
|
||||||
const reContext = patternToRegex(context);
|
const reContext = patternToRegex(context);
|
||||||
|
const extraArgs = getExtraArgs(Array.from(arguments), 3);
|
||||||
const thisScript = document.currentScript;
|
const thisScript = document.currentScript;
|
||||||
const chain = target.split('.');
|
const chain = target.split('.');
|
||||||
let owner = window;
|
let owner = window;
|
||||||
|
@ -266,8 +264,8 @@ function abortCurrentScriptCore(
|
||||||
value = owner[prop];
|
value = owner[prop];
|
||||||
desc = undefined;
|
desc = undefined;
|
||||||
}
|
}
|
||||||
const log = shouldLog(details);
|
const log = shouldLog(extraArgs);
|
||||||
const debug = shouldDebug(details);
|
const debug = shouldDebug(extraArgs);
|
||||||
const exceptionToken = getExceptionToken();
|
const exceptionToken = getExceptionToken();
|
||||||
const scriptTexts = new WeakMap();
|
const scriptTexts = new WeakMap();
|
||||||
const getScriptText = elem => {
|
const getScriptText = elem => {
|
||||||
|
@ -827,13 +825,9 @@ builtinScriptlets.push({
|
||||||
});
|
});
|
||||||
// Issues to mind before changing anything:
|
// Issues to mind before changing anything:
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/2154
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/2154
|
||||||
function abortCurrentScript(
|
function abortCurrentScript(...args) {
|
||||||
arg1,
|
|
||||||
arg2,
|
|
||||||
arg3
|
|
||||||
) {
|
|
||||||
runAtHtmlElement(( ) => {
|
runAtHtmlElement(( ) => {
|
||||||
abortCurrentScriptCore(arg1, arg2, arg3);
|
abortCurrentScriptCore(...args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue