Skip to content

Commit

Permalink
this fixes #456
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jan 2, 2015
1 parent 8562f70 commit 33d73b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/js/contentscript-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions src/js/cosmetic-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down

0 comments on commit 33d73b3

Please sign in to comment.