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 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 title, | 201 title, |
202 iconUrl, | 202 iconUrl, |
203 message, | 203 message, |
204 buttons: activeButtons.map(button => ({title: button.title})), | 204 buttons: activeButtons.map(button => ({title: button.title})), |
205 // We use the highest priority to prevent the notification | 205 // We use the highest priority to prevent the notification |
206 // from closing automatically. | 206 // from closing automatically. |
207 priority: 2 | 207 priority: 2 |
208 }; | 208 }; |
209 browser.notifications.create("", notificationOptions, () => | 209 browser.notifications.create("", notificationOptions, () => |
210 { | 210 { |
211 // Opera does not support the addtition of buttons to notifications. | 211 // Opera does not support the addtition of buttons to notifications. |
Sebastian Noack
2017/11/01 18:45:03
Typo: addtition
| |
212 // Question type notfications always include buttons. | 212 // Question type notfications always include buttons. |
213 if (browser.runtime.lastError) | 213 if (browser.runtime.lastError && activeNotification.type != "question") |
214 { | 214 { |
215 if (activeNotification.type != "question") | 215 delete notificationOptions.buttons; |
Sebastian Noack
2017/10/30 22:46:43
You can just check both conditions in the same if-
Jon Sonesen
2017/11/01 18:21:44
Done.
| |
216 { | 216 browser.notifications.create("", notificationOptions); |
217 delete notificationOptions.buttons; | |
218 browser.notifications.create("", notificationOptions); | |
219 } | |
220 } | 217 } |
221 }); | 218 }); |
222 } | 219 } |
223 else if ("Notification" in window && activeNotification.type != "question") | 220 else if ("Notification" in window && activeNotification.type != "question") |
224 { | 221 { |
225 if (linkCount > 0) | 222 if (linkCount > 0) |
226 { | 223 { |
227 message += " " + browser.i18n.getMessage( | 224 message += " " + browser.i18n.getMessage( |
228 "notification_without_buttons" | 225 "notification_without_buttons" |
229 ); | 226 ); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 let methods = displayMethods[notificationType] || defaultDisplayMethods; | 293 let methods = displayMethods[notificationType] || defaultDisplayMethods; |
297 return methods.includes(method); | 294 return methods.includes(method); |
298 }; | 295 }; |
299 | 296 |
300 ext.pages.onLoading.addListener(page => | 297 ext.pages.onLoading.addListener(page => |
301 { | 298 { |
302 NotificationStorage.showNext(stringifyURL(page.url)); | 299 NotificationStorage.showNext(stringifyURL(page.url)); |
303 }); | 300 }); |
304 | 301 |
305 NotificationStorage.addShowListener(showNotification); | 302 NotificationStorage.addShowListener(showNotification); |
LEFT | RIGHT |