hwm_chat_informer

Оповещение о новых сообщениях чата

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name           hwm_chat_informer
// @namespace      https://greasyfork.org/ru/users/170936
// @description    Оповещение о новых сообщениях чата
// @author         Kleshnerukij
// @version        1.2.1
// @include        https://www.heroeswm.ru/chat2020.php
// @include        https://www.lordswm.com/chat2020.php
// @include        http://178.248.235.15/chat2020.php
// ==/UserScript==

(function() {
var aud = new Audio();
aud.preload = 'auto';
aud.src = 'https://sound-pack.net/download/Sound_17211.mp3';

var msg_container = document.getElementById("chat_messages_container");
var new_child;
var new_id;
var name_author = '';
var your_name = 'RS51';
var room = document.getElementById("newroom");
var last_room;

var room_arr = new Array();

setInterval(function () {
    new_child = msg_container.lastChild;
    new_id = new_child.id;

    if (room_arr[room.value] == undefined) {
        room_arr[room.value] = new_id;
    }

    if (document.getElementById(new_id).getElementsByClassName("chat_name")[0] !== undefined) {
        name_author = document.getElementById(new_id).getElementsByClassName("chat_name")[0].innerHTML;
    }

    if (new_id > room_arr[room.value] && name_author !== your_name) {
        if (last_room == room.value) {
            aud.play();
            alert("");
        }
        room_arr[room.value] = new_id;
    }

    last_room = room.value;
}, 1000);
})();