| Index: chrome/content/elemHideEmulation.js |
| =================================================================== |
| --- a/chrome/content/elemHideEmulation.js |
| +++ b/chrome/content/elemHideEmulation.js |
| @@ -88,17 +88,17 @@ |
| if (selector) |
| newSelector += " > "; |
| return makeSelector(node.parentElement, newSelector + selector); |
| } |
| return selector; |
| } |
| -const abpSelectorRegexp = /:-abp-(properties|has|[A-Za-z\d-]*)\(/i; |
| +const abpSelectorRegexp = /:-abp-(properties|has|contains|[A-Za-z\d-]*)\(/i; |
| function parseSelectorContent(content, quoted = false) |
| { |
| let parens = 1; |
| let i = 0; |
| let quote = null; |
| let originalLength = content.length; |
| if (quoted) |
| @@ -191,16 +191,22 @@ |
| return null; |
| } |
| let hasSelector = new HasSelector(content.text); |
| if (!hasSelector.valid()) |
| return null; |
| selectors.push(hasSelector); |
| } |
| + else if (match[1] == "contains") |
| + { |
| + content = parseSelectorContent(selector.substr(startIndex), true); |
| + |
| + selectors.push(new ContainsSelector(content.text)); |
| + } |
| else |
| { |
| // this is an error, can't parse selector. |
| console.error(new SyntaxError("Failed parsing AdBlock Plus " + |
| `selector ${selector}, invalid ` + |
| `pseudo-class -abp-${match[1]}.`)); |
| return null; |
| } |
| @@ -315,16 +321,40 @@ |
| // we insert a space between the two. It becomes a no-op if selector |
| // doesn't have a combinator |
| if (subtree.querySelector(newPrefix + " " + selector)) |
| yield element; |
| } |
| } |
| }; |
| +function ContainsSelector(textContent) |
| +{ |
| + this._text = textContent; |
| +} |
| + |
| +ContainsSelector.prototype = { |
| + |
| + *getSelectors(prefix, subtree, stylesheet) |
| + { |
| + for (let element of this.getElements(prefix, subtree, stylesheet)) |
| + yield [makeSelector(element, ""), subtree]; |
| + }, |
| + |
| + *getElements(prefix, subtree, stylesheet) |
| + { |
| + let actualPrefix = (!prefix || prefixEndRegexp.test(prefix)) ? |
| + prefix + "*" : prefix; |
| + let elements = subtree.querySelectorAll(actualPrefix); |
| + for (let element of elements) |
| + if (element.textContent == this._text) |
| + yield element; |
| + } |
| +}; |
| + |
| function PropsSelector(propertyExpression) |
| { |
| let regexpString; |
| if (propertyExpression.length >= 2 && propertyExpression[0] == "/" && |
| propertyExpression[propertyExpression.length - 1] == "/") |
| { |
| regexpString = propertyExpression.slice(1, -1) |
| .replace("\\x7B ", "{").replace("\\x7D ", "}"); |