| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 { | 204 { |
| 205 let antiAdblockSubscription = Subscription.fromURL( | 205 let antiAdblockSubscription = Subscription.fromURL( |
| 206 Prefs.subscriptions_antiadblockurl | 206 Prefs.subscriptions_antiadblockurl |
| 207 ); | 207 ); |
| 208 antiAdblockSubscription.disabled = true; | 208 antiAdblockSubscription.disabled = true; |
| 209 subscriptions.push(antiAdblockSubscription); | 209 subscriptions.push(antiAdblockSubscription); |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 | 212 |
| 213 // Add default ad blocking subscription (e.g. EasyList) | 213 // Add default ad blocking subscription (e.g. EasyList) |
| 214 if (shouldAddDefaultSubscription()) | 214 // Ensure the Anti Circumvention is added on upgrade. |
|
Manish Jethani
2018/07/13 15:20:25
You mean anti-circumvention subscription?
hub
2018/07/13 17:23:59
Done.
| |
| 215 let addDefaultSubscription = shouldAddDefaultSubscription(); | |
| 216 if (addDefaultSubscription || !Prefs.subscriptions_checkedanticv) | |
| 215 { | 217 { |
| 216 return fetch("subscriptions.xml") | 218 return fetch("subscriptions.xml") |
| 217 .then(response => response.text()) | 219 .then(response => response.text()) |
| 218 .then(text => | 220 .then(text => |
| 219 { | 221 { |
| 220 let doc = new DOMParser().parseFromString(text, "application/xml"); | 222 let doc = new DOMParser().parseFromString(text, "application/xml"); |
| 221 let nodes = doc.getElementsByTagName("subscription"); | 223 let nodes = doc.getElementsByTagName("subscription"); |
| 222 | 224 |
| 223 let defaultSubscriptions = chooseFilterSubscriptions(nodes); | 225 let defaultSubscriptions = chooseFilterSubscriptions(nodes); |
| 224 if (defaultSubscriptions) | 226 if (defaultSubscriptions) |
| 225 { | 227 { |
| 226 for (let name in defaultSubscriptions) | 228 for (let name in defaultSubscriptions) |
| 227 { | 229 { |
| 228 let node = defaultSubscriptions[name]; | 230 let node = defaultSubscriptions[name]; |
| 229 if (!node) | 231 if (!node) |
| 230 continue; | 232 continue; |
| 231 | 233 |
| 234 let type = node.getAttribute("type"); | |
| 235 if (!addDefaultSubscription && type != "circumvention") | |
| 236 continue; | |
| 237 | |
| 232 let url = node.getAttribute("url"); | 238 let url = node.getAttribute("url"); |
| 233 if (url) | 239 if (url) |
| 234 { | 240 { |
| 235 let subscription = Subscription.fromURL(url); | 241 let subscription = Subscription.fromURL(url); |
| 236 subscription.disabled = false; | 242 subscription.disabled = false; |
| 237 subscription.title = node.getAttribute("title"); | 243 subscription.title = node.getAttribute("title"); |
| 238 subscription.homepage = node.getAttribute("homepage"); | 244 subscription.homepage = node.getAttribute("homepage"); |
| 239 subscription.type = node.getAttribute("type"); | 245 subscription.type = type; |
| 240 subscriptions.push(subscription); | 246 subscriptions.push(subscription); |
| 247 if (subscription.type == "circumvention") | |
| 248 Prefs.subscriptions_checkedanticv = true; | |
| 241 } | 249 } |
| 242 } | 250 } |
| 243 } | 251 } |
| 244 | 252 |
| 245 return subscriptions; | 253 return subscriptions; |
| 246 }); | 254 }); |
| 247 } | 255 } |
| 248 | 256 |
| 249 return subscriptions; | 257 return subscriptions; |
| 250 } | 258 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 * | 332 * |
| 325 * @param {function} callback | 333 * @param {function} callback |
| 326 */ | 334 */ |
| 327 exports.setSubscriptionsCallback = callback => | 335 exports.setSubscriptionsCallback = callback => |
| 328 { | 336 { |
| 329 subscriptionsCallback = callback; | 337 subscriptionsCallback = callback; |
| 330 }; | 338 }; |
| 331 | 339 |
| 332 // Exports for tests only | 340 // Exports for tests only |
| 333 exports.chooseFilterSubscriptions = chooseFilterSubscriptions; | 341 exports.chooseFilterSubscriptions = chooseFilterSubscriptions; |
| OLD | NEW |