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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 "use strict"; | 18 "use strict"; |
19 | 19 |
20 (function() | 20 (function() |
21 { | 21 { |
22 var subscriptionsMap = Object.create(null); | 22 var subscriptionsMap = Object.create(null); |
23 var recommendationsMap = Object.create(null); | 23 var recommendationsMap = Object.create(null); |
24 var filtersMap = Object.create(null); | 24 var filtersMap = Object.create(null); |
25 var collections = Object.create(null); | 25 var collections = Object.create(null); |
26 var acceptableAdsUrl = null; | |
26 var maxLabelId = 0; | 27 var maxLabelId = 0; |
27 var getMessage = ext.i18n.getMessage; | 28 var getMessage = ext.i18n.getMessage; |
28 var filterErrors = | 29 var filterErrors = |
29 { | 30 { |
30 "synchronize_invalid_url": "options_filterList_lastDownload_invalidURL", | 31 "synchronize_invalid_url": "options_filterList_lastDownload_invalidURL", |
31 "synchronize_connection_error": "options_filterList_lastDownload_connectionE rror", | 32 "synchronize_connection_error": "options_filterList_lastDownload_connectionE rror", |
32 "synchronize_invalid_data": "options_filterList_lastDownload_invalidData", | 33 "synchronize_invalid_data": "options_filterList_lastDownload_invalidData", |
33 "synchronize_checksum_mismatch": "options_filterList_lastDownload_checksumMi smatch" | 34 "synchronize_checksum_mismatch": "options_filterList_lastDownload_checksumMi smatch" |
34 }; | 35 }; |
35 | 36 |
(...skipping 19 matching lines...) Expand all Loading... | |
55 | 56 |
56 Collection.prototype._createElementQuery = function(item) | 57 Collection.prototype._createElementQuery = function(item) |
57 { | 58 { |
58 var access = (item.url || item.text).replace(/'/g, "\\'"); | 59 var access = (item.url || item.text).replace(/'/g, "\\'"); |
59 return function(container) | 60 return function(container) |
60 { | 61 { |
61 return container.querySelector("[data-access='" + access + "']"); | 62 return container.querySelector("[data-access='" + access + "']"); |
62 }; | 63 }; |
63 }; | 64 }; |
64 | 65 |
66 Collection.prototype._getItemTitle = function(item, i) | |
67 { | |
68 var title = null; | |
69 if (this.details[i].useOriginalTitle) | |
70 title = item.originalTitle; | |
71 if (!title) | |
72 title = item.title || item.url || item.text; | |
73 return title; | |
74 }; | |
75 | |
65 Collection.prototype.addItems = function() | 76 Collection.prototype.addItems = function() |
66 { | 77 { |
67 var length = Array.prototype.push.apply(this.items, arguments); | 78 var length = Array.prototype.push.apply(this.items, arguments); |
68 if (length == 0) | 79 if (length == 0) |
69 return; | 80 return; |
70 | 81 |
71 this.items.sort(function(a, b) | 82 this.items.sort(function(a, b) |
72 { | 83 { |
73 var aValue = (a.title || a.text || a.url).toLowerCase(); | 84 // Make sure that Acceptable Ads is always last, since it cannot be |
74 var bValue = (b.title || b.text || b.url).toLowerCase(); | 85 // disabled, but only be removed. That way it's grouped together with |
75 return aValue.localeCompare(bValue); | 86 // the "Own filter list" which cannot be disabled either at the bottom |
76 }); | 87 // of the filter lists in the Advanced tab. |
88 if (a.url == acceptableAdsUrl) | |
89 return 1; | |
90 if (b.url == acceptableAdsUrl) | |
91 return -1; | |
92 | |
93 var aTitle = this._getItemTitle(a, 0).toLowerCase(); | |
94 var bTitle = this._getItemTitle(b, 0).toLowerCase(); | |
95 return aTitle.localeCompare(bTitle); | |
96 }.bind(this)); | |
77 | 97 |
78 for (var j = 0; j < this.details.length; j++) | 98 for (var j = 0; j < this.details.length; j++) |
79 { | 99 { |
80 var table = E(this.details[j].id); | 100 var table = E(this.details[j].id); |
81 var template = table.querySelector("template"); | 101 var template = table.querySelector("template"); |
82 for (var i = 0; i < arguments.length; i++) | 102 for (var i = 0; i < arguments.length; i++) |
83 { | 103 { |
84 var item = arguments[i]; | 104 var item = arguments[i]; |
85 var listItem = document.createElement("li"); | 105 var listItem = document.createElement("li"); |
86 listItem.appendChild(document.importNode(template.content, true)); | 106 listItem.appendChild(document.importNode(template.content, true)); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 Collection.prototype.updateItem = function(item) | 181 Collection.prototype.updateItem = function(item) |
162 { | 182 { |
163 var access = (item.url || item.text).replace(/'/g, "\\'"); | 183 var access = (item.url || item.text).replace(/'/g, "\\'"); |
164 for (var i = 0; i < this.details.length; i++) | 184 for (var i = 0; i < this.details.length; i++) |
165 { | 185 { |
166 var table = E(this.details[i].id); | 186 var table = E(this.details[i].id); |
167 var element = table.querySelector("[data-access='" + access + "']"); | 187 var element = table.querySelector("[data-access='" + access + "']"); |
168 if (!element) | 188 if (!element) |
169 continue; | 189 continue; |
170 | 190 |
171 var title = null; | 191 var title = this._getItemTitle(item, i); |
172 if (this.details[i].useOriginalTitle) | |
173 title = item.originalTitle; | |
174 if (!title) | |
175 title = item.title || item.url || item.text; | |
176 element.querySelector(".display").textContent = title; | 192 element.querySelector(".display").textContent = title; |
177 if (title) | 193 if (title) |
178 element.setAttribute("data-search", title.toLowerCase()); | 194 element.setAttribute("data-search", title.toLowerCase()); |
179 var control = element.querySelector(".control[role='checkbox']"); | 195 var control = element.querySelector(".control[role='checkbox']"); |
180 if (control) | 196 if (control) |
181 { | 197 { |
182 control.setAttribute("aria-checked", item.disabled == false); | 198 control.setAttribute("aria-checked", item.disabled == false); |
183 if (item.disableable == false && | 199 if (item.url == acceptableAdsUrl && this.details[i].onClick == |
184 this.details[i].onClick == toggleDisableSubscription) | 200 toggleDisableSubscription) |
185 control.setAttribute("disabled", true); | 201 control.setAttribute("disabled", true); |
186 } | 202 } |
187 | 203 |
188 var downloadStatus = item.downloadStatus; | |
189 var dateElement = element.querySelector(".date"); | 204 var dateElement = element.querySelector(".date"); |
190 var timeElement = element.querySelector(".time"); | 205 var timeElement = element.querySelector(".time"); |
191 if(dateElement && timeElement) | 206 if (dateElement && timeElement) |
192 { | 207 { |
193 var message = element.querySelector(".message"); | 208 var message = element.querySelector(".message"); |
194 ext.backgroundPage.sendMessage( | 209 if (item.isDownloading) |
195 { | 210 { |
196 type: "subscriptions.isDownloading", | 211 var text = getMessage("options_filterList_lastDownload_inProgress"); |
197 url: item.url | 212 message.textContent = text; |
198 }, | 213 element.classList.add("show-message"); |
199 function(isDownloading) | 214 } |
200 { | 215 else if (item.downloadStatus != "synchronize_ok") |
201 if (isDownloading) | 216 { |
202 { | 217 var error = filterErrors[item.downloadStatus]; |
203 var text = getMessage("options_filterList_lastDownload_inProgress"); | 218 if (error) |
204 message.textContent = text; | 219 message.textContent = getMessage(error); |
205 element.classList.add("show-message"); | 220 else |
206 } | 221 message.textContent = item.downloadStatus; |
207 else if (downloadStatus && downloadStatus != "synchronize_ok") | 222 element.classList.add("show-message"); |
208 { | 223 } |
209 if (downloadStatus in filterErrors) | 224 else if (item.lastDownload > 0) |
210 message.textContent = getMessage(filterErrors[downloadStatus]); | 225 { |
211 else | 226 var dateTime = i18n_formatDateTime(item.lastDownload * 1000); |
212 message.textContent = item.downloadStatus; | 227 dateElement.textContent = dateTime[0]; |
213 element.classList.add("show-message"); | 228 timeElement.textContent = dateTime[1]; |
214 } | 229 element.classList.remove("show-message"); |
215 else if (item.lastDownload > 0) | 230 } |
216 { | 231 } |
217 var dateTime = i18n_formatDateTime(item.lastDownload * 1000); | 232 |
218 dateElement.textContent = dateTime[0]; | |
219 timeElement.textContent = dateTime[1]; | |
220 element.classList.remove("show-message"); | |
221 } | |
222 }); | |
223 } | |
224 var websiteElement = element.querySelector(".context-menu .website"); | 233 var websiteElement = element.querySelector(".context-menu .website"); |
225 var sourceElement = element.querySelector(".context-menu .source"); | 234 var sourceElement = element.querySelector(".context-menu .source"); |
226 if (websiteElement && item.homepage) | 235 if (websiteElement && item.homepage) |
227 websiteElement.setAttribute("href", item.homepage); | 236 websiteElement.setAttribute("href", item.homepage); |
228 if (sourceElement) | 237 if (sourceElement) |
229 sourceElement.setAttribute("href", item.url); | 238 sourceElement.setAttribute("href", item.url); |
230 } | 239 } |
231 }; | 240 }; |
232 | 241 |
233 Collection.prototype.clearAll = function() | 242 Collection.prototype.clearAll = function() |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 collections.allLangs.removeItem(subscription); | 397 collections.allLangs.removeItem(subscription); |
389 collections.langs.addItems(subscription); | 398 collections.langs.addItems(subscription); |
390 } | 399 } |
391 else | 400 else |
392 { | 401 { |
393 collections.allLangs.addItems(subscription); | 402 collections.allLangs.addItems(subscription); |
394 collections.langs.removeItem(subscription); | 403 collections.langs.removeItem(subscription); |
395 } | 404 } |
396 } | 405 } |
397 } | 406 } |
398 for (var i in collections) | 407 } |
399 collections[i].updateItem(subscription); | 408 |
400 } | 409 for (var name in collections) |
410 collections[name].updateItem(subscription); | |
401 } | 411 } |
402 | 412 |
403 if (!Object.observe) | 413 if (!Object.observe) |
404 { | 414 { |
405 ["disabled", "lastDownload"].forEach(function(property) | 415 Object.keys(subscription).forEach(function(property) |
406 { | 416 { |
407 subscription["$" + property] = subscription[property]; | 417 var value = subscription[property]; |
408 Object.defineProperty(subscription, property, | 418 Object.defineProperty(subscription, property, |
409 { | 419 { |
410 get: function() | 420 get: function() |
411 { | 421 { |
412 return this["$" + property]; | 422 return value; |
413 }, | 423 }, |
414 set: function(newValue) | 424 set: function(newValue) |
415 { | 425 { |
416 var oldValue = this["$" + property]; | 426 if (value != newValue) |
417 if (oldValue != newValue) | |
418 { | 427 { |
419 this["$" + property] = newValue; | 428 value = newValue; |
420 var change = Object.create(null); | 429 onObjectChanged([{name: property}]); |
421 change.name = property; | |
422 onObjectChanged([change]); | |
423 } | 430 } |
424 } | 431 } |
425 }); | 432 }); |
426 }); | 433 }); |
427 } | 434 } |
428 else | 435 else |
429 { | 436 { |
430 Object.observe(subscription, onObjectChanged); | 437 Object.observe(subscription, onObjectChanged); |
431 } | 438 } |
432 } | 439 } |
433 | 440 |
434 function updateSubscription(subscription) | 441 function updateSubscription(subscription) |
435 { | 442 { |
436 var subscriptionUrl = subscription.url; | 443 var subscriptionUrl = subscription.url; |
437 var knownSubscription = subscriptionsMap[subscriptionUrl]; | 444 var knownSubscription = subscriptionsMap[subscriptionUrl]; |
438 if (knownSubscription) | 445 if (knownSubscription) |
439 { | 446 { |
440 for (var property in subscription) | 447 for (var property in subscription) |
441 if (property != "title") | 448 { |
449 if (property == "title" && subscriptionUrl in recommendationsMap) | |
450 knownSubscription.originalTitle = subscription.title; | |
451 else | |
442 knownSubscription[property] = subscription[property]; | 452 knownSubscription[property] = subscription[property]; |
453 } | |
443 } | 454 } |
444 else | 455 else |
445 { | 456 { |
446 observeSubscription(subscription); | 457 observeSubscription(subscription); |
447 getAcceptableAdsURL(function(acceptableAdsUrl) | 458 |
448 { | 459 var collection; |
449 var collection = null; | 460 if (subscriptionUrl in recommendationsMap) |
450 if (subscriptionUrl in recommendationsMap) | 461 { |
451 { | 462 var recommendation = recommendationsMap[subscriptionUrl]; |
452 var recommendation = recommendationsMap[subscriptionUrl]; | 463 if (recommendation.type != "ads") |
453 if (recommendation.type != "ads") | 464 collection = collections.popular; |
454 collection = collections.popular; | 465 else if (subscription.disabled == false) |
455 else if (subscription.disabled == false) | 466 collection = collections.langs; |
456 collection = collections.langs; | |
457 else | |
458 collection = collections.allLangs; | |
459 } | |
460 else if (subscriptionUrl == acceptableAdsUrl) | |
461 { | |
462 collection = collections.acceptableAds; | |
463 subscription.disableable = false; | |
464 } | |
465 else | 467 else |
466 collection = collections.custom; | 468 collection = collections.allLangs; |
467 | 469 } |
468 collection.addItems(subscription); | 470 else if (subscriptionUrl == acceptableAdsUrl) |
469 subscriptionsMap[subscriptionUrl] = subscription; | 471 collection = collections.acceptableAds; |
470 }); | 472 else |
473 collection = collections.custom; | |
474 | |
475 collection.addItems(subscription); | |
476 subscriptionsMap[subscriptionUrl] = subscription; | |
471 } | 477 } |
472 } | 478 } |
473 | 479 |
474 function updateFilter(filter) | 480 function updateFilter(filter) |
475 { | 481 { |
476 var match = filter.text.match(/^@@\|\|([^\/:]+)\^\$document$/); | 482 var match = filter.text.match(/^@@\|\|([^\/:]+)\^\$document$/); |
477 if (match && !filtersMap[filter.text]) | 483 if (match && !filtersMap[filter.text]) |
478 { | 484 { |
479 filter.title = match[1]; | 485 filter.title = match[1]; |
480 collections.whitelist.addItems(filter); | 486 collections.whitelist.addItems(filter); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
849 subscriptionUrl: subscriptions[i].url | 855 subscriptionUrl: subscriptions[i].url |
850 }, | 856 }, |
851 function(filters) | 857 function(filters) |
852 { | 858 { |
853 for (var i = 0; i < filters.length; i++) | 859 for (var i = 0; i < filters.length; i++) |
854 updateFilter(filters[i]); | 860 updateFilter(filters[i]); |
855 }); | 861 }); |
856 } | 862 } |
857 }); | 863 }); |
858 loadRecommendations(); | 864 loadRecommendations(); |
859 getAcceptableAdsURL(function(acceptableAdsUrl) | 865 ext.backgroundPage.sendMessage( |
860 { | 866 { |
861 var subscription = Object.create(null); | 867 type: "prefs.get", |
862 subscription.url = acceptableAdsUrl; | 868 key: "subscriptions_exceptionsurl" |
863 subscription.disabled = true; | 869 }, |
864 subscription.title = getMessage("options_acceptableAds_description"); | 870 function(url) |
865 updateSubscription(subscription); | 871 { |
872 acceptableAdsUrl = url; | |
873 updateSubscription({ | |
874 url: acceptableAdsUrl, | |
875 disabled: true, | |
876 title: getMessage("options_acceptableAds_description") | |
877 }); | |
866 | 878 |
867 // Load user subscriptions | 879 // Load user subscriptions |
868 ext.backgroundPage.sendMessage( | 880 ext.backgroundPage.sendMessage( |
869 { | 881 { |
870 type: "subscriptions.get", | 882 type: "subscriptions.get", |
871 downloadable: true | 883 downloadable: true |
872 }, | 884 }, |
873 function(subscriptions) | 885 function(subscriptions) |
874 { | 886 { |
875 for (var i = 0; i < subscriptions.length; i++) | 887 for (var i = 0; i < subscriptions.length; i++) |
(...skipping 18 matching lines...) Expand all Loading... | |
894 document.querySelector("#whitelisting .controls").classList.remove("mode-edi t"); | 906 document.querySelector("#whitelisting .controls").classList.remove("mode-edi t"); |
895 } | 907 } |
896 | 908 |
897 function editCustomFilters() | 909 function editCustomFilters() |
898 { | 910 { |
899 var customFilterItems = collections.customFilters.items; | 911 var customFilterItems = collections.customFilters.items; |
900 var filterTexts = []; | 912 var filterTexts = []; |
901 for (var i = 0; i < customFilterItems.length; i++) | 913 for (var i = 0; i < customFilterItems.length; i++) |
902 filterTexts.push(customFilterItems[i].text); | 914 filterTexts.push(customFilterItems[i].text); |
903 E("custom-filters-raw").value = filterTexts.join("\n"); | 915 E("custom-filters-raw").value = filterTexts.join("\n"); |
904 } | |
905 | |
906 function getAcceptableAdsURL(callback) | |
907 { | |
908 getPref("subscriptions_exceptionsurl", callback); | |
Sebastian Noack
2016/04/01 15:41:56
Unrelated, but I couldn't resits. WTF?
Sebastian Noack
2016/04/06 17:15:41
Ahh, now I understand. The old code impelemted som
Thomas Greiner
2016/04/07 17:21:15
Yeah, the idea here was to avoid messaging the bac
Sebastian Noack
2016/04/08 14:22:16
Well, a promise still requires a callback. Caching
| |
909 } | 916 } |
910 | 917 |
911 function addEnableSubscription(url, title, homepage) | 918 function addEnableSubscription(url, title, homepage) |
912 { | 919 { |
913 var messageType = null; | 920 var messageType = null; |
914 var knownSubscription = subscriptionsMap[url]; | 921 var knownSubscription = subscriptionsMap[url]; |
915 if (knownSubscription && knownSubscription.disabled == true) | 922 if (knownSubscription && knownSubscription.disabled == true) |
916 messageType = "subscriptions.toggle" | 923 messageType = "subscriptions.toggle" |
917 else | 924 else |
918 messageType = "subscriptions.add" | 925 messageType = "subscriptions.add" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
961 var knownSubscription = subscriptionsMap[subscription.url]; | 968 var knownSubscription = subscriptionsMap[subscription.url]; |
962 if (knownSubscription) | 969 if (knownSubscription) |
963 collections.filterLists.addItems(knownSubscription); | 970 collections.filterLists.addItems(knownSubscription); |
964 else | 971 else |
965 collections.filterLists.addItems(subscription); | 972 collections.filterLists.addItems(subscription); |
966 break; | 973 break; |
967 case "disabled": | 974 case "disabled": |
968 updateSubscription(subscription); | 975 updateSubscription(subscription); |
969 updateShareLink(); | 976 updateShareLink(); |
970 break; | 977 break; |
971 case "lastDownload": | |
972 updateSubscription(subscription); | |
973 break; | |
974 case "homepage": | |
975 // TODO: NYI | |
976 break; | |
977 case "removed": | 978 case "removed": |
978 var knownSubscription = subscriptionsMap[subscription.url]; | 979 var knownSubscription = subscriptionsMap[subscription.url]; |
979 getAcceptableAdsURL(function(acceptableAdsUrl) | 980 if (subscription.url == acceptableAdsUrl) |
980 { | 981 { |
981 if (subscription.url == acceptableAdsUrl) | 982 subscription.disabled = true; |
982 { | 983 updateSubscription(subscription); |
983 subscription.disabled = true; | 984 } |
984 updateSubscription(subscription); | 985 else |
986 { | |
987 if (subscription.url in recommendationsMap) | |
988 knownSubscription.disabled = true; | |
989 else | |
990 { | |
991 collections.custom.removeItem(knownSubscription); | |
992 delete subscriptionsMap[subscription.url]; | |
985 } | 993 } |
986 else | 994 } |
987 { | 995 updateShareLink(); |
988 if (subscription.url in recommendationsMap) | 996 collections.filterLists.removeItem(knownSubscription); |
989 knownSubscription.disabled = true; | 997 break; |
990 else | 998 default: |
991 { | 999 updateSubscription(subscription); |
992 collections.custom.removeItem(knownSubscription); | |
993 delete subscriptionsMap[subscription.url]; | |
994 } | |
995 } | |
996 updateShareLink(); | |
997 collections.filterLists.removeItem(knownSubscription); | |
998 }); | |
999 break; | |
1000 case "title": | |
1001 // TODO: NYI | |
1002 break; | 1000 break; |
1003 } | 1001 } |
1004 } | 1002 } |
1005 | 1003 |
1006 function hidePref(key, value) | 1004 function hidePref(key, value) |
1007 { | 1005 { |
1008 var element = document.querySelector("[data-pref='" + key + "']"); | 1006 var element = document.querySelector("[data-pref='" + key + "']"); |
1009 if (element) | 1007 if (element) |
1010 element.setAttribute("aria-hidden", value); | 1008 element.setAttribute("aria-hidden", value); |
1011 } | 1009 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1103 | 1101 |
1104 for (var i = 0; i < shareResources.length; i++) | 1102 for (var i = 0; i < shareResources.length; i++) |
1105 checkShareResource(shareResources[i], onResult); | 1103 checkShareResource(shareResources[i], onResult); |
1106 } | 1104 } |
1107 | 1105 |
1108 ext.onMessage.addListener(function(message) | 1106 ext.onMessage.addListener(function(message) |
1109 { | 1107 { |
1110 switch (message.type) | 1108 switch (message.type) |
1111 { | 1109 { |
1112 case "app.respond": | 1110 case "app.respond": |
1113 if (message.action == "addSubscription") | 1111 switch (message.action) |
1114 { | 1112 { |
1115 var subscription = message.args[0]; | 1113 case "addSubscription": |
1116 var dialog = E("dialog-content-predefined"); | 1114 var subscription = message.args[0]; |
1117 dialog.querySelector("h3").textContent = subscription.title || ""; | 1115 var dialog = E("dialog-content-predefined"); |
1118 dialog.querySelector(".url").textContent = subscription.url; | 1116 dialog.querySelector("h3").textContent = subscription.title || ""; |
1119 openDialog("predefined"); | 1117 dialog.querySelector(".url").textContent = subscription.url; |
1118 openDialog("predefined"); | |
1119 break; | |
1120 case "focusSection": | |
1121 document.body.setAttribute("data-tab", message.args[0]); | |
1122 break; | |
1120 } | 1123 } |
1121 break; | 1124 break; |
1122 case "filters.respond": | 1125 case "filters.respond": |
1123 onFilterMessage(message.action, message.args[0]); | 1126 onFilterMessage(message.action, message.args[0]); |
1124 break; | 1127 break; |
1125 case "prefs.respond": | 1128 case "prefs.respond": |
1126 onPrefMessage(message.action, message.args[0], false); | 1129 onPrefMessage(message.action, message.args[0], false); |
1127 break; | 1130 break; |
1128 case "subscriptions.respond": | 1131 case "subscriptions.respond": |
1129 onSubscriptionMessage(message.action, message.args[0]); | 1132 onSubscriptionMessage(message.action, message.args[0]); |
1130 break; | 1133 break; |
1131 } | 1134 } |
1132 }); | 1135 }); |
1133 | 1136 |
1134 ext.backgroundPage.sendMessage( | 1137 ext.backgroundPage.sendMessage( |
1135 { | 1138 { |
1136 type: "app.listen", | 1139 type: "app.listen", |
1137 filter: ["addSubscription"] | 1140 filter: ["addSubscription", "focusSection"] |
1138 }); | 1141 }); |
1139 ext.backgroundPage.sendMessage( | 1142 ext.backgroundPage.sendMessage( |
1140 { | 1143 { |
1141 type: "filters.listen", | 1144 type: "filters.listen", |
1142 filter: ["added", "loaded", "removed"] | 1145 filter: ["added", "loaded", "removed"] |
1143 }); | 1146 }); |
1144 ext.backgroundPage.sendMessage( | 1147 ext.backgroundPage.sendMessage( |
1145 { | 1148 { |
1146 type: "prefs.listen", | 1149 type: "prefs.listen", |
1147 filter: ["notifications_ignoredcategories", "notifications_showui", | 1150 filter: ["notifications_ignoredcategories", "notifications_showui", |
1148 "safari_contentblocker", "show_devtools_panel", | 1151 "safari_contentblocker", "show_devtools_panel", |
1149 "shouldShowBlockElementMenu"] | 1152 "shouldShowBlockElementMenu"] |
1150 }); | 1153 }); |
1151 ext.backgroundPage.sendMessage( | 1154 ext.backgroundPage.sendMessage( |
1152 { | 1155 { |
1153 type: "subscriptions.listen", | 1156 type: "subscriptions.listen", |
1154 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1157 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1155 "title"] | 1158 "title", "downloadStatus", "downloading"] |
1156 }); | 1159 }); |
1157 | 1160 |
1158 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1161 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1159 })(); | 1162 })(); |
LEFT | RIGHT |