Change the timeout for notifications in the firefox extension

I use the notification function from the firefox SDK to create Firefox extensions. the problem is that after the notification is displayed, it disappears too quickly, is there a way to change the notification timeout? this is the code i use:

notifications.notify({ title: "notification title", text: " notification text ", data: List[i] , onClick: function (data) { tabs.open(data); } }); 
+5
source share
2 answers

Unable to control animation. @canuckistani has half the right: both the SDK notifications and HTML5 notifications use the same basic service, nsIAlertsService . This service does not allow you to control the duration.

Desktop Firefox does not use services at the system level, with the exception of the implementation of Metro (still officially released and does not support add-ons in any case IIRC). Instead, they use an implementation of the XUL alert service, which is just a few XULs with some Javascript and some extra CSS . And some code to open a window .

Depending on any prefix, either a hard-coded 4000 ms timeout via setTimeout or a 4S CSS animation will be used.

While this is not convenient, in particular, not in the SDK add-in, where you do not receive a chrome package to open your own XUL windows, you can copy / paste implement your own XUL window plug with controls for a while, or even override Firefox by default. I can’t remember this name right now, but I know that there is or was at least one add-on that does just that, overriding the built-in implementation and allowing the user to choose an individual timeout, among other things.

+1
source

The high-level SDK api cannot control how quickly notifications are deleted:

https://addons.mozilla.org/en-US/developers/docs/sdk/latest/modules/sdk/notifications.html

This implementation in Firefox 22+ is based on the basic HTML5 api notifications, and in Firefox and Safari, in particular, the implementations seem to make it difficult to close the time that passes before the notification closes:

https://developer.mozilla.org/en-US/docs/WebAPI/Using_Web_Notifications#Creating_a_notification

0
source

Source: https://habr.com/ru/post/979195/


All Articles