1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-06 02:59:39 +02:00

new script:inject syntax, use only when next release is *very* widespread

This commit is contained in:
Raymond Hill 2018-03-06 09:09:53 -05:00
parent 34efe9d6f2
commit ec56165d0d
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 13 additions and 2 deletions

View File

@ -393,7 +393,6 @@ var FilterContainer = function() {
'^',
'(?:',
[
'script:contains',
'.+?:has',
'.+?:has-text',
'.+?:if',

View File

@ -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
@ -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;
}