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

Side by Side Diff: lib/antiadblockInit.js

Issue 29643698: Issue 6201 - Fix the "Hide targeted messages?" notification (Closed)
Patch Set: Created Dec. 18, 2017, 3:32 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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-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 28 matching lines...) Expand all
39 let subscription = Subscription.fromURL(Prefs.subscriptions_antiadblockurl); 39 let subscription = Subscription.fromURL(Prefs.subscriptions_antiadblockurl);
40 if (subscription.url in FilterStorage.knownSubscriptions) 40 if (subscription.url in FilterStorage.knownSubscriptions)
41 subscription.disabled = !approved; 41 subscription.disabled = !approved;
42 } 42 }
43 43
44 function addAntiAdblockNotification(subscription) 44 function addAntiAdblockNotification(subscription)
45 { 45 {
46 let urlFilters = []; 46 let urlFilters = [];
47 for (let filter of subscription.filters) 47 for (let filter of subscription.filters)
48 { 48 {
49 if (filter instanceof ActiveFilter) 49 if (filter instanceof ActiveFilter && filter.domains)
50 { 50 {
51 for (let domain in filter.domains) 51 for (let domain of filter.domains.keys())
Wladimir Palant 2017/12/19 11:36:05 You need the value as well, so better: for (let
kzar 2017/12/19 12:28:00 Done.
52 { 52 {
53 let urlFilter = "||" + domain + "^$document"; 53 let urlFilter = "||" + domain + "^$document";
54 if (domain && filter.domains[domain] && 54 if (domain && filter.domains.has(domain) &&
Wladimir Palant 2017/12/19 11:36:05 That's pointless, you already know that domain exi
kzar 2017/12/19 12:28:00 Whoops, Done.
55 urlFilters.indexOf(urlFilter) == -1) 55 urlFilters.indexOf(urlFilter) == -1)
56 urlFilters.push(urlFilter); 56 urlFilters.push(urlFilter);
57 } 57 }
58 } 58 }
59 } 59 }
60 notification.urlFilters = urlFilters; 60 notification.urlFilters = urlFilters;
61 Notification.addNotification(notification); 61 Notification.addNotification(notification);
62 Notification.addQuestionListener(notification.id, notificationListener); 62 Notification.addQuestionListener(notification.id, notificationListener);
63 } 63 }
64 64
(...skipping 18 matching lines...) Expand all
83 if (url in FilterStorage.knownSubscriptions && subscription.disabled) 83 if (url in FilterStorage.knownSubscriptions && subscription.disabled)
84 addAntiAdblockNotification(subscription); 84 addAntiAdblockNotification(subscription);
85 else 85 else
86 removeAntiAdblockNotification(); 86 removeAntiAdblockNotification();
87 } 87 }
88 88
89 FilterNotifier.on("subscription.updated", onSubscriptionChange); 89 FilterNotifier.on("subscription.updated", onSubscriptionChange);
90 FilterNotifier.on("subscription.removed", onSubscriptionChange); 90 FilterNotifier.on("subscription.removed", onSubscriptionChange);
91 FilterNotifier.on("subscription.disabled", onSubscriptionChange); 91 FilterNotifier.on("subscription.disabled", onSubscriptionChange);
92 }; 92 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld