1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00
This commit is contained in:
gorhill 2016-03-15 11:18:34 -04:00
parent 2ac643b520
commit 74905aa2a5
4 changed files with 28 additions and 37 deletions

View File

@ -93,7 +93,7 @@ return {
// read-only // read-only
systemSettings: { systemSettings: {
compiledMagic: 'ythmhjvufkkq', compiledMagic: 'nytangedtvcz',
selfieMagic: 'xtsldiywhvgc' selfieMagic: 'xtsldiywhvgc'
}, },

View File

@ -273,10 +273,6 @@ var filterDecompiler = (function() {
var typeVal = bits >>> 4 & 0x0F; var typeVal = bits >>> 4 & 0x0F;
if ( typeVal ) { if ( typeVal ) {
opts.push(typeValToTypeName[typeVal]); opts.push(typeValToTypeName[typeVal]);
// Because of the way `elemhide` is implemented
if ( typeVal === 13 ) {
filter = '@@' + filter;
}
} }
if ( opts.length !== 0 ) { if ( opts.length !== 0 ) {
filter += '$' + opts.join(','); filter += '$' + opts.join(',');

View File

@ -320,8 +320,8 @@ PageStore.prototype.init = function(tabId) {
this.skipCosmeticFiltering = µb.staticNetFilteringEngine.matchStringExactType( this.skipCosmeticFiltering = µb.staticNetFilteringEngine.matchStringExactType(
this.createContextFromPage(), this.createContextFromPage(),
tabContext.normalURL, tabContext.normalURL,
'cosmetic-filtering' 'elemhide'
); ) === false;
if ( this.skipCosmeticFiltering && µb.logger.isEnabled() ) { if ( this.skipCosmeticFiltering && µb.logger.isEnabled() ) {
// https://github.com/gorhill/uBlock/issues/370 // https://github.com/gorhill/uBlock/issues/370
// Log using `cosmetic-filtering`, not `elemhide`. // Log using `cosmetic-filtering`, not `elemhide`.
@ -329,7 +329,7 @@ PageStore.prototype.init = function(tabId) {
tabId, tabId,
'net', 'net',
µb.staticNetFilteringEngine.toResultString(true), µb.staticNetFilteringEngine.toResultString(true),
'cosmetic-filtering', 'elemhide',
tabContext.rawURL, tabContext.rawURL,
this.tabHostname, this.tabHostname,
this.tabHostname this.tabHostname

View File

@ -67,7 +67,7 @@ var typeNameToTypeValue = {
'other': 10 << 4, 'other': 10 << 4,
'popunder': 11 << 4, 'popunder': 11 << 4,
'main_frame': 12 << 4, 'main_frame': 12 << 4,
'cosmetic-filtering': 13 << 4, 'elemhide': 13 << 4,
'inline-script': 14 << 4, 'inline-script': 14 << 4,
'popup': 15 << 4 'popup': 15 << 4
}; };
@ -86,7 +86,7 @@ var typeValueToTypeName = {
10: 'other', 10: 'other',
11: 'popunder', 11: 'popunder',
12: 'document', 12: 'document',
13: 'cosmetic-filtering', 13: 'elemhide',
14: 'inline-script', 14: 'inline-script',
15: 'popup' 15: 'popup'
}; };
@ -1316,7 +1316,7 @@ FilterParser.prototype.toNormalizedType = {
'other': 'other', 'other': 'other',
'popunder': 'popunder', 'popunder': 'popunder',
'document': 'main_frame', 'document': 'main_frame',
'elemhide': 'cosmetic-filtering', 'elemhide': 'elemhide',
'inline-script': 'inline-script', 'inline-script': 'inline-script',
'popup': 'popup' 'popup': 'popup'
}; };
@ -1359,11 +1359,13 @@ FilterParser.prototype.parseOptType = function(raw, not) {
} }
// Negated type: set all valid network request type bits to 1 // Negated type: set all valid network request type bits to 1
if ( this.types === 0 ) { if (
this.types = allNetRequestTypesBitmap; (typeBit & allNetRequestTypesBitmap) !== 0 &&
(this.types & allNetRequestTypesBitmap) === 0
) {
this.types |= allNetRequestTypesBitmap;
} }
this.types &= ~typeBit;
this.types &= ~typeBit & allNetRequestTypesBitmap;
}; };
/******************************************************************************/ /******************************************************************************/
@ -1401,7 +1403,6 @@ FilterParser.prototype.parseOptions = function(s) {
if ( opt === 'elemhide' || opt === 'generichide' ) { if ( opt === 'elemhide' || opt === 'generichide' ) {
if ( this.action === AllowAction ) { if ( this.action === AllowAction ) {
this.parseOptType('elemhide', false); this.parseOptType('elemhide', false);
this.action = BlockAction;
continue; continue;
} }
this.unsupported = true; this.unsupported = true;
@ -2321,6 +2322,21 @@ FilterContainer.prototype.matchStringExactType = function(context, requestURL, r
var categories = this.categories; var categories = this.categories;
var key, bucket; var key, bucket;
// https://github.com/gorhill/uBlock/issues/1477
// Special case: blocking elemhide filter ALWAYS exists, it is implicit --
// thus we always and only check for exception filters.
if ( requestType === 'elemhide' ) {
key = AllowAnyParty | type;
if (
(bucket = categories[toHex(key)]) &&
this.matchTokens(bucket, url)
) {
this.keyRegister = key;
return false;
}
return undefined;
}
// https://github.com/chrisaljoudi/uBlock/issues/139 // https://github.com/chrisaljoudi/uBlock/issues/139
// Test against important block filters // Test against important block filters
key = BlockAnyParty | Important | type; key = BlockAnyParty | Important | type;
@ -2338,27 +2354,6 @@ FilterContainer.prototype.matchStringExactType = function(context, requestURL, r
} }
} }
// Test against block filters
key = BlockAnyParty | type;
if ( (bucket = categories[toHex(key)]) ) {
if ( this.matchTokens(bucket, url) ) {
this.keyRegister = key;
}
}
if ( this.fRegister === null ) {
key = BlockAction | type | party;
if ( (bucket = categories[toHex(key)]) ) {
if ( this.matchTokens(bucket, url) ) {
this.keyRegister = key;
}
}
}
// If there is no block filter, no need to test against allow filters
if ( this.fRegister === null ) {
return undefined;
}
// Test against allow filters // Test against allow filters
key = AllowAnyParty | type; key = AllowAnyParty | type;
if ( (bucket = categories[toHex(key)]) ) { if ( (bucket = categories[toHex(key)]) ) {