From 7d95c58408e7b271dd28d1e839f8746e72cdfb7a Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 30 Jan 2026 11:05:57 -0500 Subject: [PATCH] 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']) --- src/js/resources/utils.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/js/resources/utils.js b/src/js/resources/utils.js index 45c96ca32..52e7a9b45 100644 --- a/src/js/resources/utils.js +++ b/src/js/resources/utils.js @@ -220,6 +220,14 @@ export function generateContentFn(trusted, directive) { warXHR.send(); }).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 ) { return directive; }