Left: | ||
Right: |
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 |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 | 404 |
405 let elements = []; | 405 let elements = []; |
406 let elementFilters = []; | 406 let elementFilters = []; |
407 | 407 |
408 let cssStyles = []; | 408 let cssStyles = []; |
409 | 409 |
410 let stylesheetOnlyChange = !!stylesheets; | 410 let stylesheetOnlyChange = !!stylesheets; |
411 if (!stylesheets) | 411 if (!stylesheets) |
412 stylesheets = this.document.styleSheets; | 412 stylesheets = this.document.styleSheets; |
413 | 413 |
414 for (let stylesheet of stylesheets) | 414 try |
415 { | 415 { |
416 // Explicitly ignore third-party stylesheets to ensure consistent behavior | 416 for (let stylesheet of stylesheets) |
417 // between Firefox and Chrome. | 417 { |
418 if (!this.isSameOrigin(stylesheet)) | 418 try |
419 continue; | 419 { |
420 // Explicitly ignore third-party stylesheets to ensure consistent beha vior | |
kzar
2017/11/03 10:20:50
Nit: This line is too long, did you check the code
| |
421 // between Firefox and Chrome. | |
422 if (!this.isSameOrigin(stylesheet)) | |
423 continue; | |
420 | 424 |
421 let rules = stylesheet.cssRules; | 425 let rules = stylesheet.cssRules; |
422 if (!rules) | 426 if (!rules) |
423 continue; | 427 continue; |
424 | 428 |
425 for (let rule of rules) | 429 for (let rule of rules) |
426 { | 430 { |
427 if (rule.type != rule.STYLE_RULE) | 431 if (rule.type != rule.STYLE_RULE) |
428 continue; | 432 continue; |
429 | 433 |
430 cssStyles.push(stringifyStyle(rule)); | 434 cssStyles.push(stringifyStyle(rule)); |
435 } | |
436 } | |
437 catch (e) | |
438 { | |
439 // On Firefox we seem to get a InvalidAccessError when | |
kzar
2017/11/03 10:20:50
Nit: "...get an...".
| |
440 // accessing the stylesheet under some circumstances. | |
441 } | |
431 } | 442 } |
432 } | 443 } |
444 catch (e) | |
445 { | |
446 // On Firefox we seem to get a InvalidAccessError when | |
kzar
2017/11/03 10:20:50
Maybe combine these two identical comments and add
| |
447 // enumerating the stylesheet under some circumstances. | |
448 } | |
433 | 449 |
434 let patterns = this.patterns.slice(); | 450 let patterns = this.patterns.slice(); |
435 let pattern = null; | 451 let pattern = null; |
436 let generator = null; | 452 let generator = null; |
437 | 453 |
438 let processPatterns = () => | 454 let processPatterns = () => |
439 { | 455 { |
440 let cycleStart = performance.now(); | 456 let cycleStart = performance.now(); |
441 | 457 |
442 if (!pattern) | 458 if (!pattern) |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 characterData: true, | 607 characterData: true, |
592 subtree: true | 608 subtree: true |
593 } | 609 } |
594 ); | 610 ); |
595 this.document.addEventListener("load", this.onLoad.bind(this), true); | 611 this.document.addEventListener("load", this.onLoad.bind(this), true); |
596 } | 612 } |
597 } | 613 } |
598 }; | 614 }; |
599 | 615 |
600 exports.ElemHideEmulation = ElemHideEmulation; | 616 exports.ElemHideEmulation = ElemHideEmulation; |
OLD | NEW |