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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 "use strict"; | 18 "use strict"; |
19 | 19 |
20 const {textToRegExp, filterToRegExp, splitSelector} = require("../common"); | 20 const {textToRegExp, filterToRegExp, splitSelector, |
| 21 qualifySelector} = require("../common"); |
21 const {indexOf} = require("../coreUtils"); | 22 const {indexOf} = require("../coreUtils"); |
22 | 23 |
23 let MIN_INVOCATION_INTERVAL = 3000; | 24 let MIN_INVOCATION_INTERVAL = 3000; |
24 const MAX_SYNCHRONOUS_PROCESSING_TIME = 50; | 25 const MAX_SYNCHRONOUS_PROCESSING_TIME = 50; |
25 const abpSelectorRegexp = /:-abp-([\w-]+)\(/i; | 26 const abpSelectorRegexp = /:-abp-([\w-]+)\(/i; |
26 | 27 |
27 function getCachedPropertyValue(object, name, defaultValueFunc = () => {}) | 28 function getCachedPropertyValue(object, name, defaultValueFunc = () => {}) |
28 { | 29 { |
29 let value = object[name]; | 30 let value = object[name]; |
30 if (typeof value == "undefined") | 31 if (typeof value == "undefined") |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 for (let subSelector of style.subSelectors) | 378 for (let subSelector of style.subSelectors) |
378 { | 379 { |
379 if (subSelector.startsWith("*") && | 380 if (subSelector.startsWith("*") && |
380 !incompletePrefixRegexp.test(prefix)) | 381 !incompletePrefixRegexp.test(prefix)) |
381 { | 382 { |
382 subSelector = subSelector.substr(1); | 383 subSelector = subSelector.substr(1); |
383 } | 384 } |
384 let idx = subSelector.lastIndexOf("::"); | 385 let idx = subSelector.lastIndexOf("::"); |
385 if (idx != -1) | 386 if (idx != -1) |
386 subSelector = subSelector.substr(0, idx); | 387 subSelector = subSelector.substr(0, idx); |
387 yield prefix + subSelector; | 388 yield qualifySelector(subSelector, prefix); |
388 } | 389 } |
389 }, | 390 }, |
390 | 391 |
391 *getSelectors(prefix, subtree, styles) | 392 *getSelectors(prefix, subtree, styles) |
392 { | 393 { |
393 for (let selector of this.findPropsSelectors(styles, prefix, this._regexp)) | 394 for (let selector of this.findPropsSelectors(styles, prefix, this._regexp)) |
394 yield [selector, subtree]; | 395 yield [selector, subtree]; |
395 } | 396 } |
396 }; | 397 }; |
397 | 398 |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 characterData: shouldObserveCharacterData(this.patterns), | 866 characterData: shouldObserveCharacterData(this.patterns), |
866 subtree: true | 867 subtree: true |
867 } | 868 } |
868 ); | 869 ); |
869 this.document.addEventListener("load", this.onLoad.bind(this), true); | 870 this.document.addEventListener("load", this.onLoad.bind(this), true); |
870 } | 871 } |
871 } | 872 } |
872 }; | 873 }; |
873 | 874 |
874 exports.ElemHideEmulation = ElemHideEmulation; | 875 exports.ElemHideEmulation = ElemHideEmulation; |
OLD | NEW |