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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 | 907 |
908 // We don't allow ElemHide filters which have any empty domains. | 908 // We don't allow ElemHide filters which have any empty domains. |
909 // Note: The ElemHide.prototype.domainSeparator is duplicated here, if that | 909 // Note: The ElemHide.prototype.domainSeparator is duplicated here, if that |
910 // changes this must be changed too. | 910 // changes this must be changed too. |
911 if (domain && /(^|,)~?(,|$)/.test(domain)) | 911 if (domain && /(^|,)~?(,|$)/.test(domain)) |
912 return new InvalidFilter(text, "filter_invalid_domain"); | 912 return new InvalidFilter(text, "filter_invalid_domain"); |
913 | 913 |
914 if (isException) | 914 if (isException) |
915 return new ElemHideException(text, domain, selector); | 915 return new ElemHideException(text, domain, selector); |
916 | 916 |
917 if (selector.indexOf("[-abp-properties") != -1) | 917 if ((selector.indexOf("[-abp-properties") != -1) || (selector.indexOf(":has(")
!= -1)) |
918 { | 918 { |
919 // Element hiding emulation filters are inefficient so we need to make sure | 919 // Element hiding emulation filters are inefficient so we need to make sure |
920 // that they're only applied if they specify active domains | 920 // that they're only applied if they specify active domains |
921 if (!/,[^~][^,.]*\.[^,]/.test("," + domain)) | 921 if (!/,[^~][^,.]*\.[^,]/.test("," + domain)) |
922 return new InvalidFilter(text, "filter_elemhideemulation_nodomain"); | 922 return new InvalidFilter(text, "filter_elemhideemulation_nodomain"); |
923 | 923 |
924 return new ElemHideEmulationFilter(text, domain, selector); | 924 return new ElemHideEmulationFilter(text, domain, selector); |
925 } | 925 } |
926 | 926 |
927 return new ElemHideFilter(text, domain, selector); | 927 return new ElemHideFilter(text, domain, selector); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 * Class for element hiding emulation filters | 967 * Class for element hiding emulation filters |
968 * @param {String} text see Filter() | 968 * @param {String} text see Filter() |
969 * @param {String} domains see ElemHideBase() | 969 * @param {String} domains see ElemHideBase() |
970 * @param {String} selector see ElemHideBase() | 970 * @param {String} selector see ElemHideBase() |
971 * @constructor | 971 * @constructor |
972 * @augments ElemHideBase | 972 * @augments ElemHideBase |
973 */ | 973 */ |
974 function ElemHideEmulationFilter(text, domains, selector) | 974 function ElemHideEmulationFilter(text, domains, selector) |
975 { | 975 { |
976 ElemHideBase.call(this, text, domains, selector); | 976 ElemHideBase.call(this, text, domains, selector); |
| 977 this.cssPropFilter = (selector.indexOf("[-abp-properties") != -1); |
| 978 this.pseudoClassHas = (selector.indexOf(":has(") != -1); |
977 } | 979 } |
978 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; | 980 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; |
979 | 981 |
980 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { | 982 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { |
981 type: "elemhideemulation" | 983 type: "elemhideemulation", |
| 984 cssPropFilter: false, |
| 985 pseudoClassHas: false, |
982 }); | 986 }); |
OLD | NEW |