1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-18 08:52:26 +02:00

this addresses #909

This commit is contained in:
gorhill 2015-11-19 09:36:15 -05:00
parent dec3237991
commit 7c4d1f510a

View File

@ -119,15 +119,14 @@ var filterPlain = new FilterPlain();
// #center_col > div[style="font-size:14px;margin-right:0;min-height:5px"] ... // #center_col > div[style="font-size:14px;margin-right:0;min-height:5px"] ...
// #adframe:not(frameset) // #adframe:not(frameset)
// .l-container > #fishtank // .l-container > #fishtank
// body #sliding-popup
var FilterPlainMore = function(s) { var FilterPlainMore = function(s) {
this.s = s; this.s = s;
}; };
FilterPlainMore.prototype.retrieve = function(s, out) { FilterPlainMore.prototype.retrieve = function(s, out) {
if ( this.s.lastIndexOf(s, 0) === 0 ) { out.push(this.s);
out.push(this.s);
}
}; };
FilterPlainMore.prototype.fid = '#+'; FilterPlainMore.prototype.fid = '#+';
@ -746,35 +745,47 @@ FilterContainer.prototype.compileGenericSelector = function(parsed, out) {
return; return;
} }
if ( this.isValidSelector(selector) !== true ) {
return;
}
// ["title"] and ["alt"] will go in high-low generic bin. // ["title"] and ["alt"] will go in high-low generic bin.
if ( this.reHighLow.test(selector) ) { if ( this.reHighLow.test(selector) ) {
if ( this.isValidSelector(selector) ) { out.push('c\vhlg0\v' + selector);
out.push('c\vhlg0\v' + selector);
}
return; return;
} }
// [href^="..."] will go in high-medium generic bin. // [href^="..."] will go in high-medium generic bin.
matches = this.reHighMedium.exec(selector); matches = this.reHighMedium.exec(selector);
if ( matches && matches.length === 2 ) { if ( matches && matches.length === 2 ) {
if ( this.isValidSelector(selector) ) { out.push(
out.push( 'c\vhmg0\v' +
'c\vhmg0\v' + matches[1] + '\v' +
matches[1] + '\v' + selector
selector );
); return;
} }
// https://github.com/gorhill/uBlock/issues/909
// Anything which contains a plain id/class selector can be classified
// as a low generic cosmetic filter.
matches = this.rePlainSelectorEx.exec(selector);
if ( matches && matches.length === 2 ) {
out.push(
'c\vlg+\v' +
matches[1] + '\v' +
selector
);
return; return;
} }
// All else // All else
if ( this.isValidSelector(selector) ) { out.push('c\vhhg0\v' + selector);
out.push('c\vhhg0\v' + selector);
}
}; };
FilterContainer.prototype.reClassOrIdSelector = /^[#.][\w-]+$/; FilterContainer.prototype.reClassOrIdSelector = /^[#.][\w-]+$/;
FilterContainer.prototype.rePlainSelector = /^[#.][\w-]+/; FilterContainer.prototype.rePlainSelector = /^[#.][\w-]+/;
FilterContainer.prototype.rePlainSelectorEx = /^[^#.\[(]+([#.][\w-]+)/;
FilterContainer.prototype.reHighLow = /^[a-z]*\[(?:alt|title)="[^"]+"\]$/; FilterContainer.prototype.reHighLow = /^[a-z]*\[(?:alt|title)="[^"]+"\]$/;
FilterContainer.prototype.reHighMedium = /^\[href\^="https?:\/\/([^"]{8})[^"]*"\]$/; FilterContainer.prototype.reHighMedium = /^\[href\^="https?:\/\/([^"]{8})[^"]*"\]$/;