Skip to content

Commit bdd39fe

Browse files
committed
Improve trusted-click-element scriptlet
If the leading character of the selector parameter is one of `;}`, it will be used as separator character for the selector expression. Related discussion: uBlockOrigin/uAssets#33677 (comment)
1 parent 031b52b commit bdd39fe

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/js/resources/scriptlets.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,10 +1880,16 @@ function trustedClickElement(
18801880
}
18811881
}
18821882

1883-
const steps = safe.String_split.call(selectors, /\s*,\s*/).map(a => {
1884-
if ( /^\d+$/.test(a) ) { return parseInt(a, 10); }
1885-
return a;
1886-
});
1883+
const steps = (( ) => {
1884+
const steps = /^[;|]/.test(selectors)
1885+
? safe.String_split.call(selectors.slice(1), selectors.charAt(0))
1886+
: safe.String_split.call(selectors, ',');
1887+
return steps.map(a => {
1888+
a = a.trim();
1889+
if ( /^\d+$/.test(a) ) { return parseInt(a, 10); }
1890+
return a;
1891+
});
1892+
})();
18871893
if ( steps.length === 0 ) { return; }
18881894
const clickDelay = parseInt(delay, 10) || 1;
18891895
for ( let i = steps.length-1; i > 0; i-- ) {

0 commit comments

Comments
 (0)