diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index bac96673c..712995b7e 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -55,7 +55,7 @@ var ThirdParty = 2 << 2; var AnyType = 0 << 4; var typeNameToTypeValue = { - 'notype': 0 << 4, + 'no_type': 0 << 4, 'stylesheet': 1 << 4, 'image': 2 << 4, 'object': 3 << 4, @@ -2336,8 +2336,8 @@ FilterContainer.prototype.matchTokens = function(bucket, url) { FilterContainer.prototype.matchStringExactType = function(context, requestURL, requestType) { // Be prepared to support unknown types - var type = typeNameToTypeValue[requestType] || 0; - if ( type === 0 ) { + var type = typeNameToTypeValue[requestType]; + if ( type === undefined ) { return undefined; } @@ -2436,7 +2436,7 @@ FilterContainer.prototype.matchString = function(context) { var type = typeNameToTypeValue[context.requestType]; if ( type === undefined ) { type = typeOtherValue; - } else if ( type > typeOtherValue ) { + } else if ( type === 0 || type > typeOtherValue ) { return this.matchStringExactType(context, context.requestURL, context.requestType); } diff --git a/src/js/traffic.js b/src/js/traffic.js index 043526c9d..7814a910d 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -169,7 +169,7 @@ var onBeforeRootFrameRequest = function(details) { pageDomain: requestDomain, requestURL: requestURL, requestHostname: requestHostname, - requestType: 'notype' + requestType: 'main_frame' }; var result = ''; @@ -196,12 +196,18 @@ var onBeforeRootFrameRequest = function(details) { var snfe = µb.staticNetFilteringEngine; // Check for specific block - if ( result === '' && snfe.matchStringExactType(context, requestURL, 'main_frame') !== undefined ) { + if ( + result === '' && + snfe.matchStringExactType(context, requestURL, 'main_frame') !== undefined + ) { result = snfe.toResultString(true); } // Check for generic block - if ( result === '' && snfe.matchString(context) !== undefined ) { + if ( + result === '' && + snfe.matchStringExactType(context, requestURL, 'no_type') !== undefined + ) { result = snfe.toResultString(true); // https://github.com/chrisaljoudi/uBlock/issues/1128 // Do not block if the match begins after the hostname, except when