Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/antiadblockInit.js

Issue 29375899: Issue 4871 - Start using ESLint for adblockplusui (Closed)
Patch Set: Created Feb. 20, 2017, 10:01 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« background.js ('K') | « i18n.js ('k') | messageResponder.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 /* globals Cu */
19
20 "use strict";
21
18 Cu.import("resource://gre/modules/Services.jsm"); 22 Cu.import("resource://gre/modules/Services.jsm");
19 23
20 let {Utils} = require("utils"); 24 let {Utils} = require("utils");
21 let {Prefs} = require("prefs"); 25 let {Prefs} = require("prefs");
22 let {ActiveFilter} = require("filterClasses"); 26 let {ActiveFilter} = require("filterClasses");
23 let {FilterStorage} = require("filterStorage"); 27 let {FilterStorage} = require("filterStorage");
24 let {FilterNotifier} = require("filterNotifier"); 28 let {FilterNotifier} = require("filterNotifier");
25 let {Subscription} = require("subscriptionClasses"); 29 let {Subscription} = require("subscriptionClasses");
26 let {Notification} = require("notification"); 30 let {Notification} = require("notification");
27 31
(...skipping 17 matching lines...) Expand all
45 function addAntiAdblockNotification(subscription) 49 function addAntiAdblockNotification(subscription)
46 { 50 {
47 let urlFilters = []; 51 let urlFilters = [];
48 for (let filter of subscription.filters) 52 for (let filter of subscription.filters)
49 { 53 {
50 if (filter instanceof ActiveFilter) 54 if (filter instanceof ActiveFilter)
51 { 55 {
52 for (let domain in filter.domains) 56 for (let domain in filter.domains)
53 { 57 {
54 let urlFilter = "||" + domain + "^$document"; 58 let urlFilter = "||" + domain + "^$document";
55 if (domain && filter.domains[domain] && urlFilters.indexOf(urlFilter) == -1) 59 if (domain && filter.domains[domain] &&
60 urlFilters.indexOf(urlFilter) == -1)
56 urlFilters.push(urlFilter); 61 urlFilters.push(urlFilter);
57 } 62 }
58 } 63 }
59 } 64 }
60 notification.urlFilters = urlFilters; 65 notification.urlFilters = urlFilters;
61 Notification.addNotification(notification); 66 Notification.addNotification(notification);
62 Notification.addQuestionListener(notification.id, notificationListener); 67 Notification.addQuestionListener(notification.id, notificationListener);
63 } 68 }
64 69
65 function removeAntiAdblockNotification() 70 function removeAntiAdblockNotification()
66 { 71 {
67 Notification.removeNotification(notification); 72 Notification.removeNotification(notification);
68 Notification.removeQuestionListener(notification.id, notificationListener); 73 Notification.removeQuestionListener(notification.id, notificationListener);
69 } 74 }
70 75
71 let subscription = Subscription.fromURL(Prefs.subscriptions_antiadblockurl); 76 {
72 if (subscription.lastDownload && subscription.disabled) 77 let subscription = Subscription.fromURL(Prefs.subscriptions_antiadblockurl);
73 addAntiAdblockNotification(subscription); 78 if (subscription.lastDownload && subscription.disabled)
79 addAntiAdblockNotification(subscription);
80 }
74 81
75 function onSubscriptionChange(subscription) 82 function onSubscriptionChange(subscription)
76 { 83 {
77 let url = Prefs.subscriptions_antiadblockurl; 84 let url = Prefs.subscriptions_antiadblockurl;
78 if (url != subscription.url) 85 if (url != subscription.url)
79 return; 86 return;
80 87
81 if (url in FilterStorage.knownSubscriptions && !subscription.disabled) 88 if (url in FilterStorage.knownSubscriptions && !subscription.disabled)
82 addAntiAdblockNotification(subscription); 89 addAntiAdblockNotification(subscription);
83 else 90 else
84 removeAntiAdblockNotification(); 91 removeAntiAdblockNotification();
85 } 92 }
86 93
87 FilterNotifier.on("subscription.updated", onSubscriptionChange); 94 FilterNotifier.on("subscription.updated", onSubscriptionChange);
88 FilterNotifier.on("subscription.removed", onSubscriptionChange); 95 FilterNotifier.on("subscription.removed", onSubscriptionChange);
89 FilterNotifier.on("subscription.disabled", onSubscriptionChange); 96 FilterNotifier.on("subscription.disabled", onSubscriptionChange);
90 } 97 };
OLDNEW
« background.js ('K') | « i18n.js ('k') | messageResponder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld