LEFT | RIGHT |
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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 selector = tagName + "." + id + additional + "," + tagName + "#" + id + ad
ditional; | 904 selector = tagName + "." + id + additional + "," + tagName + "#" + id + ad
ditional; |
905 else if (tagName || additional) | 905 else if (tagName || additional) |
906 selector = tagName + additional; | 906 selector = tagName + additional; |
907 else | 907 else |
908 return new InvalidFilter(text, Utils.getString("filter_elemhide_nocriteria
")); | 908 return new InvalidFilter(text, Utils.getString("filter_elemhide_nocriteria
")); |
909 } | 909 } |
910 | 910 |
911 if (isException) | 911 if (isException) |
912 return new ElemHideException(text, domain, selector); | 912 return new ElemHideException(text, domain, selector); |
913 | 913 |
914 if (Filter.csspropertyRegExp.test(selector)) | 914 let match = Filter.csspropertyRegExp.exec(selector); |
| 915 if (match) |
915 { | 916 { |
916 // CSS property filters are inefficient so we need to make sure that | 917 // CSS property filters are inefficient so we need to make sure that |
917 // they're only applied if they specify active domains | 918 // they're only applied if they specify active domains |
918 if (!/,[^~][^,.]*\.[^,]/.test("," + domain)) | 919 if (!/,[^~][^,.]*\.[^,]/.test("," + domain)) |
919 return new InvalidFilter(text, Utils.getString("filter_cssproperty_nodomai
n")); | 920 return new InvalidFilter(text, Utils.getString("filter_cssproperty_nodomai
n")); |
920 | 921 |
921 return new CSSPropertyFilter(text, domain, selector); | 922 return new CSSPropertyFilter(text, domain, selector, match[2], |
| 923 selector.substr(0, match.index), |
| 924 selector.substr(match.index + match[0].length)); |
922 } | 925 } |
923 | 926 |
924 return new ElemHideFilter(text, domain, selector); | 927 return new ElemHideFilter(text, domain, selector); |
925 }; | 928 }; |
926 | 929 |
927 /** | 930 /** |
928 * Class for element hiding filters | 931 * Class for element hiding filters |
929 * @param {String} text see Filter() | 932 * @param {String} text see Filter() |
930 * @param {String} domains see ElemHideBase() | 933 * @param {String} domains see ElemHideBase() |
931 * @param {String} selector see ElemHideBase() | 934 * @param {String} selector see ElemHideBase() |
(...skipping 25 matching lines...) Expand all Loading... |
957 } | 960 } |
958 exports.ElemHideException = ElemHideException; | 961 exports.ElemHideException = ElemHideException; |
959 | 962 |
960 ElemHideException.prototype = | 963 ElemHideException.prototype = |
961 { | 964 { |
962 __proto__: ElemHideBase.prototype | 965 __proto__: ElemHideBase.prototype |
963 }; | 966 }; |
964 | 967 |
965 /** | 968 /** |
966 * Class for CSS property filters | 969 * Class for CSS property filters |
967 * @param {String} text see Filter() | 970 * @param {String} text see Filter() |
968 * @param {String} domains see ElemHideBase() | 971 * @param {String} domains see ElemHideBase() |
969 * @param {String} selector see ElemHideBase() | 972 * @param {String} selector see ElemHideBase() |
| 973 * @param {String} regexpSource see CSSPropertyFilter.regexpSource |
| 974 * @param {String} selectorPrefix see CSSPropertyFilter.selectorPrefix |
| 975 * @param {String} selectorSuffix see CSSPropertyFilter.selectorSuffix |
970 * @constructor | 976 * @constructor |
971 * @augments ElemHideBase | 977 * @augments ElemHideBase |
972 */ | 978 */ |
973 function CSSPropertyFilter(text, domains, selector) | 979 function CSSPropertyFilter(text, domains, selector, regexpSource, |
| 980 selectorPrefix, selectorSuffix) |
974 { | 981 { |
975 ElemHideBase.call(this, text, domains, selector); | 982 ElemHideBase.call(this, text, domains, selector); |
976 | 983 |
977 let properties; | 984 this.regexpSource = regexpSource; |
978 [properties, , this.regexpSource] = selector.match(Filter.csspropertyRegExp); | 985 this.selectorPrefix = selectorPrefix; |
979 [this.selectorPrefix, this.selectorSuffix] = selector.split(properties); | 986 this.selectorSuffix = selectorSuffix; |
980 } | 987 } |
981 exports.CSSPropertyFilter = CSSPropertyFilter; | 988 exports.CSSPropertyFilter = CSSPropertyFilter; |
982 | 989 |
983 CSSPropertyFilter.prototype = | 990 CSSPropertyFilter.prototype = |
984 { | 991 { |
985 __proto__: ElemHideBase.prototype, | 992 __proto__: ElemHideBase.prototype, |
986 | 993 |
987 /** | 994 /** |
988 * Expression from which a regular expression should be generated for matching | 995 * Expression from which a regular expression should be generated for matching |
989 * CSS properties - for delayed creation of the regexpString property | 996 * CSS properties - for delayed creation of the regexpString property |
(...skipping 24 matching lines...) Expand all Loading... |
1014 // several times on Safari, due to WebKit bug 132872 | 1021 // several times on Safari, due to WebKit bug 132872 |
1015 let prop = Object.getOwnPropertyDescriptor(this, "regexpString"); | 1022 let prop = Object.getOwnPropertyDescriptor(this, "regexpString"); |
1016 if (prop) | 1023 if (prop) |
1017 return prop.value; | 1024 return prop.value; |
1018 | 1025 |
1019 let regexp = Filter.toRegExp(this.regexpSource); | 1026 let regexp = Filter.toRegExp(this.regexpSource); |
1020 Object.defineProperty(this, "regexpString", {value: regexp}); | 1027 Object.defineProperty(this, "regexpString", {value: regexp}); |
1021 return regexp; | 1028 return regexp; |
1022 } | 1029 } |
1023 }; | 1030 }; |
LEFT | RIGHT |