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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 * if necessary. | 135 * if necessary. |
136 * @param {Filter} filter filter that has been added | 136 * @param {Filter} filter filter that has been added |
137 */ | 137 */ |
138 function addFilter(filter) | 138 function addFilter(filter) |
139 { | 139 { |
140 if (!(filter instanceof ActiveFilter) || filter.disabled) | 140 if (!(filter instanceof ActiveFilter) || filter.disabled) |
141 return; | 141 return; |
142 | 142 |
143 let hasEnabled = false; | 143 let hasEnabled = false; |
144 let allowSnippets = false; | 144 let allowSnippets = false; |
145 for (let i = 0; i < filter.subscriptions.length; i++) | 145 for (let subscription of filter.subscriptions) |
146 { | 146 { |
147 let subscription = filter.subscriptions[i]; | |
148 | |
149 if (!subscription.disabled) | 147 if (!subscription.disabled) |
150 { | 148 { |
151 hasEnabled = true; | 149 hasEnabled = true; |
152 | 150 |
153 // Allow snippets to be executed only by the circumvention lists or the | 151 // Allow snippets to be executed only by the circumvention lists or the |
154 // user's own filters. | 152 // user's own filters. |
155 if (subscription.type == "circumvention" || | 153 if (subscription.type == "circumvention" || |
156 subscription instanceof SpecialSubscription) | 154 subscription instanceof SpecialSubscription) |
157 { | 155 { |
158 allowSnippets = true; | 156 allowSnippets = true; |
(...skipping 23 matching lines...) Expand all Loading... |
182 * @param {Filter} filter filter that has been removed | 180 * @param {Filter} filter filter that has been removed |
183 */ | 181 */ |
184 function removeFilter(filter) | 182 function removeFilter(filter) |
185 { | 183 { |
186 if (!(filter instanceof ActiveFilter)) | 184 if (!(filter instanceof ActiveFilter)) |
187 return; | 185 return; |
188 | 186 |
189 if (!filter.disabled) | 187 if (!filter.disabled) |
190 { | 188 { |
191 let hasEnabled = false; | 189 let hasEnabled = false; |
192 for (let i = 0; i < filter.subscriptions.length; i++) | 190 for (let subscription of filter.subscriptions) |
193 { | 191 { |
194 if (!filter.subscriptions[i].disabled) | 192 if (!subscription.disabled) |
195 { | 193 { |
196 hasEnabled = true; | 194 hasEnabled = true; |
197 break; | 195 break; |
198 } | 196 } |
199 } | 197 } |
200 if (hasEnabled) | 198 if (hasEnabled) |
201 return; | 199 return; |
202 } | 200 } |
203 | 201 |
204 if (filter instanceof RegExpFilter) | 202 if (filter instanceof RegExpFilter) |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 { | 334 { |
337 if (!subscription.disabled) | 335 if (!subscription.disabled) |
338 addFilters(subscription.filters); | 336 addFilters(subscription.filters); |
339 } | 337 } |
340 } | 338 } |
341 | 339 |
342 function onSave() | 340 function onSave() |
343 { | 341 { |
344 isDirty = 0; | 342 isDirty = 0; |
345 } | 343 } |
OLD | NEW |