hwm_chat_informer

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

  1. // ==UserScript==
  2. // @name hwm_chat_informer
  3. // @namespace https://greasyfork.org/ru/users/170936
  4. // @description Оповещение о новых сообщениях чата
  5. // @author Kleshnerukij
  6. // @version 1.2.1
  7. // @include https://www.heroeswm.ru/chat2020.php
  8. // @include https://www.lordswm.com/chat2020.php
  9. // @include http://178.248.235.15/chat2020.php
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. var aud = new Audio();
  14. aud.preload = 'auto';
  15. aud.src = 'https://sound-pack.net/download/Sound_17211.mp3';
  16.  
  17. var msg_container = document.getElementById("chat_messages_container");
  18. var new_child;
  19. var new_id;
  20. var name_author = '';
  21. var your_name = 'RS51';
  22. var room = document.getElementById("newroom");
  23. var last_room;
  24.  
  25. var room_arr = new Array();
  26.  
  27. setInterval(function () {
  28. new_child = msg_container.lastChild;
  29. new_id = new_child.id;
  30.  
  31. if (room_arr[room.value] == undefined) {
  32. room_arr[room.value] = new_id;
  33. }
  34.  
  35. if (document.getElementById(new_id).getElementsByClassName("chat_name")[0] !== undefined) {
  36. name_author = document.getElementById(new_id).getElementsByClassName("chat_name")[0].innerHTML;
  37. }
  38.  
  39. if (new_id > room_arr[room.value] && name_author !== your_name) {
  40. if (last_room == room.value) {
  41. aud.play();
  42. alert("");
  43. }
  44. room_arr[room.value] = new_id;
  45. }
  46.  
  47. last_room = room.value;
  48. }, 1000);
  49. })();