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

Side by Side Diff: lib/antiadblockInit.js

Issue 5501516697829376: Issue 1161 - Anti-adblock notifications were triggered on similar domains (Closed)
Patch Set: Created July 29, 2014, 3:41 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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 { 39 {
40 let subscription = Subscription.fromURL(Prefs.subscriptions_antiadblockurl); 40 let subscription = Subscription.fromURL(Prefs.subscriptions_antiadblockurl);
41 if (subscription.url in FilterStorage.knownSubscriptions) 41 if (subscription.url in FilterStorage.knownSubscriptions)
42 subscription.disabled = !approved; 42 subscription.disabled = !approved;
43 } 43 }
44 44
45 function addAntiAdblockNotification(subscription) 45 function addAntiAdblockNotification(subscription)
46 { 46 {
47 let urlFilters = []; 47 let urlFilters = [];
48 for (let filter of subscription.filters) 48 for (let filter of subscription.filters)
49 {
49 if (filter instanceof ActiveFilter) 50 if (filter instanceof ActiveFilter)
51 {
50 for (let domain in filter.domains) 52 for (let domain in filter.domains)
51 if (domain && urlFilters.indexOf(domain) == -1) 53 {
52 urlFilters.push(domain); 54 let urlFilter = "||" + domain + "^";
55 if (domain && filter.domains[domain] && urlFilters.indexOf(urlFilter) == -1)
56 urlFilters.push(urlFilter);
57 }
58 }
59 }
53 notification.urlFilters = urlFilters; 60 notification.urlFilters = urlFilters;
54 Notification.addNotification(notification); 61 Notification.addNotification(notification);
55 Notification.addQuestionListener(notification.id, notificationListener); 62 Notification.addQuestionListener(notification.id, notificationListener);
56 } 63 }
57 64
58 function removeAntiAdblockNotification() 65 function removeAntiAdblockNotification()
59 { 66 {
60 Notification.removeNotification(notification); 67 Notification.removeNotification(notification);
61 Notification.removeQuestionListener(notification.id, notificationListener); 68 Notification.removeQuestionListener(notification.id, notificationListener);
62 } 69 }
63 70
64 let subscription = Subscription.fromURL(Prefs.subscriptions_antiadblockurl); 71 let subscription = Subscription.fromURL(Prefs.subscriptions_antiadblockurl);
65 if (subscription.lastDownload && subscription.disabled) 72 if (subscription.lastDownload && subscription.disabled)
66 addAntiAdblockNotification(subscription); 73 addAntiAdblockNotification(subscription);
67 74
68 FilterNotifier.addListener(function(action, value, newItem, oldItem) 75 FilterNotifier.addListener(function(action, value, newItem, oldItem)
69 { 76 {
70 if (!/^subscription\.(updated|removed|disabled)$/.test(action) || value.url != Prefs.subscriptions_antiadblockurl) 77 if (!/^subscription\.(updated|removed|disabled)$/.test(action) || value.url != Prefs.subscriptions_antiadblockurl)
71 return; 78 return;
72 79
73 if (action == "subscription.updated") 80 if (action == "subscription.updated")
74 addAntiAdblockNotification(value); 81 addAntiAdblockNotification(value);
75 else if (action == "subscription.removed" || (action == "subscription.disabl ed" && !value.disabled)) 82 else if (action == "subscription.removed" || (action == "subscription.disabl ed" && !value.disabled))
76 removeAntiAdblockNotification(); 83 removeAntiAdblockNotification();
77 }); 84 });
78 } 85 }
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