Left: | ||
Right: |
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 |
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 publicSuffixes */ | |
19 | |
18 "use strict"; | 20 "use strict"; |
19 | 21 |
20 const {Prefs} = require("prefs"); | 22 const {Prefs} = require("prefs"); |
21 const {ActiveFilter} = require("filterClasses"); | 23 const {ActiveFilter} = require("filterClasses"); |
22 const {FilterStorage} = require("filterStorage"); | 24 const {FilterStorage} = require("filterStorage"); |
23 const {FilterNotifier} = require("filterNotifier"); | 25 const {FilterNotifier} = require("filterNotifier"); |
24 const {Subscription} = require("subscriptionClasses"); | 26 const {Subscription} = require("subscriptionClasses"); |
25 const {Notification} = require("notification"); | 27 const {Notification} = require("notification"); |
26 | 28 |
27 exports.initAntiAdblockNotification = function initAntiAdblockNotification() | 29 exports.initAntiAdblockNotification = function initAntiAdblockNotification() |
(...skipping 15 matching lines...) Expand all Loading... | |
43 | 45 |
44 function addAntiAdblockNotification(subscription) | 46 function addAntiAdblockNotification(subscription) |
45 { | 47 { |
46 let urlFilters = []; | 48 let urlFilters = []; |
47 for (let filter of subscription.filters) | 49 for (let filter of subscription.filters) |
48 { | 50 { |
49 if (filter instanceof ActiveFilter && filter.domains) | 51 if (filter instanceof ActiveFilter && filter.domains) |
50 { | 52 { |
51 for (let [domain, included] of filter.domains) | 53 for (let [domain, included] of filter.domains) |
52 { | 54 { |
55 let domainIsTLD = !domain.includes(".") || domain.endsWith("."); | |
kzar
2018/05/25 13:51:56
This logic doesn't look right to me, what about th
kzar
2018/05/25 13:51:57
This variable seems kind of pointless, when we onl
Jon Sonesen
2018/05/25 21:04:39
Hm, but there is the case where `com.` and `com` s
| |
56 if (domainIsTLD || publicSuffixes.hasOwnProperty(domain)) | |
kzar
2018/05/25 13:51:57
If the domain ends in "." it won't be found in pub
Jon Sonesen
2018/05/25 21:04:39
Acknowledged.
| |
57 continue; | |
53 let urlFilter = "||" + domain + "^$document"; | 58 let urlFilter = "||" + domain + "^$document"; |
54 if (domain && included && urlFilters.indexOf(urlFilter) == -1) | 59 if (domain && included && urlFilters.indexOf(urlFilter) == -1) |
kzar
2018/05/25 13:51:57
It seems a shame we're doing these cheaper checks
Jon Sonesen
2018/05/25 21:04:39
Acknowledged.
| |
60 { | |
55 urlFilters.push(urlFilter); | 61 urlFilters.push(urlFilter); |
62 } | |
56 } | 63 } |
57 } | 64 } |
58 } | 65 } |
59 notification.urlFilters = urlFilters; | 66 notification.urlFilters = urlFilters; |
60 Notification.addNotification(notification); | 67 Notification.addNotification(notification); |
61 Notification.addQuestionListener(notification.id, notificationListener); | 68 Notification.addQuestionListener(notification.id, notificationListener); |
62 } | 69 } |
63 | 70 |
64 function removeAntiAdblockNotification() | 71 function removeAntiAdblockNotification() |
65 { | 72 { |
(...skipping 16 matching lines...) Expand all Loading... | |
82 if (url in FilterStorage.knownSubscriptions && subscription.disabled) | 89 if (url in FilterStorage.knownSubscriptions && subscription.disabled) |
83 addAntiAdblockNotification(subscription); | 90 addAntiAdblockNotification(subscription); |
84 else | 91 else |
85 removeAntiAdblockNotification(); | 92 removeAntiAdblockNotification(); |
86 } | 93 } |
87 | 94 |
88 FilterNotifier.on("subscription.updated", onSubscriptionChange); | 95 FilterNotifier.on("subscription.updated", onSubscriptionChange); |
89 FilterNotifier.on("subscription.removed", onSubscriptionChange); | 96 FilterNotifier.on("subscription.removed", onSubscriptionChange); |
90 FilterNotifier.on("subscription.disabled", onSubscriptionChange); | 97 FilterNotifier.on("subscription.disabled", onSubscriptionChange); |
91 }; | 98 }; |
OLD | NEW |