This commit is contained in:
gorhill 2015-01-01 19:09:40 -05:00
parent 8562f70144
commit 33d73b343d
2 changed files with 12 additions and 5 deletions

View File

@ -259,15 +259,20 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
node = nodeList[iNode];
attrValue = node.getAttribute(attr);
if ( !attrValue ) { continue; }
// Candidate 1 = generic form
// If specific form is injected, no need to process specific
// form, as the generic will affect all related specific forms
selector = '[' + attr + '="' + attrValue + '"]';
if ( generics[selector] ) {
if ( generics.hasOwnProperty(selector) ) {
if ( injectedSelectors.hasOwnProperty(selector) === false ) {
injectedSelectors[selector] = true;
out.push(selector);
continue;
}
}
// Candidate 2 = specific form
selector = node.tagName.toLowerCase() + selector;
if ( generics[selector] ) {
if ( generics.hasOwnProperty(selector) ) {
if ( injectedSelectors.hasOwnProperty(selector) === false ) {
injectedSelectors[selector] = true;
out.push(selector);

View File

@ -778,7 +778,9 @@ FilterContainer.prototype.freezeHighGenerics = function(what) {
}
var highHighGenericCount = 0;
var reHighLow = /^[a-z]*(\[(?:alt|title)="[^"]+"\])$/;
// https://github.com/gorhill/uBlock/issues/456
// Include tag name, it's part of the filter
var reHighLow = /^[a-z]*\[(?:alt|title)="[^"]+"\]$/;
var reHighMedium = /^\[href\^="https?:\/\/([^"]{8})[^"]*"\]$/;
var matches, hash;
@ -788,8 +790,8 @@ FilterContainer.prototype.freezeHighGenerics = function(what) {
}
// ["title"] and ["alt"] will go in high-low generic bin.
matches = reHighLow.exec(selector);
if ( matches && matches.length === 2 ) {
highLowGeneric[matches[1]] = true;
if ( matches && matches.length === 1 ) {
highLowGeneric[matches[0]] = true;
highLowGenericCount += 1;
continue;
}