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 |
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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 } | 231 } |
231 | 232 |
232 element.setAttribute("aria-label", title); | 233 element.setAttribute("aria-label", title); |
233 if (this.details[i].searchable) | 234 if (this.details[i].searchable) |
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) |
| 241 { |
240 control.disabled = true; | 242 control.disabled = true; |
| 243 } |
| 244 } |
| 245 if (additionalSubscriptions.includes(item.url)) |
| 246 { |
| 247 element.classList.add("preconfigured"); |
| 248 let disablePreconfigures = |
| 249 element.querySelectorAll("[data-disable~='preconfigured']"); |
| 250 for (let disablePreconfigure of disablePreconfigures) |
| 251 disablePreconfigure.disabled = true; |
241 } | 252 } |
242 | 253 |
243 let lastUpdateElement = element.querySelector(".last-update"); | 254 let lastUpdateElement = element.querySelector(".last-update"); |
244 if (lastUpdateElement) | 255 if (lastUpdateElement) |
245 { | 256 { |
246 let message = element.querySelector(".message"); | 257 let message = element.querySelector(".message"); |
247 if (item.isDownloading) | 258 if (item.isDownloading) |
248 { | 259 { |
249 let text = getMessage("options_filterList_lastDownload_inProgress"); | 260 let text = getMessage("options_filterList_lastDownload_inProgress"); |
250 message.textContent = text; | 261 message.textContent = text; |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 acceptableAdsUrl = url; | 1174 acceptableAdsUrl = url; |
1164 | 1175 |
1165 browser.runtime.sendMessage({ | 1176 browser.runtime.sendMessage({ |
1166 type: "prefs.get", | 1177 type: "prefs.get", |
1167 key: "subscriptions_exceptionsurl_privacy" | 1178 key: "subscriptions_exceptionsurl_privacy" |
1168 }, | 1179 }, |
1169 (urlPrivacy) => | 1180 (urlPrivacy) => |
1170 { | 1181 { |
1171 acceptableAdsPrivacyUrl = urlPrivacy; | 1182 acceptableAdsPrivacyUrl = urlPrivacy; |
1172 | 1183 |
1173 // Load user subscriptions | 1184 getPref("additional_subscriptions", (subscriptionUrls) => |
1174 browser.runtime.sendMessage({ | |
1175 type: "subscriptions.get", | |
1176 downloadable: true | |
1177 }, | |
1178 (subscriptions) => | |
1179 { | 1185 { |
1180 for (let subscription of subscriptions) | 1186 additionalSubscriptions = subscriptionUrls; |
1181 onSubscriptionMessage("added", subscription); | |
1182 | 1187 |
1183 setAcceptableAds(); | 1188 // Load user subscriptions |
| 1189 browser.runtime.sendMessage({ |
| 1190 type: "subscriptions.get", |
| 1191 downloadable: true |
| 1192 }, |
| 1193 (subscriptions) => |
| 1194 { |
| 1195 for (let subscription of subscriptions) |
| 1196 onSubscriptionMessage("added", subscription); |
| 1197 |
| 1198 setAcceptableAds(); |
| 1199 }); |
1184 }); | 1200 }); |
1185 }); | 1201 }); |
1186 }); | 1202 }); |
1187 } | 1203 } |
1188 | 1204 |
1189 function addWhitelistedDomain() | 1205 function addWhitelistedDomain() |
1190 { | 1206 { |
1191 let domain = E("whitelisting-textbox"); | 1207 let domain = E("whitelisting-textbox"); |
1192 for (let whitelistItem of collections.whitelist.items) | 1208 for (let whitelistItem of collections.whitelist.items) |
1193 { | 1209 { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 "ui_warn_tracking"] | 1481 "ui_warn_tracking"] |
1466 }); | 1482 }); |
1467 browser.runtime.sendMessage({ | 1483 browser.runtime.sendMessage({ |
1468 type: "subscriptions.listen", | 1484 type: "subscriptions.listen", |
1469 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1485 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1470 "title", "downloadStatus", "downloading"] | 1486 "title", "downloadStatus", "downloading"] |
1471 }); | 1487 }); |
1472 | 1488 |
1473 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1489 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1474 window.addEventListener("hashchange", onHashChange, false); | 1490 window.addEventListener("hashchange", onHashChange, false); |
OLD | NEW |