From de587335bd5144f6fc866438a4077ea0c9085809 Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 27 Oct 2016 08:33:19 -0400 Subject: [PATCH] `elemhide` is (and has always been) really `generichide` --- src/js/logger-ui.js | 2 +- src/js/pagestore.js | 6 ++-- src/js/static-net-filtering.js | 62 +++++++++++++--------------------- 3 files changed, 27 insertions(+), 43 deletions(-) diff --git a/src/js/logger-ui.js b/src/js/logger-ui.js index 03c2d65d4..08f299401 100644 --- a/src/js/logger-ui.js +++ b/src/js/logger-ui.js @@ -176,7 +176,7 @@ var filterDecompiler = (function() { 10: 'other', 11: 'popunder', 12: 'document', - 13: 'elemhide', + 13: 'generichide', 14: 'inline-script', 15: 'popup' }; diff --git a/src/js/pagestore.js b/src/js/pagestore.js index 36ec7e276..5470096ee 100644 --- a/src/js/pagestore.js +++ b/src/js/pagestore.js @@ -334,16 +334,14 @@ PageStore.prototype.init = function(tabId) { this.noGenericCosmeticFiltering = µb.staticNetFilteringEngine.matchStringExactType( this.createContextFromPage(), tabContext.normalURL, - 'elemhide' + 'generichide' ) === false; if ( µb.logger.isEnabled() && this.noGenericCosmeticFiltering ) { - // https://github.com/gorhill/uBlock/issues/370 - // Log using `cosmetic-filtering`, not `elemhide`. µb.logger.writeOne( tabId, 'net', µb.staticNetFilteringEngine.toResultString(true), - 'elemhide', + 'generichide', tabContext.rawURL, this.tabHostname, this.tabHostname diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index a7d73d85b..3073741bf 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -68,7 +68,7 @@ var typeNameToTypeValue = { 'other': 10 << 4, 'popunder': 11 << 4, 'main_frame': 12 << 4, - 'elemhide': 13 << 4, + 'generichide': 13 << 4, 'inline-script': 14 << 4, 'popup': 15 << 4 }; @@ -87,7 +87,7 @@ var typeValueToTypeName = { 10: 'other', 11: 'popunder', 12: 'document', - 13: 'elemhide', + 13: 'generichide', 14: 'inline-script', 15: 'popup' }; @@ -337,57 +337,42 @@ var hostnameMissTest = function(owner) { }; var hostnameHitSetTest = function(owner) { - var dict = owner._hostnameDict; - var needle = pageHostnameRegister; - var pos; + var dict = owner._hostnameDict, + needle = pageHostnameRegister, + pos; for (;;) { - if ( dict.has(needle) ) { - return true; - } + if ( dict.has(needle) ) { return true; } pos = needle.indexOf('.'); - if ( pos === -1 ) { - break; - } + if ( pos === -1 ) { break; } needle = needle.slice(pos + 1); } return false; }; var hostnameMissSetTest = function(owner) { - var dict = owner._hostnameDict; - var needle = pageHostnameRegister; - var pos; + var dict = owner._hostnameDict, + needle = pageHostnameRegister, + pos; for (;;) { - if ( dict.has(needle) ) { - return false; - } + if ( dict.has(needle) ) { return false; } pos = needle.indexOf('.'); - if ( pos === -1 ) { - break; - } + if ( pos === -1 ) { break; } needle = needle.slice(pos + 1); } - return true; }; var hostnameMixedSetTest = function(owner) { - var dict = owner._hostnameDict; - var needle = pageHostnameRegister; - var hit = false; - var v, pos; + var dict = owner._hostnameDict, + needle = pageHostnameRegister, + hit = false, + v, pos; for (;;) { v = dict.get(needle); - if ( v === false ) { - return false; - } - if ( v === true ) { - hit = true; - } + if ( v === false ) { return false; } + if ( v === true ) { hit = true; } pos = needle.indexOf('.'); - if ( pos === -1 ) { - break; - } + if ( pos === -1 ) { break; } needle = needle.slice(pos + 1); } return hit; @@ -1180,7 +1165,8 @@ FilterParser.prototype.toNormalizedType = { 'other': 'other', 'popunder': 'popunder', 'document': 'main_frame', - 'elemhide': 'elemhide', + 'generichide': 'generichide', + 'elemhide': 'generichide', 'inline-script': 'inline-script', 'popup': 'popup' }; @@ -1272,7 +1258,7 @@ FilterParser.prototype.parseOptions = function(s) { // adding support for the new keyword. if ( opt === 'elemhide' || opt === 'generichide' ) { if ( this.action === AllowAction ) { - this.parseOptType('elemhide', false); + this.parseOptType('generichide', false); continue; } this.unsupported = true; @@ -2223,9 +2209,9 @@ FilterContainer.prototype.matchStringExactType = function(context, requestURL, r var key, bucket; // https://github.com/gorhill/uBlock/issues/1477 - // Special case: blocking elemhide filter ALWAYS exists, it is implicit -- + // Special case: blocking generichide filter ALWAYS exists, it is implicit -- // thus we always and only check for exception filters. - if ( requestType === 'elemhide' ) { + if ( requestType === 'generichide' ) { key = AllowAnyParty | type; if ( (bucket = categories.get(toHex(key))) &&