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

Delta Between Two Patch Sets: lib/subscriptionInit.js

Issue 29805597: Issue 6699 - Support the "circumvention" filter list as default subscription (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Use "circumvention" instead of "cv" Created June 13, 2018, 9:43 p.m.
Right Patch Set: Use "==" instead of "in" Created June 19, 2018, 12:40 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | qunit/subscriptions.xml » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 let matchCount = 0; 105 let matchCount = 0;
106 for (let subscription of subscriptions) 106 for (let subscription of subscriptions)
107 { 107 {
108 let prefixes = subscription.getAttribute("prefixes"); 108 let prefixes = subscription.getAttribute("prefixes");
109 let prefix = prefixes && prefixes.split(",").find( 109 let prefix = prefixes && prefixes.split(",").find(
110 lang => new RegExp("^" + lang + "\\b").test(Utils.appLocale) 110 lang => new RegExp("^" + lang + "\\b").test(Utils.appLocale)
111 ); 111 );
112 112
113 let subscriptionType = subscription.getAttribute("type"); 113 let subscriptionType = subscription.getAttribute("type");
114 114
115 if (subscriptionType in ["ads", "circumvention"] && 115 if ((subscriptionType == "ads" || subscriptionType == "circumvention") &&
116 !selectedItem[subscriptionType]) 116 !selectedItem[subscriptionType])
117 selectedItem[subscriptionType] = subscription; 117 selectedItem[subscriptionType] = subscription;
118 118
119 if (prefix) 119 if (prefix)
120 { 120 {
121 // The "ads" subscription is the one driving the selection. 121 // The "ads" subscription is the one driving the selection.
122 if (subscriptionType == "ads") 122 if (subscriptionType == "ads")
123 { 123 {
124 if (!selectedPrefix || selectedPrefix.length < prefix.length) 124 if (!selectedPrefix || selectedPrefix.length < prefix.length)
125 { 125 {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // Add default ad blocking subscription (e.g. EasyList) 213 // Add default ad blocking subscription (e.g. EasyList)
214 if (shouldAddDefaultSubscription()) 214 if (shouldAddDefaultSubscription())
215 { 215 {
216 return fetch("subscriptions.xml") 216 return fetch("subscriptions.xml")
217 .then(response => response.text()) 217 .then(response => response.text())
218 .then(text => 218 .then(text =>
219 { 219 {
220 let doc = new DOMParser().parseFromString(text, "application/xml"); 220 let doc = new DOMParser().parseFromString(text, "application/xml");
221 let nodes = doc.getElementsByTagName("subscription"); 221 let nodes = doc.getElementsByTagName("subscription");
222 222
223 let subs = chooseFilterSubscriptions(nodes); 223 let defaultSubscriptions = chooseFilterSubscriptions(nodes);
Manish Jethani 2018/06/14 05:07:34 Just a thought: Maybe a good idea to rename `subs`
hub 2018/06/14 19:59:57 Done.
224 if (subs) 224 if (defaultSubscriptions)
225 { 225 {
226 for (let name in subs) 226 for (let name in defaultSubscriptions)
227 { 227 {
228 let node = subs[name]; 228 let node = defaultSubscriptions[name];
229 if (!node) 229 if (!node)
230 continue; 230 continue;
231 231
232 let url = node.getAttribute("url"); 232 let url = node.getAttribute("url");
233 if (url) 233 if (url)
234 { 234 {
235 let subscription = Subscription.fromURL(url); 235 let subscription = Subscription.fromURL(url);
236 subscription.disabled = false; 236 subscription.disabled = false;
237 subscription.title = node.getAttribute("title"); 237 subscription.title = node.getAttribute("title");
238 subscription.homepage = node.getAttribute("homepage"); 238 subscription.homepage = node.getAttribute("homepage");
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 * 324 *
325 * @param {function} callback 325 * @param {function} callback
326 */ 326 */
327 exports.setSubscriptionsCallback = callback => 327 exports.setSubscriptionsCallback = callback =>
328 { 328 {
329 subscriptionsCallback = callback; 329 subscriptionsCallback = callback;
330 }; 330 };
331 331
332 // Exports for tests only 332 // Exports for tests only
333 exports.chooseFilterSubscriptions = chooseFilterSubscriptions; 333 exports.chooseFilterSubscriptions = chooseFilterSubscriptions;
LEFTRIGHT

Powered by Google App Engine
This is Rietveld