LEFT | RIGHT |
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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 /* globals checkShareResource, getDocLink, i18nFormatDateTime, openSharePopup, | 18 /* globals checkShareResource, getDocLink, i18nFormatDateTime, openSharePopup, |
19 setLinks, E */ | 19 setLinks, E */ |
20 | 20 |
21 "use strict"; | 21 "use strict"; |
22 | 22 |
23 let subscriptionsMap = Object.create(null); | 23 let subscriptionsMap = Object.create(null); |
24 let filtersMap = Object.create(null); | 24 let filtersMap = Object.create(null); |
25 let collections = Object.create(null); | 25 let collections = Object.create(null); |
26 let acceptableAdsUrl = null; | 26 let acceptableAdsUrl = null; |
27 let acceptableAdsPrivacyUrl = null; | 27 let acceptableAdsPrivacyUrl = null; |
28 let isCustomFiltersLoaded = false; | 28 let isCustomFiltersLoaded = false; |
| 29 let additionalSubscriptions = []; |
29 let {getMessage} = browser.i18n; | 30 let {getMessage} = browser.i18n; |
30 let {setElementText} = ext.i18n; | 31 let {setElementText} = ext.i18n; |
31 let customFilters = []; | 32 let customFilters = []; |
32 let filterErrors = new Map([ | 33 let filterErrors = new Map([ |
33 ["synchronize_invalid_url", | 34 ["synchronize_invalid_url", |
34 "options_filterList_lastDownload_invalidURL"], | 35 "options_filterList_lastDownload_invalidURL"], |
35 ["synchronize_connection_error", | 36 ["synchronize_connection_error", |
36 "options_filterList_lastDownload_connectionError"], | 37 "options_filterList_lastDownload_connectionError"], |
37 ["synchronize_invalid_data", | 38 ["synchronize_invalid_data", |
38 "options_filterList_lastDownload_invalidData"], | 39 "options_filterList_lastDownload_invalidData"], |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 element.setAttribute("data-search", title.toLowerCase()); | 235 element.setAttribute("data-search", title.toLowerCase()); |
235 let controls = element.querySelectorAll(".control[role='checkbox']"); | 236 let controls = element.querySelectorAll(".control[role='checkbox']"); |
236 for (let control of controls) | 237 for (let control of controls) |
237 { | 238 { |
238 control.setAttribute("aria-checked", item.disabled == false); | 239 control.setAttribute("aria-checked", item.disabled == false); |
239 if (isAcceptableAds(item.url) && this == collections.filterLists) | 240 if (isAcceptableAds(item.url) && this == collections.filterLists) |
240 { | 241 { |
241 control.disabled = true; | 242 control.disabled = true; |
242 } | 243 } |
243 } | 244 } |
244 getPref("additional_subscriptions", (additionalSubscriptions) => | 245 if (additionalSubscriptions.includes(item.url)) |
245 { | 246 { |
246 if (additionalSubscriptions.includes(item.url)) | 247 element.classList.add("preconfigured"); |
247 { | 248 let disablePreconfigures = |
248 element.classList.add("preconfigured"); | 249 element.querySelectorAll("[data-disable~='preconfigured']"); |
249 if (this == collections.protection) | 250 for (let disablePreconfigure of disablePreconfigures) |
250 controls[0].disabled = true; | 251 disablePreconfigure.disabled = true; |
251 } | 252 } |
252 }); | |
253 | 253 |
254 let lastUpdateElement = element.querySelector(".last-update"); | 254 let lastUpdateElement = element.querySelector(".last-update"); |
255 if (lastUpdateElement) | 255 if (lastUpdateElement) |
256 { | 256 { |
257 let message = element.querySelector(".message"); | 257 let message = element.querySelector(".message"); |
258 if (item.isDownloading) | 258 if (item.isDownloading) |
259 { | 259 { |
260 let text = getMessage("options_filterList_lastDownload_inProgress"); | 260 let text = getMessage("options_filterList_lastDownload_inProgress"); |
261 message.textContent = text; | 261 message.textContent = text; |
262 element.classList.add("show-message"); | 262 element.classList.add("show-message"); |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 acceptableAdsUrl = url; | 1174 acceptableAdsUrl = url; |
1175 | 1175 |
1176 browser.runtime.sendMessage({ | 1176 browser.runtime.sendMessage({ |
1177 type: "prefs.get", | 1177 type: "prefs.get", |
1178 key: "subscriptions_exceptionsurl_privacy" | 1178 key: "subscriptions_exceptionsurl_privacy" |
1179 }, | 1179 }, |
1180 (urlPrivacy) => | 1180 (urlPrivacy) => |
1181 { | 1181 { |
1182 acceptableAdsPrivacyUrl = urlPrivacy; | 1182 acceptableAdsPrivacyUrl = urlPrivacy; |
1183 | 1183 |
1184 // Load user subscriptions | 1184 getPref("additional_subscriptions", (subscriptionUrls) => |
1185 browser.runtime.sendMessage({ | 1185 { |
1186 type: "subscriptions.get", | 1186 additionalSubscriptions = subscriptionUrls; |
1187 downloadable: true | 1187 |
1188 }, | 1188 // Load user subscriptions |
1189 (subscriptions) => | 1189 browser.runtime.sendMessage({ |
1190 { | 1190 type: "subscriptions.get", |
1191 for (let subscription of subscriptions) | 1191 downloadable: true |
1192 onSubscriptionMessage("added", subscription); | 1192 }, |
1193 | 1193 (subscriptions) => |
1194 setAcceptableAds(); | 1194 { |
| 1195 for (let subscription of subscriptions) |
| 1196 onSubscriptionMessage("added", subscription); |
| 1197 |
| 1198 setAcceptableAds(); |
| 1199 }); |
1195 }); | 1200 }); |
1196 }); | 1201 }); |
1197 }); | 1202 }); |
1198 } | 1203 } |
1199 | 1204 |
1200 function addWhitelistedDomain() | 1205 function addWhitelistedDomain() |
1201 { | 1206 { |
1202 let domain = E("whitelisting-textbox"); | 1207 let domain = E("whitelisting-textbox"); |
1203 for (let whitelistItem of collections.whitelist.items) | 1208 for (let whitelistItem of collections.whitelist.items) |
1204 { | 1209 { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 "ui_warn_tracking"] | 1481 "ui_warn_tracking"] |
1477 }); | 1482 }); |
1478 browser.runtime.sendMessage({ | 1483 browser.runtime.sendMessage({ |
1479 type: "subscriptions.listen", | 1484 type: "subscriptions.listen", |
1480 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1485 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1481 "title", "downloadStatus", "downloading"] | 1486 "title", "downloadStatus", "downloading"] |
1482 }); | 1487 }); |
1483 | 1488 |
1484 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1489 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1485 window.addEventListener("hashchange", onHashChange, false); | 1490 window.addEventListener("hashchange", onHashChange, false); |
LEFT | RIGHT |