Left: | ||
Right: |
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 { | 23 { |
24 let subscriptionsMap = Object.create(null); | 24 let subscriptionsMap = Object.create(null); |
25 let filtersMap = Object.create(null); | 25 let filtersMap = Object.create(null); |
26 let collections = Object.create(null); | 26 let collections = Object.create(null); |
27 let acceptableAdsUrl = null; | 27 let acceptableAdsUrl = null; |
28 let acceptableAdsPrivacyUrl = null; | 28 let acceptableAdsPrivacyUrl = null; |
29 let isCustomFiltersLoaded = false; | 29 let isCustomFiltersLoaded = false; |
30 let {getMessage} = chrome.i18n; | 30 let {getMessage} = browser.i18n; |
31 let customFilters = []; | 31 let customFilters = []; |
32 let filterErrors = new Map([ | 32 let filterErrors = new Map([ |
33 ["synchronize_invalid_url", | 33 ["synchronize_invalid_url", |
34 "options_filterList_lastDownload_invalidURL"], | 34 "options_filterList_lastDownload_invalidURL"], |
35 ["synchronize_connection_error", | 35 ["synchronize_connection_error", |
36 "options_filterList_lastDownload_connectionError"], | 36 "options_filterList_lastDownload_connectionError"], |
37 ["synchronize_invalid_data", | 37 ["synchronize_invalid_data", |
38 "options_filterList_lastDownload_invalidData"], | 38 "options_filterList_lastDownload_invalidData"], |
39 ["synchronize_checksum_mismatch", | 39 ["synchronize_checksum_mismatch", |
40 "options_filterList_lastDownload_checksumMismatch"] | 40 "options_filterList_lastDownload_checksumMismatch"] |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
536 return element.getAttribute("data-" + dataName); | 536 return element.getAttribute("data-" + dataName); |
537 } | 537 } |
538 | 538 |
539 element = element.parentElement; | 539 element = element.parentElement; |
540 } | 540 } |
541 return null; | 541 return null; |
542 } | 542 } |
543 | 543 |
544 function sendMessageHandleErrors(message, onSuccess) | 544 function sendMessageHandleErrors(message, onSuccess) |
545 { | 545 { |
546 chrome.runtime.sendMessage(message, (errors) => | 546 browser.runtime.sendMessage(message, (errors) => |
547 { | 547 { |
548 if (errors.length > 0) | 548 if (errors.length > 0) |
549 alert(errors.join("\n")); | 549 alert(errors.join("\n")); |
550 else if (onSuccess) | 550 else if (onSuccess) |
551 onSuccess(); | 551 onSuccess(); |
552 }); | 552 }); |
553 } | 553 } |
554 | 554 |
555 function switchTab(id) | 555 function switchTab(id) |
556 { | 556 { |
557 location.hash = id; | 557 location.hash = id; |
558 } | 558 } |
559 | 559 |
560 function execAction(action, element) | 560 function execAction(action, element) |
561 { | 561 { |
562 if (element.getAttribute("aria-disabled") == "true") | |
563 return; | |
564 | |
562 switch (action) | 565 switch (action) |
563 { | 566 { |
564 case "add-domain-exception": | 567 case "add-domain-exception": |
565 addWhitelistedDomain(); | 568 addWhitelistedDomain(); |
566 break; | 569 break; |
567 case "add-language-subscription": | 570 case "add-language-subscription": |
568 addEnableSubscription(findParentData(element, "access", false)); | 571 addEnableSubscription(findParentData(element, "access", false)); |
569 break; | 572 break; |
570 case "add-predefined-subscription": { | 573 case "add-predefined-subscription": { |
571 let dialog = E("dialog-content-predefined"); | 574 let dialog = E("dialog-content-predefined"); |
572 let title = dialog.querySelector("h3").textContent; | 575 let title = dialog.querySelector("h3").textContent; |
573 let url = dialog.querySelector(".url").textContent; | 576 let url = dialog.querySelector(".url").textContent; |
574 addEnableSubscription(url, title); | 577 addEnableSubscription(url, title); |
575 closeDialog(); | 578 closeDialog(); |
576 break; | 579 break; |
577 } | 580 } |
578 case "cancel-custom-filters": | 581 case "cancel-custom-filters": |
579 setCustomFiltersView("read"); | 582 setCustomFiltersView("read"); |
580 break; | 583 break; |
581 case "change-language-subscription": | 584 case "change-language-subscription": |
582 for (let key in subscriptionsMap) | 585 for (let key in subscriptionsMap) |
583 { | 586 { |
584 let subscription = subscriptionsMap[key]; | 587 let subscription = subscriptionsMap[key]; |
585 let subscriptionType = subscription.recommended; | 588 let subscriptionType = subscription.recommended; |
586 if (subscriptionType == "ads" && subscription.disabled == false) | 589 if (subscriptionType == "ads" && subscription.disabled == false) |
587 { | 590 { |
588 chrome.runtime.sendMessage({ | 591 browser.runtime.sendMessage({ |
589 type: "subscriptions.remove", | 592 type: "subscriptions.remove", |
590 url: subscription.url | 593 url: subscription.url |
591 }); | 594 }); |
592 chrome.runtime.sendMessage({ | 595 browser.runtime.sendMessage({ |
593 type: "subscriptions.add", | 596 type: "subscriptions.add", |
594 url: findParentData(element, "access", false) | 597 url: findParentData(element, "access", false) |
595 }); | 598 }); |
596 break; | 599 break; |
597 } | 600 } |
598 } | 601 } |
599 break; | 602 break; |
600 case "close-dialog": | 603 case "close-dialog": |
601 closeDialog(); | 604 closeDialog(); |
602 break; | 605 break; |
(...skipping 17 matching lines...) Expand all Loading... | |
620 if (listItem && !listItem.classList.contains("show-context-menu")) | 623 if (listItem && !listItem.classList.contains("show-context-menu")) |
621 listItem.classList.add("show-context-menu"); | 624 listItem.classList.add("show-context-menu"); |
622 break; | 625 break; |
623 } | 626 } |
624 case "open-dialog": { | 627 case "open-dialog": { |
625 let dialog = findParentData(element, "dialog", false); | 628 let dialog = findParentData(element, "dialog", false); |
626 openDialog(dialog); | 629 openDialog(dialog); |
627 break; | 630 break; |
628 } | 631 } |
629 case "remove-filter": | 632 case "remove-filter": |
630 chrome.runtime.sendMessage({ | 633 browser.runtime.sendMessage({ |
631 type: "filters.remove", | 634 type: "filters.remove", |
632 text: findParentData(element, "access", false) | 635 text: findParentData(element, "access", false) |
633 }); | 636 }); |
634 break; | 637 break; |
635 case "remove-subscription": | 638 case "remove-subscription": |
636 chrome.runtime.sendMessage({ | 639 browser.runtime.sendMessage({ |
637 type: "subscriptions.remove", | 640 type: "subscriptions.remove", |
638 url: findParentData(element, "access", false) | 641 url: findParentData(element, "access", false) |
639 }); | 642 }); |
640 break; | 643 break; |
641 case "save-custom-filters": | 644 case "save-custom-filters": |
642 sendMessageHandleErrors({ | 645 sendMessageHandleErrors({ |
643 type: "filters.importRaw", | 646 type: "filters.importRaw", |
644 text: E("custom-filters-raw").value, | 647 text: E("custom-filters-raw").value, |
645 removeExisting: true | 648 removeExisting: true |
646 }, | 649 }, |
647 () => | 650 () => |
648 { | 651 { |
649 setCustomFiltersView("read"); | 652 setCustomFiltersView("read"); |
650 }); | 653 }); |
651 break; | 654 break; |
652 case "show-more-filters-section": | 655 case "show-more-filters-section": |
653 E("more-filters").setAttribute("aria-hidden", false); | 656 E("more-filters").setAttribute("aria-hidden", false); |
654 break; | 657 break; |
655 case "switch-acceptable-ads": | 658 case "switch-acceptable-ads": |
656 let isChecked = element.getAttribute("aria-checked") == "true"; | |
657 let value = element.value || element.dataset.value; | 659 let value = element.value || element.dataset.value; |
658 let isAcceptableAds = value == "ads"; | 660 // User check the checkbox |
ire
2017/10/17 08:16:34
I'm getting the eslint error: isAcceptableAds is a
saroyanm
2017/10/17 19:23:07
Thanks, I isolated scope with the braces. Let me k
ire
2017/10/18 17:48:45
I'm still getting the same error, I don't think th
saroyanm
2017/10/19 20:41:55
Right, my bad, I thought it was a variable in the
ire
2017/10/20 08:14:41
I don't have a strong preference about the name. I
| |
659 | 661 let shouldCheck = element.getAttribute("aria-checked") != "true"; |
660 chrome.runtime.sendMessage({ | 662 let installAcceptableAds = false; |
661 type: isAcceptableAds != isChecked ? "subscriptions.add" : | 663 let installAcceptableAdsPrivacy = false; |
664 // Acceptable Ads checkbox clicked | |
665 if (value == "ads") | |
666 { | |
667 installAcceptableAds = shouldCheck; | |
668 } | |
669 // Privacy Friendly Acceptable Ads checkbox clicked | |
670 else | |
671 { | |
672 installAcceptableAdsPrivacy = shouldCheck; | |
673 installAcceptableAds = !shouldCheck; | |
674 } | |
675 | |
676 browser.runtime.sendMessage({ | |
677 type: installAcceptableAds ? "subscriptions.add" : | |
662 "subscriptions.remove", | 678 "subscriptions.remove", |
663 url: acceptableAdsUrl | 679 url: acceptableAdsUrl |
664 }); | 680 }); |
665 chrome.runtime.sendMessage({ | 681 browser.runtime.sendMessage({ |
666 type: isAcceptableAds || isChecked ? "subscriptions.remove" : | 682 type: installAcceptableAdsPrivacy ? "subscriptions.add" : |
667 "subscriptions.add", | 683 "subscriptions.remove", |
668 url: acceptableAdsPrivacyUrl | 684 url: acceptableAdsPrivacyUrl |
669 }); | 685 }); |
670 break; | 686 break; |
671 case "switch-tab": | 687 case "switch-tab": |
672 switchTab(element.getAttribute("href").substr(1)); | 688 switchTab(element.getAttribute("href").substr(1)); |
673 break; | 689 break; |
674 case "toggle-disable-subscription": | 690 case "toggle-disable-subscription": |
675 chrome.runtime.sendMessage({ | 691 browser.runtime.sendMessage({ |
676 type: "subscriptions.toggle", | 692 type: "subscriptions.toggle", |
677 keepInstalled: true, | 693 keepInstalled: true, |
678 url: findParentData(element, "access", false) | 694 url: findParentData(element, "access", false) |
679 }); | 695 }); |
680 break; | 696 break; |
681 case "toggle-pref": | 697 case "toggle-pref": |
682 chrome.runtime.sendMessage({ | 698 browser.runtime.sendMessage({ |
683 type: "prefs.toggle", | 699 type: "prefs.toggle", |
684 key: findParentData(element, "pref", false) | 700 key: findParentData(element, "pref", false) |
685 }); | 701 }); |
686 break; | 702 break; |
687 case "toggle-remove-subscription": | 703 case "toggle-remove-subscription": |
688 let subscriptionUrl = findParentData(element, "access", false); | 704 let subscriptionUrl = findParentData(element, "access", false); |
689 if (element.getAttribute("aria-checked") == "true") | 705 if (element.getAttribute("aria-checked") == "true") |
690 { | 706 { |
691 chrome.runtime.sendMessage({ | 707 browser.runtime.sendMessage({ |
692 type: "subscriptions.remove", | 708 type: "subscriptions.remove", |
693 url: subscriptionUrl | 709 url: subscriptionUrl |
694 }); | 710 }); |
695 } | 711 } |
696 else | 712 else |
697 addEnableSubscription(subscriptionUrl); | 713 addEnableSubscription(subscriptionUrl); |
698 break; | 714 break; |
699 case "update-all-subscriptions": | 715 case "update-all-subscriptions": |
700 chrome.runtime.sendMessage({ | 716 browser.runtime.sendMessage({ |
701 type: "subscriptions.update" | 717 type: "subscriptions.update" |
702 }); | 718 }); |
703 break; | 719 break; |
704 case "update-subscription": | 720 case "update-subscription": |
705 chrome.runtime.sendMessage({ | 721 browser.runtime.sendMessage({ |
706 type: "subscriptions.update", | 722 type: "subscriptions.update", |
707 url: findParentData(element, "access", false) | 723 url: findParentData(element, "access", false) |
708 }); | 724 }); |
709 break; | 725 break; |
710 case "validate-import-subscription": | 726 case "validate-import-subscription": |
711 let form = findParentData(element, "validation", true); | 727 let form = findParentData(element, "validation", true); |
712 if (!form) | 728 if (!form) |
713 return; | 729 return; |
714 | 730 |
715 if (form.checkValidity()) | 731 if (form.checkValidity()) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
857 if (!tabContent) | 873 if (!tabContent) |
858 break; | 874 break; |
859 } | 875 } |
860 } | 876 } |
861 | 877 |
862 function onDOMLoaded() | 878 function onDOMLoaded() |
863 { | 879 { |
864 populateLists(); | 880 populateLists(); |
865 | 881 |
866 // Initialize navigation sidebar | 882 // Initialize navigation sidebar |
867 chrome.runtime.sendMessage({ | 883 browser.runtime.sendMessage({ |
868 type: "app.get", | 884 type: "app.get", |
869 what: "addonVersion" | 885 what: "addonVersion" |
870 }, | 886 }, |
871 (addonVersion) => | 887 (addonVersion) => |
872 { | 888 { |
873 E("abp-version").textContent = getMessage("options_dialog_about_version", | 889 E("abp-version").textContent = getMessage("options_dialog_about_version", |
874 [addonVersion]); | 890 [addonVersion]); |
875 }); | 891 }); |
876 | 892 |
877 updateTooltips(); | 893 updateTooltips(); |
(...skipping 10 matching lines...) Expand all Loading... | |
888 }, false); | 904 }, false); |
889 | 905 |
890 getDocLink("contribute", (link) => | 906 getDocLink("contribute", (link) => |
891 { | 907 { |
892 E("contribute").href = link; | 908 E("contribute").href = link; |
893 }); | 909 }); |
894 getDocLink("acceptable_ads_criteria", (link) => | 910 getDocLink("acceptable_ads_criteria", (link) => |
895 { | 911 { |
896 setLinks("enable-acceptable-ads-description", link); | 912 setLinks("enable-acceptable-ads-description", link); |
897 }); | 913 }); |
898 getDocLink("privacy_friendly_ads", (link) => | 914 getDocLink("privacy_friendly_ads", (link) => |
saroyanm
2017/10/16 17:45:51
We still missing this redirection link, I'll reach
ire
2017/10/17 08:16:34
Acknowledged.
| |
899 { | 915 { |
900 setLinks("enable-acceptable-ads-privacy-description", link); | 916 E("enable-acceptable-ads-privacy-description").href = link; |
901 }); | 917 }); |
902 getDocLink("adblock_plus_{browser}_dnt", url => | 918 getDocLink("adblock_plus_{browser}_dnt", url => |
903 { | 919 { |
904 setLinks("dnt", url); | 920 setLinks("dnt", url); |
905 }); | 921 }); |
906 | 922 |
907 // Advanced tab | 923 // Advanced tab |
908 let customize = document.querySelectorAll("#customize li[data-pref]"); | 924 let customize = document.querySelectorAll("#customize li[data-pref]"); |
909 customize = Array.prototype.map.call(customize, (checkbox) => | 925 customize = Array.prototype.map.call(customize, (checkbox) => |
910 { | 926 { |
911 return checkbox.getAttribute("data-pref"); | 927 return checkbox.getAttribute("data-pref"); |
912 }); | 928 }); |
913 for (let key of customize) | 929 for (let key of customize) |
914 { | 930 { |
915 getPref(key, (value) => | 931 getPref(key, (value) => |
916 { | 932 { |
917 onPrefMessage(key, value, true); | 933 onPrefMessage(key, value, true); |
918 }); | 934 }); |
919 } | 935 } |
920 chrome.runtime.sendMessage({ | 936 browser.runtime.sendMessage({ |
921 type: "app.get", | 937 type: "app.get", |
922 what: "features" | 938 what: "features" |
923 }, | 939 }, |
924 (features) => | 940 (features) => |
925 { | 941 { |
926 hidePref("show_devtools_panel", !features.devToolsPanel); | 942 hidePref("show_devtools_panel", !features.devToolsPanel); |
927 }); | 943 }); |
928 | 944 |
929 getDocLink("filterdoc", (link) => | 945 getDocLink("filterdoc", (link) => |
930 { | 946 { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1041 } | 1057 } |
1042 | 1058 |
1043 function setAcceptableAds() | 1059 function setAcceptableAds() |
1044 { | 1060 { |
1045 let acceptableAdsForm = E("acceptable-ads"); | 1061 let acceptableAdsForm = E("acceptable-ads"); |
1046 let acceptableAds = E("acceptable-ads-allow"); | 1062 let acceptableAds = E("acceptable-ads-allow"); |
1047 let acceptableAdsPrivacy = E("acceptable-ads-privacy-allow"); | 1063 let acceptableAdsPrivacy = E("acceptable-ads-privacy-allow"); |
1048 acceptableAdsForm.classList.remove("show-dnt-notification"); | 1064 acceptableAdsForm.classList.remove("show-dnt-notification"); |
1049 acceptableAds.setAttribute("aria-checked", false); | 1065 acceptableAds.setAttribute("aria-checked", false); |
1050 acceptableAdsPrivacy.setAttribute("aria-checked", false); | 1066 acceptableAdsPrivacy.setAttribute("aria-checked", false); |
1051 acceptableAdsPrivacy.disabled = true; | 1067 acceptableAdsPrivacy.setAttribute("tabindex", 0); |
ire
2017/10/17 08:16:34
When you toggle the acceptableAdsPrivacy checkbox
saroyanm
2017/10/17 19:23:07
yes this is trickier than it appears. I'll try to
saroyanm
2017/10/17 19:54:29
Done.
ire
2017/10/18 17:48:45
Ah I see, very tricky!
| |
1052 if (acceptableAdsUrl in subscriptionsMap) | 1068 if (acceptableAdsUrl in subscriptionsMap) |
1053 { | 1069 { |
1054 acceptableAds.setAttribute("aria-checked", true); | 1070 acceptableAds.setAttribute("aria-checked", true); |
1055 acceptableAdsPrivacy.disabled = false; | 1071 acceptableAdsPrivacy.setAttribute("aria-disabled", false); |
1056 } | 1072 } |
1057 else if (acceptableAdsPrivacyUrl in subscriptionsMap) | 1073 else if (acceptableAdsPrivacyUrl in subscriptionsMap) |
1058 { | 1074 { |
1059 acceptableAds.setAttribute("aria-checked", true); | 1075 acceptableAds.setAttribute("aria-checked", true); |
1060 acceptableAdsPrivacy.setAttribute("aria-checked", true); | 1076 acceptableAdsPrivacy.setAttribute("aria-checked", true); |
1061 acceptableAdsPrivacy.disabled = false; | 1077 acceptableAdsPrivacy.setAttribute("aria-disabled", false); |
1062 | 1078 |
1063 if (navigator.doNotTrack != 1) | 1079 if (navigator.doNotTrack != 1) |
saroyanm
2017/10/16 17:45:52
See -> https://issues.adblockplus.org/ticket/5866
ire
2017/10/17 08:16:34
Seen. I agree with you.
ire
2017/10/17 08:16:34
I don't know if support for Edge/Safari is relevan
saroyanm
2017/10/17 19:23:07
We don't consider Safari, but it make sense for th
ire
2017/10/18 17:48:45
Acknowledged.
| |
1064 acceptableAdsForm.classList.add("show-dnt-notification"); | 1080 acceptableAdsForm.classList.add("show-dnt-notification"); |
1081 } | |
1082 else | |
1083 { | |
1084 // Using aria-disabled in order to keep the focus | |
1085 acceptableAdsPrivacy.setAttribute("aria-disabled", true); | |
1086 acceptableAdsPrivacy.setAttribute("tabindex", -1); | |
1065 } | 1087 } |
1066 } | 1088 } |
1067 | 1089 |
1068 function isAcceptableAds(url) | 1090 function isAcceptableAds(url) |
1069 { | 1091 { |
1070 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; | 1092 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; |
1071 } | 1093 } |
1072 | 1094 |
1073 function populateLists() | 1095 function populateLists() |
1074 { | 1096 { |
1075 subscriptionsMap = Object.create(null); | 1097 subscriptionsMap = Object.create(null); |
1076 filtersMap = Object.create(null); | 1098 filtersMap = Object.create(null); |
1077 | 1099 |
1078 // Empty collections and lists | 1100 // Empty collections and lists |
1079 for (let property in collections) | 1101 for (let property in collections) |
1080 collections[property].clearAll(); | 1102 collections[property].clearAll(); |
1081 | 1103 |
1082 setCustomFiltersView("empty"); | 1104 setCustomFiltersView("empty"); |
1083 chrome.runtime.sendMessage({ | 1105 browser.runtime.sendMessage({ |
1084 type: "subscriptions.get", | 1106 type: "subscriptions.get", |
1085 special: true | 1107 special: true |
1086 }, | 1108 }, |
1087 (subscriptions) => | 1109 (subscriptions) => |
1088 { | 1110 { |
1089 // Load filters | 1111 // Load filters |
1090 for (let subscription of subscriptions) | 1112 for (let subscription of subscriptions) |
1091 { | 1113 { |
1092 chrome.runtime.sendMessage({ | 1114 browser.runtime.sendMessage({ |
1093 type: "filters.get", | 1115 type: "filters.get", |
1094 subscriptionUrl: subscription.url | 1116 subscriptionUrl: subscription.url |
1095 }, | 1117 }, |
1096 (filters) => | 1118 (filters) => |
1097 { | 1119 { |
1098 loadCustomFilters(filters); | 1120 loadCustomFilters(filters); |
1099 }); | 1121 }); |
1100 } | 1122 } |
1101 }); | 1123 }); |
1102 loadRecommendations(); | 1124 loadRecommendations(); |
1103 chrome.runtime.sendMessage({ | 1125 browser.runtime.sendMessage({ |
1104 type: "prefs.get", | 1126 type: "prefs.get", |
1105 key: "subscriptions_exceptionsurl" | 1127 key: "subscriptions_exceptionsurl" |
1106 }, | 1128 }, |
1107 (url) => | 1129 (url) => |
1108 { | 1130 { |
1109 acceptableAdsUrl = url; | 1131 acceptableAdsUrl = url; |
1110 | 1132 |
1111 chrome.runtime.sendMessage({ | 1133 browser.runtime.sendMessage({ |
1112 type: "prefs.get", | 1134 type: "prefs.get", |
1113 key: "subscriptions_exceptionsurl_privacy" | 1135 key: "subscriptions_exceptionsurl_privacy" |
1114 }, | 1136 }, |
1115 (urlPrivacy) => | 1137 (urlPrivacy) => |
1116 { | 1138 { |
1117 acceptableAdsPrivacyUrl = urlPrivacy; | 1139 acceptableAdsPrivacyUrl = urlPrivacy; |
1118 | 1140 |
1119 // Load user subscriptions | 1141 // Load user subscriptions |
1120 chrome.runtime.sendMessage({ | 1142 browser.runtime.sendMessage({ |
1121 type: "subscriptions.get", | 1143 type: "subscriptions.get", |
1122 downloadable: true | 1144 downloadable: true |
1123 }, | 1145 }, |
1124 (subscriptions) => | 1146 (subscriptions) => |
1125 { | 1147 { |
1126 for (let subscription of subscriptions) | 1148 for (let subscription of subscriptions) |
1127 onSubscriptionMessage("added", subscription); | 1149 onSubscriptionMessage("added", subscription); |
1128 | 1150 |
1129 setAcceptableAds(); | 1151 setAcceptableAds(); |
1130 }); | 1152 }); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1168 | 1190 |
1169 let message = { | 1191 let message = { |
1170 type: messageType, | 1192 type: messageType, |
1171 url | 1193 url |
1172 }; | 1194 }; |
1173 if (title) | 1195 if (title) |
1174 message.title = title; | 1196 message.title = title; |
1175 if (homepage) | 1197 if (homepage) |
1176 message.homepage = homepage; | 1198 message.homepage = homepage; |
1177 | 1199 |
1178 chrome.runtime.sendMessage(message); | 1200 browser.runtime.sendMessage(message); |
1179 } | 1201 } |
1180 | 1202 |
1181 function onFilterMessage(action, filter) | 1203 function onFilterMessage(action, filter) |
1182 { | 1204 { |
1183 switch (action) | 1205 switch (action) |
1184 { | 1206 { |
1185 case "added": | 1207 case "added": |
1186 filter[timestampUI] = Date.now(); | 1208 filter[timestampUI] = Date.now(); |
1187 updateFilter(filter); | 1209 updateFilter(filter); |
1188 break; | 1210 break; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1279 { | 1301 { |
1280 let checkPref = getPref.checks[key] || getPref.checkNone; | 1302 let checkPref = getPref.checks[key] || getPref.checkNone; |
1281 checkPref((isActive) => | 1303 checkPref((isActive) => |
1282 { | 1304 { |
1283 if (!isActive) | 1305 if (!isActive) |
1284 { | 1306 { |
1285 hidePref(key, !isActive); | 1307 hidePref(key, !isActive); |
1286 return; | 1308 return; |
1287 } | 1309 } |
1288 | 1310 |
1289 chrome.runtime.sendMessage({ | 1311 browser.runtime.sendMessage({ |
1290 type: "prefs.get", | 1312 type: "prefs.get", |
1291 key | 1313 key |
1292 }, callback); | 1314 }, callback); |
1293 }); | 1315 }); |
1294 } | 1316 } |
1295 | 1317 |
1296 getPref.checkNone = function(callback) | 1318 getPref.checkNone = function(callback) |
1297 { | 1319 { |
1298 callback(true); | 1320 callback(true); |
1299 }; | 1321 }; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1373 break; | 1395 break; |
1374 case "prefs.respond": | 1396 case "prefs.respond": |
1375 onPrefMessage(message.action, message.args[0], false); | 1397 onPrefMessage(message.action, message.args[0], false); |
1376 break; | 1398 break; |
1377 case "subscriptions.respond": | 1399 case "subscriptions.respond": |
1378 onSubscriptionMessage(message.action, message.args[0]); | 1400 onSubscriptionMessage(message.action, message.args[0]); |
1379 break; | 1401 break; |
1380 } | 1402 } |
1381 }); | 1403 }); |
1382 | 1404 |
1383 chrome.runtime.sendMessage({ | 1405 browser.runtime.sendMessage({ |
1384 type: "app.listen", | 1406 type: "app.listen", |
1385 filter: ["addSubscription", "focusSection"] | 1407 filter: ["addSubscription", "focusSection"] |
1386 }); | 1408 }); |
1387 chrome.runtime.sendMessage({ | 1409 browser.runtime.sendMessage({ |
1388 type: "filters.listen", | 1410 type: "filters.listen", |
1389 filter: ["added", "loaded", "removed"] | 1411 filter: ["added", "loaded", "removed"] |
1390 }); | 1412 }); |
1391 chrome.runtime.sendMessage({ | 1413 browser.runtime.sendMessage({ |
1392 type: "prefs.listen", | 1414 type: "prefs.listen", |
1393 filter: ["notifications_ignoredcategories", "notifications_showui", | 1415 filter: ["notifications_ignoredcategories", "notifications_showui", |
1394 "show_devtools_panel", "shouldShowBlockElementMenu"] | 1416 "show_devtools_panel", "shouldShowBlockElementMenu"] |
1395 }); | 1417 }); |
1396 chrome.runtime.sendMessage({ | 1418 browser.runtime.sendMessage({ |
1397 type: "subscriptions.listen", | 1419 type: "subscriptions.listen", |
1398 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1420 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1399 "title", "downloadStatus", "downloading"] | 1421 "title", "downloadStatus", "downloading"] |
1400 }); | 1422 }); |
1401 | 1423 |
1402 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1424 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1403 window.addEventListener("hashchange", onHashChange, false); | 1425 window.addEventListener("hashchange", onHashChange, false); |
1404 } | 1426 } |
LEFT | RIGHT |