Skip to content

Commit

Permalink
new script:inject syntax, use only when next release is *very* wide…
Browse files Browse the repository at this point in the history
…spread
  • Loading branch information
gorhill committed Mar 6, 2018
1 parent 34efe9d commit ec56165
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/js/cosmetic-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ var FilterContainer = function() {
'^',
'(?:',
[
'script:contains',
'.+?:has',
'.+?:has-text',
'.+?:if',
Expand Down
14 changes: 13 additions & 1 deletion src/js/static-ext-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- cosmetic filtering (aka "element hiding" in Adblock Plus)
- scriptlet injection: selector starts with `script:inject`
- New shorter syntax (1.15.12): `example.com##+js(bab-defuser.js)`
- html filtering: selector starts with `^`
Depending on the specialized filtering engine, field 1 may or may not be
Expand Down Expand Up @@ -655,10 +656,21 @@
}
}

var c0 = suffix.charCodeAt(0);

// New shorter syntax for scriptlet injection engine.
if ( c0 === 0x2B /* '+' */ && suffix.startsWith('+js') ) {
// Convert to deprecated syntax for now. Once 1.15.12 is
// widespread, `+js` form will be the official syntax.
parsed.suffix = 'script:inject' + parsed.suffix.slice(3);
µb.scriptletFilteringEngine.compile(parsed, writer);
return true;
}

// HTML filtering engine.
// TODO: evaluate converting Adguard's `$$` syntax into uBO's HTML
// filtering syntax.
if ( suffix.charCodeAt(0) === 0x5E /* '^' */ ) {
if ( c0 === 0x5E /* '^' */ ) {
µb.htmlFilteringEngine.compile(parsed, writer);
return true;
}
Expand Down

0 comments on commit ec56165

Please sign in to comment.