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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 pages.forEach(refreshIconAndContextMenu); | 143 pages.forEach(refreshIconAndContextMenu); |
144 }); | 144 }); |
145 } | 145 } |
146 | 146 |
147 /** | 147 /** |
148 * This function is called on an extension update. It will add the default | 148 * This function is called on an extension update. It will add the default |
149 * filter subscription if necessary. | 149 * filter subscription if necessary. |
150 */ | 150 */ |
151 function addSubscription(prevVersion) | 151 function addSubscription(prevVersion) |
152 { | 152 { |
153 // Make sure to remove "Recommended filters", no longer necessary | |
154 var toRemove = "https://easylist-downloads.adblockplus.org/chrome_supplement.t
xt"; | |
155 if (toRemove in FilterStorage.knownSubscriptions) | |
156 FilterStorage.removeSubscription(FilterStorage.knownSubscriptions[toRemove])
; | |
157 | |
158 // Add "acceptable ads" subscription for new users | 153 // Add "acceptable ads" subscription for new users |
159 var addAcceptable = !prevVersion; | 154 var addAcceptable = !prevVersion; |
160 if (addAcceptable) | 155 if (addAcceptable) |
161 { | 156 { |
162 addAcceptable = !FilterStorage.subscriptions.some(function(subscription) | 157 addAcceptable = !FilterStorage.subscriptions.some(function(subscription) |
163 { | 158 { |
164 return subscription.url == Prefs.subscriptions_exceptionsurl; | 159 return subscription.url == Prefs.subscriptions_exceptionsurl; |
165 }); | 160 }); |
166 } | 161 } |
167 | 162 |
(...skipping 22 matching lines...) Expand all Loading... |
190 { | 185 { |
191 subscription.title = "Allow non-intrusive advertising"; | 186 subscription.title = "Allow non-intrusive advertising"; |
192 FilterStorage.addSubscription(subscription); | 187 FilterStorage.addSubscription(subscription); |
193 if (subscription instanceof DownloadableSubscription && !subscription.last
Download) | 188 if (subscription instanceof DownloadableSubscription && !subscription.last
Download) |
194 Synchronizer.execute(subscription); | 189 Synchronizer.execute(subscription); |
195 } | 190 } |
196 else | 191 else |
197 addAcceptable = false; | 192 addAcceptable = false; |
198 } | 193 } |
199 | 194 |
200 // Add "anti-adblock messages" subscription for new users and users updating f
rom old ABP versions | |
201 if (!prevVersion || Services.vc.compare(prevVersion, "1.8") < 0) | |
202 { | |
203 var subscription = Subscription.fromURL(Prefs.subscriptions_antiadblockurl); | |
204 if (subscription && !(subscription.url in FilterStorage.knownSubscriptions)) | |
205 { | |
206 subscription.disabled = true; | |
207 FilterStorage.addSubscription(subscription); | |
208 if (subscription instanceof DownloadableSubscription && !subscription.last
Download) | |
209 Synchronizer.execute(subscription); | |
210 } | |
211 } | |
212 | |
213 if (!addSubscription && !addAcceptable) | 195 if (!addSubscription && !addAcceptable) |
214 return; | 196 return; |
215 | 197 |
216 Promise.resolve(addSubscription && fetch("subscriptions.xml") | 198 Promise.resolve(addSubscription && fetch("subscriptions.xml") |
217 .then(function(response) | 199 .then(function(response) |
218 { | 200 { |
219 return response.text(); | 201 return response.text(); |
220 }) | 202 }) |
221 .then(function(text) | 203 .then(function(text) |
222 { | 204 { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 } | 440 } |
459 }); | 441 }); |
460 | 442 |
461 // update icon when page changes location | 443 // update icon when page changes location |
462 ext.pages.onLoading.addListener(function(page) | 444 ext.pages.onLoading.addListener(function(page) |
463 { | 445 { |
464 page.sendMessage({type: "blockelement-finished"}); | 446 page.sendMessage({type: "blockelement-finished"}); |
465 refreshIconAndContextMenu(page); | 447 refreshIconAndContextMenu(page); |
466 showNextNotificationForUrl(page.url); | 448 showNextNotificationForUrl(page.url); |
467 }); | 449 }); |
OLD | NEW |