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, 8:58 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
« 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 30 matching lines...) Expand all
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 if (filter instanceof ActiveFilter) 49 if (filter instanceof ActiveFilter)
50 for (let domain in filter.domains) 50 for (let domain in filter.domains)
51 if (domain && urlFilters.indexOf(domain) == -1) 51 if (domain && urlFilters.indexOf(domain) == -1)
Wladimir Palant 2014/07/29 09:37:38 Please check filter.domains[domain] as well - ther
52 urlFilters.push(domain); 52 urlFilters.push("||" + domain + "^");
53 notification.urlFilters = urlFilters; 53 notification.urlFilters = urlFilters;
54 Notification.addNotification(notification); 54 Notification.addNotification(notification);
55 Notification.addQuestionListener(notification.id, notificationListener); 55 Notification.addQuestionListener(notification.id, notificationListener);
56 } 56 }
57 57
58 function removeAntiAdblockNotification() 58 function removeAntiAdblockNotification()
59 { 59 {
60 Notification.removeNotification(notification); 60 Notification.removeNotification(notification);
61 Notification.removeQuestionListener(notification.id, notificationListener); 61 Notification.removeQuestionListener(notification.id, notificationListener);
62 } 62 }
63 63
64 let subscription = Subscription.fromURL(Prefs.subscriptions_antiadblockurl); 64 let subscription = Subscription.fromURL(Prefs.subscriptions_antiadblockurl);
65 if (subscription.lastDownload && subscription.disabled) 65 if (subscription.lastDownload && subscription.disabled)
66 addAntiAdblockNotification(subscription); 66 addAntiAdblockNotification(subscription);
67 67
68 FilterNotifier.addListener(function(action, value, newItem, oldItem) 68 FilterNotifier.addListener(function(action, value, newItem, oldItem)
69 { 69 {
70 if (!/^subscription\.(updated|removed|disabled)$/.test(action) || value.url != Prefs.subscriptions_antiadblockurl) 70 if (!/^subscription\.(updated|removed|disabled)$/.test(action) || value.url != Prefs.subscriptions_antiadblockurl)
71 return; 71 return;
72 72
73 if (action == "subscription.updated") 73 if (action == "subscription.updated")
74 addAntiAdblockNotification(value); 74 addAntiAdblockNotification(value);
75 else if (action == "subscription.removed" || (action == "subscription.disabl ed" && !value.disabled)) 75 else if (action == "subscription.removed" || (action == "subscription.disabl ed" && !value.disabled))
76 removeAntiAdblockNotification(); 76 removeAntiAdblockNotification();
77 }); 77 });
78 } 78 }
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