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]; node = nodeList[iNode];
attrValue = node.getAttribute(attr); attrValue = node.getAttribute(attr);
if ( !attrValue ) { continue; } 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 + '"]'; selector = '[' + attr + '="' + attrValue + '"]';
if ( generics[selector] ) { if ( generics.hasOwnProperty(selector) ) {
if ( injectedSelectors.hasOwnProperty(selector) === false ) { if ( injectedSelectors.hasOwnProperty(selector) === false ) {
injectedSelectors[selector] = true; injectedSelectors[selector] = true;
out.push(selector); out.push(selector);
continue;
} }
} }
// Candidate 2 = specific form
selector = node.tagName.toLowerCase() + selector; selector = node.tagName.toLowerCase() + selector;
if ( generics[selector] ) { if ( generics.hasOwnProperty(selector) ) {
if ( injectedSelectors.hasOwnProperty(selector) === false ) { if ( injectedSelectors.hasOwnProperty(selector) === false ) {
injectedSelectors[selector] = true; injectedSelectors[selector] = true;
out.push(selector); out.push(selector);

View File

@ -778,7 +778,9 @@ FilterContainer.prototype.freezeHighGenerics = function(what) {
} }
var highHighGenericCount = 0; 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 reHighMedium = /^\[href\^="https?:\/\/([^"]{8})[^"]*"\]$/;
var matches, hash; var matches, hash;
@ -788,8 +790,8 @@ FilterContainer.prototype.freezeHighGenerics = function(what) {
} }
// ["title"] and ["alt"] will go in high-low generic bin. // ["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 === 1 ) {
highLowGeneric[matches[1]] = true; highLowGeneric[matches[0]] = true;
highLowGenericCount += 1; highLowGenericCount += 1;
continue; continue;
} }