mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
Improve generateContentFn helper scriptlet
New directive: `join:[separator][sub-directives]` [separator] is an author-defined two-character string to be used to split the following sub-directives string. The sub-directives are fed back into the helper scriptlet to generate sub-content, which will be joined into a single string. Example: ...##+js(trusted-prevent-fetch, propstomatch, join:--length:10-20--[some literal content]--length:80-100-- push['ads'])
This commit is contained in:
parent
359cb070eb
commit
7d95c58408
1 changed files with 8 additions and 0 deletions
|
|
@ -220,6 +220,14 @@ export function generateContentFn(trusted, directive) {
|
||||||
warXHR.send();
|
warXHR.send();
|
||||||
}).catch(( ) => '');
|
}).catch(( ) => '');
|
||||||
}
|
}
|
||||||
|
if ( directive.startsWith('join:') ) {
|
||||||
|
const parts = directive.slice(7)
|
||||||
|
.split(directive.slice(5, 7))
|
||||||
|
.map(a => generateContentFn(trusted, a));
|
||||||
|
return parts.some(a => a instanceof Promise)
|
||||||
|
? Promise.all(parts).then(parts => parts.join(''))
|
||||||
|
: parts.join('');
|
||||||
|
}
|
||||||
if ( trusted ) {
|
if ( trusted ) {
|
||||||
return directive;
|
return directive;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue