diff --git a/src/js/logger-ui.js b/src/js/logger-ui.js index 039e918ab..83d47c2ad 100644 --- a/src/js/logger-ui.js +++ b/src/js/logger-ui.js @@ -173,6 +173,7 @@ var filterDecompiler = (function() { 6: 'subdocument', 7: 'font', 8: 'other', + 12: 'document', 13: 'elemhide', 14: 'inline-script', 15: 'popup' diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index fd23afd30..f9654d87b 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -64,6 +64,7 @@ var typeNameToTypeValue = { 'sub_frame': 6 << 4, 'font': 7 << 4, 'other': 8 << 4, + 'main_frame': 12 << 4, 'cosmetic-filtering': 13 << 4, 'inline-script': 14 << 4, 'popup': 15 << 4 @@ -76,9 +77,10 @@ var typeValueToTypeName = { 3: 'object', 4: 'script', 5: 'xmlhttprequest', - 6: 'sub_frame', + 6: 'subdocument', 7: 'font', 8: 'other', + 12: 'document', 13: 'cosmetic-filtering', 14: 'inline-script', 15: 'popup' @@ -1231,6 +1233,7 @@ FilterParser.prototype.toNormalizedType = { 'subdocument': 'sub_frame', 'font': 'font', 'other': 'other', + 'document': 'main_frame', 'elemhide': 'cosmetic-filtering', 'inline-script': 'inline-script', 'popup': 'popup' @@ -1278,7 +1281,7 @@ FilterParser.prototype.parseOptType = function(raw, not) { this.types = allNetRequestTypesBitmap; } - this.types &= ~typeBit; + this.types &= ~typeBit & allNetRequestTypesBitmap; }; /******************************************************************************/ @@ -1334,6 +1337,14 @@ FilterParser.prototype.parseOptions = function(s) { this.unsupported = true; break; } + if ( opt === 'document' ) { + if ( this.action === BlockAction ) { + this.parseOptType('document', not); + continue; + } + this.unsupported = true; + break; + } if ( this.toNormalizedType.hasOwnProperty(opt) ) { this.parseOptType(opt, not); continue; @@ -1342,10 +1353,6 @@ FilterParser.prototype.parseOptions = function(s) { this.parseOptHostnames(opt.slice(7)); continue; } - if ( opt === 'popup' ) { - this.parseOptType('popup', not); - continue; - } if ( opt === 'important' ) { this.important = Important; continue; diff --git a/src/js/traffic.js b/src/js/traffic.js index e69fae310..d9ad8a44d 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -183,10 +183,16 @@ var onBeforeRootFrameRequest = function(details) { } } - // Filtering + // Static filtering: We always need the long-form result here. var snfe = µb.staticNetFilteringEngine; + + // Check for specific block + if ( result === '' && snfe.matchStringExactType(context, requestURL, 'main_frame') !== undefined ) { + result = snfe.toResultString(true); + } + + // Check for generic block if ( result === '' && snfe.matchString(context) !== undefined ) { - // We always need the long-form result here. result = snfe.toResultString(true); // https://github.com/chrisaljoudi/uBlock/issues/1128 // Do not block if the match begins after the hostname, except when