Table of Contents Previous entry (api:GM_log) Next entry (api:GM_openInTab)
GM_notification allows users to display notifications on the screen, using a provided message and other optional parameters.
The function takes several parameters. Either a details object or multiple parameters.
The details object can have the following attributes, from which some can also be used as direct parameter.
The available options include:
GM_notification again and using the same tag. If you don't provide a tag, a new notification will be created every time.event.preventDefault() in the onclick event handler.The function does not return a value.
If no url and no tag is provided the notification will closed when the userscript unloads v5.0+(e.g. when the page is reloaded or the tab is closed).
Here is an example of how the function might be used:
GM_notification({
text: "This is the notification message.",
title: "Notification Title",
url: 'https:/example.com/',
onclick: (event) => {
// The userscript is still running, so don't open example.com
event.preventDefault();
// Display an alert message instead
alert('I was clicked!')
}
});
const clicked = await GM.notification({ text: "Click me." });