| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 contentType |= RegExpFilter.typeMap[option]; | 601 contentType |= RegExpFilter.typeMap[option]; |
| 602 } | 602 } |
| 603 else if (option[0] == "~" && option.substr(1) in RegExpFilter.typeMap) | 603 else if (option[0] == "~" && option.substr(1) in RegExpFilter.typeMap) |
| 604 { | 604 { |
| 605 if (contentType == null) | 605 if (contentType == null) |
| 606 contentType = RegExpFilter.prototype.contentType; | 606 contentType = RegExpFilter.prototype.contentType; |
| 607 contentType &= ~RegExpFilter.typeMap[option.substr(1)]; | 607 contentType &= ~RegExpFilter.typeMap[option.substr(1)]; |
| 608 } | 608 } |
| 609 else if (option == "MATCH_CASE") | 609 else if (option == "MATCH_CASE") |
| 610 matchCase = true; | 610 matchCase = true; |
| 611 else if (option == "~MATCH_CASE") |
| 612 matchCase = false; |
| 611 else if (option == "DOMAIN" && typeof value != "undefined") | 613 else if (option == "DOMAIN" && typeof value != "undefined") |
| 612 domains = value; | 614 domains = value; |
| 613 else if (option == "THIRD_PARTY") | 615 else if (option == "THIRD_PARTY") |
| 614 thirdParty = true; | 616 thirdParty = true; |
| 615 else if (option == "~THIRD_PARTY") | 617 else if (option == "~THIRD_PARTY") |
| 616 thirdParty = false; | 618 thirdParty = false; |
| 617 else if (option == "COLLAPSE") | 619 else if (option == "COLLAPSE") |
| 618 collapse = true; | 620 collapse = true; |
| 619 else if (option == "~COLLAPSE") | 621 else if (option == "~COLLAPSE") |
| 620 collapse = false; | 622 collapse = false; |
| 621 else if (option == "SITEKEY" && typeof value != "undefined") | 623 else if (option == "SITEKEY" && typeof value != "undefined") |
| 622 siteKeys = value.split(/\|/); | 624 siteKeys = value.split(/\|/); |
| 625 else |
| 626 return new InvalidFilter(origText, "Unknown option " + option.toLowerCas
e()); |
| 623 } | 627 } |
| 624 } | 628 } |
| 625 | 629 |
| 626 if (!blocking && (contentType == null || (contentType & RegExpFilter.typeMap.D
OCUMENT)) && | 630 if (!blocking && (contentType == null || (contentType & RegExpFilter.typeMap.D
OCUMENT)) && |
| 627 (!options || options.indexOf("DOCUMENT") < 0) && !/^\|?[\w\-]+:/.test(text
)) | 631 (!options || options.indexOf("DOCUMENT") < 0) && !/^\|?[\w\-]+:/.test(text
)) |
| 628 { | 632 { |
| 629 // Exception filters shouldn't apply to pages by default unless they start w
ith a protocol name | 633 // Exception filters shouldn't apply to pages by default unless they start w
ith a protocol name |
| 630 if (contentType == null) | 634 if (contentType == null) |
| 631 contentType = RegExpFilter.prototype.contentType; | 635 contentType = RegExpFilter.prototype.contentType; |
| 632 contentType &= ~RegExpFilter.typeMap.DOCUMENT; | 636 contentType &= ~RegExpFilter.typeMap.DOCUMENT; |
| 633 } | 637 } |
| 634 if (!blocking && siteKeys) | 638 if (!blocking && siteKeys) |
| 635 contentType = RegExpFilter.typeMap.DOCUMENT; | 639 contentType = RegExpFilter.typeMap.DOCUMENT; |
| 636 | 640 |
| 637 try | 641 try |
| 638 { | 642 { |
| 639 if (blocking) | 643 if (blocking) |
| 640 return new BlockingFilter(origText, text, contentType, matchCase, domains,
thirdParty, collapse); | 644 return new BlockingFilter(origText, text, contentType, matchCase, domains,
thirdParty, collapse); |
| 641 else | 645 else |
| 642 return new WhitelistFilter(origText, text, contentType, matchCase, domains
, thirdParty, siteKeys); | 646 return new WhitelistFilter(origText, text, contentType, matchCase, domains
, thirdParty, siteKeys); |
| 643 } | 647 } |
| 644 catch (e) | 648 catch (e) |
| 645 { | 649 { |
| 646 return new InvalidFilter(text, e); | 650 return new InvalidFilter(origText, e); |
| 647 } | 651 } |
| 648 } | 652 } |
| 649 | 653 |
| 650 /** | 654 /** |
| 651 * Maps type strings like "SCRIPT" or "OBJECT" to bit masks | 655 * Maps type strings like "SCRIPT" or "OBJECT" to bit masks |
| 652 */ | 656 */ |
| 653 RegExpFilter.typeMap = { | 657 RegExpFilter.typeMap = { |
| 654 OTHER: 1, | 658 OTHER: 1, |
| 655 SCRIPT: 2, | 659 SCRIPT: 2, |
| 656 IMAGE: 4, | 660 IMAGE: 4, |
| 657 STYLESHEET: 8, | 661 STYLESHEET: 8, |
| 658 OBJECT: 16, | 662 OBJECT: 16, |
| 659 SUBDOCUMENT: 32, | 663 SUBDOCUMENT: 32, |
| 660 DOCUMENT: 64, | 664 DOCUMENT: 64, |
| 661 XBL: 1, | 665 XBL: 1, |
| 662 PING: 1, | 666 PING: 1, |
| 663 XMLHTTPREQUEST: 2048, | 667 XMLHTTPREQUEST: 2048, |
| 664 OBJECT_SUBREQUEST: 4096, | 668 OBJECT_SUBREQUEST: 4096, |
| 665 DTD: 1, | 669 DTD: 1, |
| 666 MEDIA: 16384, | 670 MEDIA: 16384, |
| 667 FONT: 32768, | 671 FONT: 32768, |
| 668 | 672 |
| 669 BACKGROUND: 4, // Backwards compat, same as IMAGE | 673 BACKGROUND: 4, // Backwards compat, same as IMAGE |
| 670 | 674 |
| 671 POPUP: 0x10000000, | 675 POPUP: 0x10000000, |
| 672 DONOTTRACK: 0x20000000, | |
| 673 ELEMHIDE: 0x40000000 | 676 ELEMHIDE: 0x40000000 |
| 674 }; | 677 }; |
| 675 | 678 |
| 676 // ELEMHIDE, DONOTTRACK, POPUP option shouldn't be there by default | 679 // ELEMHIDE, POPUP option shouldn't be there by default |
| 677 RegExpFilter.prototype.contentType &= ~(RegExpFilter.typeMap.ELEMHIDE | RegExpFi
lter.typeMap.DONOTTRACK | RegExpFilter.typeMap.POPUP); | 680 RegExpFilter.prototype.contentType &= ~(RegExpFilter.typeMap.ELEMHIDE | RegExpFi
lter.typeMap.POPUP); |
| 678 | 681 |
| 679 /** | 682 /** |
| 680 * Class for blocking filters | 683 * Class for blocking filters |
| 681 * @param {String} text see Filter() | 684 * @param {String} text see Filter() |
| 682 * @param {String} regexpSource see RegExpFilter() | 685 * @param {String} regexpSource see RegExpFilter() |
| 683 * @param {Number} contentType see RegExpFilter() | 686 * @param {Number} contentType see RegExpFilter() |
| 684 * @param {Boolean} matchCase see RegExpFilter() | 687 * @param {Boolean} matchCase see RegExpFilter() |
| 685 * @param {String} domains see RegExpFilter() | 688 * @param {String} domains see RegExpFilter() |
| 686 * @param {Boolean} thirdParty see RegExpFilter() | 689 * @param {Boolean} thirdParty see RegExpFilter() |
| 687 * @param {Boolean} collapse defines whether the filter should collapse blocked
content, can be null | 690 * @param {Boolean} collapse defines whether the filter should collapse blocked
content, can be null |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 function ElemHideException(text, domains, selector) | 872 function ElemHideException(text, domains, selector) |
| 870 { | 873 { |
| 871 ElemHideBase.call(this, text, domains, selector); | 874 ElemHideBase.call(this, text, domains, selector); |
| 872 } | 875 } |
| 873 exports.ElemHideException = ElemHideException; | 876 exports.ElemHideException = ElemHideException; |
| 874 | 877 |
| 875 ElemHideException.prototype = | 878 ElemHideException.prototype = |
| 876 { | 879 { |
| 877 __proto__: ElemHideBase.prototype | 880 __proto__: ElemHideBase.prototype |
| 878 }; | 881 }; |
| OLD | NEW |