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-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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 subscription.disabled = true; | 217 subscription.disabled = true; |
218 FilterStorage.addSubscription(subscription); | 218 FilterStorage.addSubscription(subscription); |
219 if (subscription instanceof DownloadableSubscription && !subscription.last
Download) | 219 if (subscription instanceof DownloadableSubscription && !subscription.last
Download) |
220 Synchronizer.execute(subscription); | 220 Synchronizer.execute(subscription); |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
224 if (!addSubscription && !addAcceptable) | 224 if (!addSubscription && !addAcceptable) |
225 return; | 225 return; |
226 | 226 |
227 function notifyUser() | 227 Promise.resolve(addSubscription && fetch("subscriptions.xml") |
| 228 .then(function(response) |
| 229 { |
| 230 return response.text(); |
| 231 }) |
| 232 .then(function(text) |
| 233 { |
| 234 var doc = new DOMParser().parseFromString(text, "application/xml"); |
| 235 var nodes = doc.getElementsByTagName("subscription"); |
| 236 var node = Utils.chooseFilterSubscription(nodes); |
| 237 var subscription = node && Subscription.fromURL(node.getAttribute("url")); |
| 238 |
| 239 if (subscription) |
| 240 { |
| 241 FilterStorage.addSubscription(subscription); |
| 242 |
| 243 subscription.disabled = false; |
| 244 subscription.title = node.getAttribute("title"); |
| 245 subscription.homepage = node.getAttribute("homepage"); |
| 246 |
| 247 if (subscription instanceof DownloadableSubscription && |
| 248 !subscription.lastDownload) |
| 249 Synchronizer.execute(subscription); |
| 250 } |
| 251 }) |
| 252 ).then(function() |
228 { | 253 { |
229 if (!Prefs.suppress_first_run_page) | 254 if (!Prefs.suppress_first_run_page) |
230 ext.pages.open(ext.getURL("firstRun.html")); | 255 ext.pages.open(ext.getURL("firstRun.html")); |
231 } | 256 }); |
232 | |
233 if (addSubscription) | |
234 { | |
235 // Load subscriptions data | |
236 var request = new XMLHttpRequest(); | |
237 request.open("GET", "subscriptions.xml"); | |
238 request.addEventListener("load", function() | |
239 { | |
240 var node = Utils.chooseFilterSubscription(request.responseXML.getElementsB
yTagName("subscription")); | |
241 var subscription = (node ? Subscription.fromURL(node.getAttribute("url"))
: null); | |
242 if (subscription) | |
243 { | |
244 FilterStorage.addSubscription(subscription); | |
245 subscription.disabled = false; | |
246 subscription.title = node.getAttribute("title"); | |
247 subscription.homepage = node.getAttribute("homepage"); | |
248 if (subscription instanceof DownloadableSubscription && !subscription.la
stDownload) | |
249 Synchronizer.execute(subscription); | |
250 | |
251 notifyUser(); | |
252 } | |
253 }, false); | |
254 request.send(null); | |
255 } | |
256 else | |
257 notifyUser(); | |
258 } | 257 } |
259 | 258 |
260 Prefs.onChanged.addListener(function(name) | 259 Prefs.onChanged.addListener(function(name) |
261 { | 260 { |
262 if (name == "shouldShowBlockElementMenu") | 261 if (name == "shouldShowBlockElementMenu") |
263 refreshIconAndContextMenuForAllPages(); | 262 refreshIconAndContextMenuForAllPages(); |
264 }); | 263 }); |
265 | 264 |
266 // This is a hack to speedup loading of the options page on Safari. | 265 // This is a hack to speedup loading of the options page on Safari. |
267 // Once we replaced the background page proxy with message passing | 266 // Once we replaced the background page proxy with message passing |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 } | 418 } |
420 }); | 419 }); |
421 | 420 |
422 // update icon when page changes location | 421 // update icon when page changes location |
423 ext.pages.onLoading.addListener(function(page) | 422 ext.pages.onLoading.addListener(function(page) |
424 { | 423 { |
425 page.sendMessage({type: "clickhide-deactivate"}); | 424 page.sendMessage({type: "clickhide-deactivate"}); |
426 refreshIconAndContextMenu(page); | 425 refreshIconAndContextMenu(page); |
427 showNextNotificationForUrl(page.url); | 426 showNextNotificationForUrl(page.url); |
428 }); | 427 }); |
OLD | NEW |