| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 regexpString = propertyExpression.slice(1, -1) | 239 regexpString = propertyExpression.slice(1, -1) |
| 240 .replace("\\x7B ", "{").replace("\\x7D ", "}"); | 240 .replace("\\x7B ", "{").replace("\\x7D ", "}"); |
| 241 } | 241 } |
| 242 else | 242 else |
| 243 regexpString = filterToRegExp(propertyExpression); | 243 regexpString = filterToRegExp(propertyExpression); |
| 244 | 244 |
| 245 this._regexp = new RegExp(regexpString, "i"); | 245 this._regexp = new RegExp(regexpString, "i"); |
| 246 } | 246 } |
| 247 | 247 |
| 248 PropsSelector.prototype = { | 248 PropsSelector.prototype = { |
| 249 preferHideWithSelector: true, |
| 250 |
| 249 *findPropsSelectors(styles, prefix, regexp) | 251 *findPropsSelectors(styles, prefix, regexp) |
| 250 { | 252 { |
| 251 for (let style of styles) | 253 for (let style of styles) |
| 252 if (regexp.test(style.style)) | 254 if (regexp.test(style.style)) |
| 253 for (let subSelector of style.subSelectors) | 255 for (let subSelector of style.subSelectors) |
| 254 yield prefix + subSelector; | 256 yield prefix + subSelector; |
| 255 }, | 257 }, |
| 256 | 258 |
| 257 *getSelectors(prefix, subtree, styles) | 259 *getSelectors(prefix, subtree, styles) |
| 258 { | 260 { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 cssStyles.push(stringifyStyle(rule)); | 371 cssStyles.push(stringifyStyle(rule)); |
| 370 } | 372 } |
| 371 } | 373 } |
| 372 | 374 |
| 373 let {document} = this.window; | 375 let {document} = this.window; |
| 374 for (let pattern of this.patterns) | 376 for (let pattern of this.patterns) |
| 375 { | 377 { |
| 376 for (let selector of evaluate(pattern.selectors, | 378 for (let selector of evaluate(pattern.selectors, |
| 377 0, "", document, cssStyles)) | 379 0, "", document, cssStyles)) |
| 378 { | 380 { |
| 379 if (!pattern.selectors.some(s => s.requiresHiding)) | 381 if (pattern.selectors.some(s => s.preferHideWithSelector) && |
| 382 !pattern.selectors.some(s => s.requiresHiding)) |
| 380 { | 383 { |
| 381 selectors.push(selector); | 384 selectors.push(selector); |
| 382 selectorFilters.push(pattern.text); | 385 selectorFilters.push(pattern.text); |
| 383 } | 386 } |
| 384 else | 387 else |
| 385 { | 388 { |
| 386 for (let element of document.querySelectorAll(selector)) | 389 for (let element of document.querySelectorAll(selector)) |
| 387 { | 390 { |
| 388 elements.push(element); | 391 elements.push(element); |
| 389 elementFilters.push(pattern.text); | 392 elementFilters.push(pattern.text); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 417 | 420 |
| 418 if (this.patterns.length > 0) | 421 if (this.patterns.length > 0) |
| 419 { | 422 { |
| 420 let {document} = this.window; | 423 let {document} = this.window; |
| 421 this.addSelectors(document.styleSheets); | 424 this.addSelectors(document.styleSheets); |
| 422 document.addEventListener("load", this.onLoad.bind(this), true); | 425 document.addEventListener("load", this.onLoad.bind(this), true); |
| 423 } | 426 } |
| 424 }); | 427 }); |
| 425 } | 428 } |
| 426 }; | 429 }; |
| OLD | NEW |