| 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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 type + "_title"); | 526 type + "_title"); |
| 527 } | 527 } |
| 528 | 528 |
| 529 addSubscription(subscription); | 529 addSubscription(subscription); |
| 530 } | 530 } |
| 531 }); | 531 }); |
| 532 } | 532 } |
| 533 | 533 |
| 534 function findParentData(element, dataName, returnElement) | 534 function findParentData(element, dataName, returnElement) |
| 535 { | 535 { |
| 536 while (element) | 536 element = element.closest(`[data-${dataName}]`); |
| 537 { | 537 if (!element) |
| 538 if (element.hasAttribute("data-" + dataName)) | 538 return null; |
| 539 { | 539 if (returnElement) |
| 540 if (returnElement) | 540 return element; |
| 541 return element; | 541 return element.getAttribute(`data-${dataName}`); |
| 542 return element.getAttribute("data-" + dataName); | |
| 543 } | |
| 544 | |
| 545 element = element.parentElement; | |
| 546 } | |
| 547 return null; | |
| 548 } | 542 } |
| 549 | 543 |
| 550 function sendMessageHandleErrors(message, onSuccess) | 544 function sendMessageHandleErrors(message, onSuccess) |
| 551 { | 545 { |
| 552 browser.runtime.sendMessage(message, (errors) => | 546 browser.runtime.sendMessage(message, (errors) => |
| 553 { | 547 { |
| 554 if (errors.length > 0) | 548 if (errors.length > 0) |
| 555 alert(errors.join("\n")); | 549 alert(errors.join("\n")); |
| 556 else if (onSuccess) | 550 else if (onSuccess) |
| 557 onSuccess(); | 551 onSuccess(); |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 | 905 |
| 912 // General tab | 906 // General tab |
| 913 getDocLink("contribute", (link) => | 907 getDocLink("contribute", (link) => |
| 914 { | 908 { |
| 915 E("contribute").href = link; | 909 E("contribute").href = link; |
| 916 }); | 910 }); |
| 917 getDocLink("acceptable_ads_criteria", (link) => | 911 getDocLink("acceptable_ads_criteria", (link) => |
| 918 { | 912 { |
| 919 setLinks("enable-acceptable-ads-description", link); | 913 setLinks("enable-acceptable-ads-description", link); |
| 920 }); | 914 }); |
| 921 setElementText(E("tracking-warning-1"), "options_tracking_warning_1", | 915 setElementText(E("tracking-warning-1"), "options_tracking_warning_1", |
| 922 [getMessage("common_feature_privacy_title"), | 916 [getMessage("common_feature_privacy_title"), |
| 923 getMessage("options_acceptableAds_ads_label")]); | 917 getMessage("options_acceptableAds_ads_label")]); |
| 924 setElementText(E("tracking-warning-3"), "options_tracking_warning_3", | 918 setElementText(E("tracking-warning-3"), "options_tracking_warning_3", |
| 925 [getMessage("options_acceptableAds_privacy_label")]); | 919 [getMessage("options_acceptableAds_privacy_label")]); |
| 926 | 920 |
| 927 getDocLink("privacy_friendly_ads", (link) => | 921 getDocLink("privacy_friendly_ads", (link) => |
| 928 { | 922 { |
| 929 E("enable-acceptable-ads-privacy-description").href = link; | 923 E("enable-acceptable-ads-privacy-description").href = link; |
| 930 }); | 924 }); |
| 931 getDocLink("adblock_plus_{browser}_dnt", url => | 925 getDocLink("adblock_plus_{browser}_dnt", url => |
| 932 { | 926 { |
| 933 setLinks("dnt", url); | 927 setLinks("dnt", url); |
| 934 }); | 928 }); |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1288 setPrivacyConflict(); | 1282 setPrivacyConflict(); |
| 1289 break; | 1283 break; |
| 1290 case "downloading": | 1284 case "downloading": |
| 1291 case "downloadStatus": | 1285 case "downloadStatus": |
| 1292 case "homepage": | 1286 case "homepage": |
| 1293 case "lastDownload": | 1287 case "lastDownload": |
| 1294 case "title": | 1288 case "title": |
| 1295 updateSubscription(subscription); | 1289 updateSubscription(subscription); |
| 1296 break; | 1290 break; |
| 1297 case "added": | 1291 case "added": |
| 1298 let {url, recommended} = subscription; | 1292 let {url} = subscription; |
| 1299 // Handle custom subscription | 1293 // Handle custom subscription |
| 1300 if (/^~user/.test(url)) | 1294 if (/^~user/.test(url)) |
| 1301 { | 1295 { |
| 1302 loadCustomFilters(subscription.filters); | 1296 loadCustomFilters(subscription.filters); |
| 1303 return; | 1297 return; |
| 1304 } | 1298 } |
| 1305 else if (url in subscriptionsMap) | 1299 else if (url in subscriptionsMap) |
| 1306 updateSubscription(subscription); | 1300 updateSubscription(subscription); |
| 1307 else | 1301 else |
| 1308 addSubscription(subscription); | 1302 addSubscription(subscription); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1469 }); | 1463 }); |
| 1470 browser.runtime.sendMessage({ | 1464 browser.runtime.sendMessage({ |
| 1471 type: "subscriptions.listen", | 1465 type: "subscriptions.listen", |
| 1472 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1466 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1473 "title", "downloadStatus", "downloading"] | 1467 "title", "downloadStatus", "downloading"] |
| 1474 }); | 1468 }); |
| 1475 | 1469 |
| 1476 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1470 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1477 window.addEventListener("hashchange", onHashChange, false); | 1471 window.addEventListener("hashchange", onHashChange, false); |
| 1478 } | 1472 } |
| OLD | NEW |