| 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}]`); |
|
Thomas Greiner
2018/01/18 16:20:46
Nice, I wasn't even aware of this method. :)
| |
| 537 if (element) | |
|
Thomas Greiner
2018/01/18 16:20:46
Detail: We can save one level of indentation by re
a.giammarchi
2018/01/19 17:02:28
Done.
| |
| 537 { | 538 { |
| 538 if (element.hasAttribute("data-" + dataName)) | 539 if (returnElement) return element; |
|
Thomas Greiner
2018/01/18 16:20:46
Detail: We tend to avoid single-line if-statements
a.giammarchi
2018/01/19 11:16:48
to be honest, there's no way I am going to remembe
Thomas Greiner
2018/01/19 13:55:16
Our coding style wasn't written with compatibility
a.giammarchi
2018/01/19 14:16:28
it's good you mentioned that ... 'cause I need a C
a.giammarchi
2018/01/19 17:02:28
Done.
a.giammarchi
2018/01/19 17:02:28
Done.
Thomas Greiner
2018/01/22 13:06:38
That's a very noble approach. I'd be curious to he
| |
| 539 { | 540 return element.getAttribute(`data-${dataName}`); |
| 540 if (returnElement) | |
| 541 return element; | |
| 542 return element.getAttribute("data-" + dataName); | |
| 543 } | |
| 544 | |
| 545 element = element.parentElement; | |
| 546 } | 541 } |
| 547 return null; | 542 return null; |
| 548 } | 543 } |
| 549 | 544 |
| 550 function sendMessageHandleErrors(message, onSuccess) | 545 function sendMessageHandleErrors(message, onSuccess) |
| 551 { | 546 { |
| 552 browser.runtime.sendMessage(message, (errors) => | 547 browser.runtime.sendMessage(message, (errors) => |
| 553 { | 548 { |
| 554 if (errors.length > 0) | 549 if (errors.length > 0) |
| 555 alert(errors.join("\n")); | 550 alert(errors.join("\n")); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 911 | 906 |
| 912 // General tab | 907 // General tab |
| 913 getDocLink("contribute", (link) => | 908 getDocLink("contribute", (link) => |
| 914 { | 909 { |
| 915 E("contribute").href = link; | 910 E("contribute").href = link; |
| 916 }); | 911 }); |
| 917 getDocLink("acceptable_ads_criteria", (link) => | 912 getDocLink("acceptable_ads_criteria", (link) => |
| 918 { | 913 { |
| 919 setLinks("enable-acceptable-ads-description", link); | 914 setLinks("enable-acceptable-ads-description", link); |
| 920 }); | 915 }); |
| 921 setElementText(E("tracking-warning-1"), "options_tracking_warning_1", | 916 setElementText(E("tracking-warning-1"), "options_tracking_warning_1", |
| 922 [getMessage("common_feature_privacy_title"), | 917 [getMessage("common_feature_privacy_title"), |
| 923 getMessage("options_acceptableAds_ads_label")]); | 918 getMessage("options_acceptableAds_ads_label")]); |
| 924 setElementText(E("tracking-warning-3"), "options_tracking_warning_3", | 919 setElementText(E("tracking-warning-3"), "options_tracking_warning_3", |
| 925 [getMessage("options_acceptableAds_privacy_label")]); | 920 [getMessage("options_acceptableAds_privacy_label")]); |
| 926 | 921 |
| 927 getDocLink("privacy_friendly_ads", (link) => | 922 getDocLink("privacy_friendly_ads", (link) => |
| 928 { | 923 { |
| 929 E("enable-acceptable-ads-privacy-description").href = link; | 924 E("enable-acceptable-ads-privacy-description").href = link; |
| 930 }); | 925 }); |
| 931 getDocLink("adblock_plus_{browser}_dnt", url => | 926 getDocLink("adblock_plus_{browser}_dnt", url => |
| 932 { | 927 { |
| 933 setLinks("dnt", url); | 928 setLinks("dnt", url); |
| 934 }); | 929 }); |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1288 setPrivacyConflict(); | 1283 setPrivacyConflict(); |
| 1289 break; | 1284 break; |
| 1290 case "downloading": | 1285 case "downloading": |
| 1291 case "downloadStatus": | 1286 case "downloadStatus": |
| 1292 case "homepage": | 1287 case "homepage": |
| 1293 case "lastDownload": | 1288 case "lastDownload": |
| 1294 case "title": | 1289 case "title": |
| 1295 updateSubscription(subscription); | 1290 updateSubscription(subscription); |
| 1296 break; | 1291 break; |
| 1297 case "added": | 1292 case "added": |
| 1298 let {url, recommended} = subscription; | 1293 let {url} = subscription; |
| 1299 // Handle custom subscription | 1294 // Handle custom subscription |
| 1300 if (/^~user/.test(url)) | 1295 if (/^~user/.test(url)) |
| 1301 { | 1296 { |
| 1302 loadCustomFilters(subscription.filters); | 1297 loadCustomFilters(subscription.filters); |
| 1303 return; | 1298 return; |
| 1304 } | 1299 } |
| 1305 else if (url in subscriptionsMap) | 1300 else if (url in subscriptionsMap) |
| 1306 updateSubscription(subscription); | 1301 updateSubscription(subscription); |
| 1307 else | 1302 else |
| 1308 addSubscription(subscription); | 1303 addSubscription(subscription); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1469 }); | 1464 }); |
| 1470 browser.runtime.sendMessage({ | 1465 browser.runtime.sendMessage({ |
| 1471 type: "subscriptions.listen", | 1466 type: "subscriptions.listen", |
| 1472 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1467 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1473 "title", "downloadStatus", "downloading"] | 1468 "title", "downloadStatus", "downloading"] |
| 1474 }); | 1469 }); |
| 1475 | 1470 |
| 1476 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1471 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1477 window.addEventListener("hashchange", onHashChange, false); | 1472 window.addEventListener("hashchange", onHashChange, false); |
| 1478 } | 1473 } |
| OLD | NEW |