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 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}]`); |
saroyanm
2018/02/08 14:59:09
Detail: We are usually careful when it comes to ex
a.giammarchi
2018/02/08 15:07:21
FWIW closest is not really experimental, it has be
saroyanm
2018/02/08 15:20:18
According to MDN it is -> https://developer.mozill
a.giammarchi
2018/02/08 15:27:29
don't trust everything you read in MDN ... it's up
saroyanm
2018/02/08 15:38:30
Thanks for the links and info.
Acknowledged.
| |
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1080 { | 1074 { |
1081 acceptableAds.setAttribute("aria-checked", true); | 1075 acceptableAds.setAttribute("aria-checked", true); |
1082 acceptableAdsPrivacy.setAttribute("aria-disabled", false); | 1076 acceptableAdsPrivacy.setAttribute("aria-disabled", false); |
1083 } | 1077 } |
1084 else if (acceptableAdsPrivacyUrl in subscriptionsMap) | 1078 else if (acceptableAdsPrivacyUrl in subscriptionsMap) |
1085 { | 1079 { |
1086 acceptableAds.setAttribute("aria-checked", true); | 1080 acceptableAds.setAttribute("aria-checked", true); |
1087 acceptableAdsPrivacy.setAttribute("aria-checked", true); | 1081 acceptableAdsPrivacy.setAttribute("aria-checked", true); |
1088 acceptableAdsPrivacy.setAttribute("aria-disabled", false); | 1082 acceptableAdsPrivacy.setAttribute("aria-disabled", false); |
1089 | 1083 |
1090 if (navigator.doNotTrack != 1) | 1084 if (navigator.doNotTrack != 1) |
saroyanm
2018/02/08 14:59:09
Edge uses window.doNotTrack:
https://developer.mo
| |
1091 acceptableAdsForm.classList.add("show-dnt-notification"); | 1085 acceptableAdsForm.classList.add("show-dnt-notification"); |
1092 } | 1086 } |
1093 else | 1087 else |
1094 { | 1088 { |
1095 // Using aria-disabled in order to keep the focus | 1089 // Using aria-disabled in order to keep the focus |
1096 acceptableAdsPrivacy.setAttribute("aria-disabled", true); | 1090 acceptableAdsPrivacy.setAttribute("aria-disabled", true); |
1097 acceptableAdsPrivacy.setAttribute("tabindex", -1); | 1091 acceptableAdsPrivacy.setAttribute("tabindex", -1); |
1098 } | 1092 } |
1099 } | 1093 } |
1100 | 1094 |
(...skipping 187 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 |