Index: lib/filterClasses.js |
=================================================================== |
--- a/lib/filterClasses.js |
+++ b/lib/filterClasses.js |
@@ -921,16 +921,18 @@ |
selectorDomain: null, |
/** |
* CSS selector for the HTML elements that should be hidden |
* @type {string} |
*/ |
selector: null |
}); |
+var abpSelectorRegExp = /\[-abp-selector=(["'])(.+)\1\]/; |
+ |
/** |
* Creates an element hiding filter from a pre-parsed text representation |
* |
* @param {string} text same as in Filter() |
* @param {string} domain |
* domain part of the text representation (can be empty) |
* @param {boolean} isException exception rule indicator |
* @param {string} tagName tag name part (can be empty) |
@@ -983,23 +985,32 @@ |
// Note: The ElemHide.prototype.domainSeparator is duplicated here, if that |
// changes this must be changed too. |
if (domain && /(^|,)~?(,|$)/.test(domain)) |
return new InvalidFilter(text, "filter_invalid_domain"); |
if (isException) |
return new ElemHideException(text, domain, selector); |
- if (selector.indexOf("[-abp-properties=") != -1) |
+ if ((selector.indexOf("[-abp-properties=") != -1) || |
+ (selector.indexOf("[-abp-selector=") != -1)) |
{ |
// Element hiding emulation filters are inefficient so we need to make sure |
// that they're only applied if they specify active domains |
if (!/,[^~][^,.]*\.[^,]/.test("," + domain)) |
return new InvalidFilter(text, "filter_elemhideemulation_nodomain"); |
+ var match = abpSelectorRegExp.exec(selector); |
+ if (match) |
+ { |
+ var prefix = selector.substr(0, match.index).trim(); |
+ var suffix = selector.substr(match.index + match[0].length).trim(); |
+ var unwrappedSelector = prefix + match[2] + suffix; |
+ return new ElemHideEmulationFilter(text, domain, unwrappedSelector); |
+ } |
return new ElemHideEmulationFilter(text, domain, selector); |
} |
return new ElemHideFilter(text, domain, selector); |
}; |
/** |
* Class for element hiding filters |