chat-logs

chat message!

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name chat-logs
// @namespace http://tampermonkey.net/
// @version 0.1.0
// @author Nei
// @description chat message!
// @match https://catwar.su/cw3/
// @license MIT
// ==/UserScript==




(function() {
    'use strict';

    var target = document.querySelector("#chat_msg");
    var infoPanel = document.querySelector("body");
    var InfoItem = document.createElement("div");
    InfoItem.textContent = "Произошло обновление в чате";
    InfoItem.style.display = "none";
    InfoItem.style.top = "0";
    InfoItem.style.height = "30px";
    InfoItem.style.background = "white";
    InfoItem.style.position = "sticky";
    InfoItem.style.fontSize = "16px";
    InfoItem.style.textAlign = "center";
    InfoItem.style.zIndex = "9";

    InfoItem.id = "chat-update";
    // infoPanel.appendChild(InfoItem);
    infoPanel.insertBefore(InfoItem, infoPanel.firstChild);


    const config = {
        childList: true,
    };

    const callback = function (mutationsList, observer) {
        for (let mutation of mutationsList) {
            if (mutation.type === "childList") {
                console.log("A child node has been added or removed.");
                document.querySelector("#chat-update").style.display = "block";
                setTimeout(() => document.querySelector("#chat-update").style.display = "none", 3000);
            }
        }
    };

    // Создаём экземпляр наблюдателя с указанной функцией колбэка
    const observer = new MutationObserver(callback);

    // Начинаем наблюдение за настроенными изменениями целевого элемента
    observer.observe(target, config);
})();