FANDOM


PrivateMessageAlert tells you when a private chat is updated (and you're not focused on the chat tab) by adding a blinking message to the tab name informing who messaged you.

Usage

Installation

  • For site-wide usage, add the code snippet below to your wiki's "MediaWiki:Chat.js" page.
  • For personal use, add the code below to your own chat.js page on any wiki.
importArticles({
    type: 'script',
    articles: [
        'u:dev:MediaWiki:PrivateMessageAlert/code.js',
    ]
});

Customization

All variables are stored in the PrivateMessageAlert object, which must be defined before the importArticles statement.

beepSound
This can be a string or an array of publicly available, valid mp3/ogg/wav files.
interval
The interval between the tab switching state between users, in milliseconds. Please don't set this to below 1000.
message
This overrides the translations for your own text to display on the title (and desktop notifications). It replaces $1 with the user who messaged you.
notifications
Boolean that defines if the script should display desktop notifications. It will still ask for permission to show them the first time you run the script, so it should be ok to have this set wiki-wide.
alertWhileFocused
By default, the script won't do anything if you're viewing the document. This changes it so you still get a notification if you're focused on the window.

Example:

var PrivateMessageAlert = {
    beepSound: 'https://soundbible.com/grab.php?id=1645&type=mp3',
//  beepSound: ['https://soundbible.com/grab.php?id=1645&type=mp3', 'https://soundbible.com/grab.php?id=1815&type=mp3'],
    message: '$1 sent you a message!',
    notifications: true,
    alertWhileFocused: true,
    interval: 2000
};