Mildom chat autoloder

It scroll Mildom's chat automatic.(ミルダムのチャットを自動でスクロール)

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Mildom chat autoloder
// @namespace    Mildom chat autoloder
// @version      0.3
// @description  It scroll Mildom's chat automatic.(ミルダムのチャットを自動でスクロール)
// @author       meguru
// @license      MIT
// @match        https://www.mildom.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let myEnv = {
        enableAutoReload: true,
        observer: undefined
    }

    setTimeout(function() {
        console.log('-------- start tamper ------------')

        function addObserver() {
            const config = {
                attributes: true,
                childList: true,
                subtree: true
            }
            const messageListContainer = document.getElementsByClassName('message-list-container')[0]
            myEnv.observer = new MutationObserver((mutations) => {
                if (messageListContainer.children[1]) {
                    messageListContainer.children[1].click();
                }
            })
            myEnv.observer.observe(messageListContainer, config)
        }

        function stopObserver() {
            myEnv.observer.disconnect()

        }

        const toolBar = document.getElementsByClassName('tool-bar')[0]
        if (!toolBar) {
            console.log('not found chat tool bar');
            return;
        }
        const autoReloadButton = document.createElement('div')
        autoReloadButton.textContent = "🌊"
        autoReloadButton.id = "myAutoReloadButton"
        autoReloadButton.onclick = () => {
            let el = document.getElementById('myAutoReloadButton')
            if (myEnv.enableAutoReload === true) {
                myEnv.enableAutoReload = false
                el.textContent = "❄"
                stopObserver()
            } else {
                myEnv.enableAutoReload = true
                el.textContent = "🌊"
                addObserver()
            }
        }
        toolBar.appendChild(autoReloadButton)
        addObserver()

        console.log('--------- end tamper -------------')
    }, 6000)

})();