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

Side by Side Diff: options.js

Issue 29479615: Issue 4978 - Read special subscription filters directly in options page (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Update adblockplusui dependency Created July 5, 2017, 12:02 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 | « dependencies ('k') | 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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 "downloadable", "special"); 62 "downloadable", "special");
63 const removeSubscription = wrapper({type: "subscriptions.remove"}, "url"); 63 const removeSubscription = wrapper({type: "subscriptions.remove"}, "url");
64 const addSubscription = wrapper({type: "subscriptions.add"}, 64 const addSubscription = wrapper({type: "subscriptions.add"},
65 "url", "title", "homepage"); 65 "url", "title", "homepage");
66 const toggleSubscription = wrapper({type: "subscriptions.toggle"}, 66 const toggleSubscription = wrapper({type: "subscriptions.toggle"},
67 "url", "keepInstalled"); 67 "url", "keepInstalled");
68 const updateSubscription = wrapper({type: "subscriptions.update"}, "url"); 68 const updateSubscription = wrapper({type: "subscriptions.update"}, "url");
69 const importRawFilters = wrapper({type: "filters.importRaw"}, 69 const importRawFilters = wrapper({type: "filters.importRaw"},
70 "text", "removeExisting"); 70 "text", "removeExisting");
71 const addFilter = wrapper({type: "filters.add"}, "text"); 71 const addFilter = wrapper({type: "filters.add"}, "text");
72 const getFilters = wrapper({type: "filters.get"}, "subscriptionUrl");
73 const removeFilter = wrapper({type: "filters.remove"}, "text"); 72 const removeFilter = wrapper({type: "filters.remove"}, "text");
74 73
75 const whitelistedDomainRegexp = /^@@\|\|([^/:]+)\^\$document$/; 74 const whitelistedDomainRegexp = /^@@\|\|([^/:]+)\^\$document$/;
76 const statusMessages = new Map([ 75 const statusMessages = new Map([
77 ["synchronize_invalid_url", 76 ["synchronize_invalid_url",
78 "filters_subscription_lastDownload_invalidURL"], 77 "filters_subscription_lastDownload_invalidURL"],
79 ["synchronize_connection_error", 78 ["synchronize_connection_error",
80 "filters_subscription_lastDownload_connectionError"], 79 "filters_subscription_lastDownload_connectionError"],
81 ["synchronize_invalid_data", 80 ["synchronize_invalid_data",
82 "filters_subscription_lastDownload_invalidData"], 81 "filters_subscription_lastDownload_invalidData"],
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // Load recommended subscriptions 179 // Load recommended subscriptions
181 loadRecommendations(); 180 loadRecommendations();
182 181
183 // Show user's filters 182 // Show user's filters
184 reloadFilters(); 183 reloadFilters();
185 } 184 }
186 $(loadOptions); 185 $(loadOptions);
187 186
188 function convertSpecialSubscription(subscription) 187 function convertSpecialSubscription(subscription)
189 { 188 {
190 getFilters(subscription.url, filters => 189 for (let filter of subscription.filters)
191 { 190 {
192 for (let filter of filters) 191 if (whitelistedDomainRegexp.test(filter.text))
193 { 192 appendToListBox("excludedDomainsBox", RegExp.$1);
194 if (whitelistedDomainRegexp.test(filter.text)) 193 else
195 appendToListBox("excludedDomainsBox", RegExp.$1); 194 appendToListBox("userFiltersBox", filter.text);
196 else 195 }
197 appendToListBox("userFiltersBox", filter.text);
198 }
199 });
200 } 196 }
201 197
202 // Reloads the displayed subscriptions and filters 198 // Reloads the displayed subscriptions and filters
203 function reloadFilters() 199 function reloadFilters()
204 { 200 {
205 // Load user filter URLs 201 // Load user filter URLs
206 let container = document.getElementById("filterLists"); 202 let container = document.getElementById("filterLists");
207 while (container.lastChild) 203 while (container.lastChild)
208 container.removeChild(container.lastChild); 204 container.removeChild(container.lastChild);
209 205
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 onFilterMessage(message.action, message.args[0]); 729 onFilterMessage(message.action, message.args[0]);
734 break; 730 break;
735 case "prefs.respond": 731 case "prefs.respond":
736 onPrefMessage(message.action, message.args[0]); 732 onPrefMessage(message.action, message.args[0]);
737 break; 733 break;
738 case "subscriptions.respond": 734 case "subscriptions.respond":
739 onSubscriptionMessage(message.action, message.args[0]); 735 onSubscriptionMessage(message.action, message.args[0]);
740 break; 736 break;
741 } 737 }
742 }); 738 });
OLDNEW
« no previous file with comments | « dependencies ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld