mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-06 19:02:30 +01:00
this partially addresses #236
This commit is contained in:
parent
2e11b38a67
commit
8d961a3bb6
@ -701,26 +701,41 @@ FilterContainer.prototype.freezeHighGenerics = function(what) {
|
|||||||
var selectors = this['highGeneric' + what];
|
var selectors = this['highGeneric' + what];
|
||||||
|
|
||||||
// ["title"] and ["alt"] will go in high-low generic bin.
|
// ["title"] and ["alt"] will go in high-low generic bin.
|
||||||
// [href^="..."] wil go in high-mdium generic bin.
|
var highLowGenericProp = 'highLowGeneric' + what;
|
||||||
// The rest will be put in the high-high generic bin.
|
var highLowGeneric = this[highLowGenericProp];
|
||||||
var highLowGeneric = {};
|
|
||||||
var highLowGenericCount = 0;
|
var highLowGenericCount = 0;
|
||||||
var highMediumGeneric = {};
|
|
||||||
|
// [href^="..."] will go in high-medium generic bin.
|
||||||
|
var highMediumGenericProp = 'highMediumGeneric' + what;
|
||||||
|
var highMediumGeneric = this[highMediumGenericProp];
|
||||||
var highMediumGenericCount = 0;
|
var highMediumGenericCount = 0;
|
||||||
|
|
||||||
|
// The rest will be put in the high-high generic bin.
|
||||||
|
// https://github.com/gorhill/uBlock/issues/236
|
||||||
|
// Insert whatever we already have
|
||||||
var highHighGeneric = [];
|
var highHighGeneric = [];
|
||||||
|
var highHighGenericProp = 'highHighGeneric' + what;
|
||||||
|
if ( this[highHighGenericProp] !== '' ) {
|
||||||
|
highHighGeneric.push(this[highHighGenericProp]);
|
||||||
|
}
|
||||||
|
var highHighGenericCount = 0;
|
||||||
|
|
||||||
var reHighLow = /^[a-z]*(\[(?:alt|title)="[^"]+"\])$/;
|
var reHighLow = /^[a-z]*(\[(?:alt|title)="[^"]+"\])$/;
|
||||||
var reHighMedium = /^\[href\^="https?:\/\/([^"]{8})[^"]*"\]$/;
|
var reHighMedium = /^\[href\^="https?:\/\/([^"]{8})[^"]*"\]$/;
|
||||||
var matches, hash;
|
var matches, hash;
|
||||||
|
|
||||||
for ( var selector in selectors ) {
|
for ( var selector in selectors ) {
|
||||||
if ( selectors.hasOwnProperty(selector) === false ) {
|
if ( selectors.hasOwnProperty(selector) === false ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// ["title"] and ["alt"] will go in high-low generic bin.
|
||||||
matches = reHighLow.exec(selector);
|
matches = reHighLow.exec(selector);
|
||||||
if ( matches && matches.length === 2 ) {
|
if ( matches && matches.length === 2 ) {
|
||||||
highLowGeneric[matches[1]] = true;
|
highLowGeneric[matches[1]] = true;
|
||||||
highLowGenericCount += 1;
|
highLowGenericCount += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// [href^="..."] will go in high-medium generic bin.
|
||||||
matches = reHighMedium.exec(selector);
|
matches = reHighMedium.exec(selector);
|
||||||
if ( matches && matches.length === 2 ) {
|
if ( matches && matches.length === 2 ) {
|
||||||
hash = matches[1];
|
hash = matches[1];
|
||||||
@ -732,14 +747,17 @@ FilterContainer.prototype.freezeHighGenerics = function(what) {
|
|||||||
highMediumGenericCount += 1;
|
highMediumGenericCount += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// All else
|
||||||
highHighGeneric.push(selector);
|
highHighGeneric.push(selector);
|
||||||
|
highHighGenericCount += 1;
|
||||||
}
|
}
|
||||||
this['highLowGeneric' + what] = highLowGeneric;
|
|
||||||
this['highLowGeneric' + what + 'Count'] = highLowGenericCount;
|
this[highLowGenericProp + 'Count'] += highLowGenericCount;
|
||||||
this['highMediumGeneric' + what] = highMediumGeneric;
|
this[highMediumGenericProp + 'Count'] += highMediumGenericCount;
|
||||||
this['highMediumGeneric' + what + 'Count'] = highMediumGenericCount;
|
this[highHighGenericProp] = highHighGeneric.join(',\n');
|
||||||
this['highHighGeneric' + what] = highHighGeneric.join(',\n');
|
this[highHighGenericProp + 'Count'] += highHighGenericCount;
|
||||||
this['highHighGeneric' + what + 'Count'] = highHighGeneric.length;
|
|
||||||
|
// Empty cumulated selectors
|
||||||
this['highGeneric' + what] = {};
|
this['highGeneric' + what] = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user