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 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 { | 1060 { |
1061 // We don't allow content filters which have any empty domains. | 1061 // We don't allow content filters which have any empty domains. |
1062 // Note: The ContentFilter.prototype.domainSeparator is duplicated here, if | 1062 // Note: The ContentFilter.prototype.domainSeparator is duplicated here, if |
1063 // that changes this must be changed too. | 1063 // that changes this must be changed too. |
1064 if (domains && /(^|,)~?(,|$)/.test(domains)) | 1064 if (domains && /(^|,)~?(,|$)/.test(domains)) |
1065 return new InvalidFilter(text, "filter_invalid_domain"); | 1065 return new InvalidFilter(text, "filter_invalid_domain"); |
1066 | 1066 |
1067 if (type == "@") | 1067 if (type == "@") |
1068 return new ElemHideException(text, domains, body); | 1068 return new ElemHideException(text, domains, body); |
1069 | 1069 |
1070 if (type == "$") | 1070 if (type == "?" || type == "$") |
| 1071 { |
| 1072 // Element hiding emulation and snippet filters are inefficient so we need |
| 1073 // to make sure that they're only applied if they specify active domains |
| 1074 if (!/,[^~][^,.]*\.[^,]/.test("," + domains)) |
| 1075 { |
| 1076 return new InvalidFilter(text, type == "?" ? |
| 1077 "filter_elemhideemulation_nodomain" : |
| 1078 "filter_snippet_nodomain"); |
| 1079 } |
| 1080 |
| 1081 if (type == "?") |
| 1082 return new ElemHideEmulationFilter(text, domains, body); |
| 1083 |
1071 return new SnippetFilter(text, domains, body); | 1084 return new SnippetFilter(text, domains, body); |
1072 | |
1073 if (type == "?") | |
1074 { | |
1075 // Element hiding emulation filters are inefficient so we need to make sure | |
1076 // that they're only applied if they specify active domains | |
1077 if (!/,[^~][^,.]*\.[^,]/.test("," + domains)) | |
1078 return new InvalidFilter(text, "filter_elemhideemulation_nodomain"); | |
1079 | |
1080 return new ElemHideEmulationFilter(text, domains, body); | |
1081 } | 1085 } |
1082 | 1086 |
1083 return new ElemHideFilter(text, domains, body); | 1087 return new ElemHideFilter(text, domains, body); |
1084 }; | 1088 }; |
1085 | 1089 |
1086 /** | 1090 /** |
1087 * Base class for element hiding filters | 1091 * Base class for element hiding filters |
1088 * @param {string} text see {@link Filter Filter()} | 1092 * @param {string} text see {@link Filter Filter()} |
1089 * @param {string} [domains] see {@link ContentFilter ContentFilter()} | 1093 * @param {string} [domains] see {@link ContentFilter ContentFilter()} |
1090 * @param {string} selector CSS selector for the HTML elements that should be | 1094 * @param {string} selector CSS selector for the HTML elements that should be |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 | 1187 |
1184 /** | 1188 /** |
1185 * Script that should be executed | 1189 * Script that should be executed |
1186 * @type {string} | 1190 * @type {string} |
1187 */ | 1191 */ |
1188 get script() | 1192 get script() |
1189 { | 1193 { |
1190 return this.body; | 1194 return this.body; |
1191 } | 1195 } |
1192 }); | 1196 }); |
OLD | NEW |