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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 return null; | 57 return null; |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 var AdblockPlusApi = | 61 var AdblockPlusApi = |
62 { | 62 { |
63 get filtersLoaded() | 63 get filtersLoaded() |
64 { | 64 { |
65 return !FilterStorage._loading; | 65 return !FilterStorage._loading; |
66 }, | 66 }, |
| 67 get adblockPlusEnabled() |
| 68 { |
| 69 return Prefs.enabled; |
| 70 }, |
| 71 set adblockPlusEnabled(adblockPlusEnabled) |
| 72 { |
| 73 Prefs.enabled = adblockPlusEnabled |
| 74 }, |
67 get acceptableAdsEnabled() | 75 get acceptableAdsEnabled() |
68 { | 76 { |
69 return FilterStorage.subscriptions.some( | 77 return FilterStorage.subscriptions.some( |
70 (subscription) => subscription.url == Prefs.subscriptions_exceptionsurl); | 78 (subscription) => subscription.url == Prefs.subscriptions_exceptionsurl); |
71 }, | 79 }, |
72 set acceptableAdsEnabled(acceptableAdsEnabled) | 80 set acceptableAdsEnabled(acceptableAdsEnabled) |
73 { | 81 { |
74 if (acceptableAdsEnabled != AdblockPlusApi.acceptableAdsEnabled) | 82 if (acceptableAdsEnabled != AdblockPlusApi.acceptableAdsEnabled) |
75 UI.toggleAcceptableAds(); | 83 UI.toggleAcceptableAds(); |
76 }, | 84 }, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 return {"success": false, "error": "malformed request"}; | 176 return {"success": false, "error": "malformed request"}; |
169 | 177 |
170 if (data["action"] == "getFiltersLoaded") | 178 if (data["action"] == "getFiltersLoaded") |
171 return {"success": true, "value": this.filtersLoaded}; | 179 return {"success": true, "value": this.filtersLoaded}; |
172 | 180 |
173 if (!this.filtersLoaded) | 181 if (!this.filtersLoaded) |
174 return {"success": false, "error": "filters not loaded"}; | 182 return {"success": false, "error": "filters not loaded"}; |
175 | 183 |
176 switch (data["action"]) | 184 switch (data["action"]) |
177 { | 185 { |
| 186 case "getAdblockPlusEnabled": |
| 187 return {"success": true, "value": this.adblockPlusEnabled}; |
| 188 case "setAdblockPlusEnabled": |
| 189 if ("enable" in data) |
| 190 { |
| 191 this.adblockPlusEnabled = !!data["enable"]; |
| 192 return {"success": true}; |
| 193 } |
| 194 break; |
178 case "getAcceptableAdsEnabled": | 195 case "getAcceptableAdsEnabled": |
179 return {"success": true, "value": this.acceptableAdsEnabled}; | 196 return {"success": true, "value": this.acceptableAdsEnabled}; |
180 case "setAcceptableAdsEnabled": | 197 case "setAcceptableAdsEnabled": |
181 if ("enable" in data) | 198 if ("enable" in data) |
182 { | 199 { |
183 this.acceptableAdsEnabled = !!data["enable"]; | 200 this.acceptableAdsEnabled = !!data["enable"]; |
184 return {"success": true}; | 201 return {"success": true}; |
185 } | 202 } |
186 break; | 203 break; |
187 case "getSubscriptionsXml": | 204 case "getSubscriptionsXml": |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 { | 241 { |
225 this.whitelistSite(data["url"], data["whitelisted"]); | 242 this.whitelistSite(data["url"], data["whitelisted"]); |
226 return {"success": true}; | 243 return {"success": true}; |
227 } | 244 } |
228 break; | 245 break; |
229 } | 246 } |
230 return {"success": false, "error": "malformed request"}; | 247 return {"success": false, "error": "malformed request"}; |
231 }).bind(this), "AdblockPlus:Api"); | 248 }).bind(this), "AdblockPlus:Api"); |
232 } | 249 } |
233 }; | 250 }; |
OLD | NEW |