自动点名机器人 - acfun.cn

掌门带点名机器人1.0版本

目前為 2021-12-04 提交的版本,檢視 最新版本

// ==UserScript==
// @name         自动点名机器人 - acfun.cn
// @namespace    http://tampermonkey.net/
// @version      0.12
// @description  掌门带点名机器人1.0版本
// @author       You
// @match        https://live.acfun.cn/live/34905158
// @icon         https://www.google.com/s2/favicons?domain=acfun.cn
// @grant        none
// @license      https://live.acfun.cn/live/34905158
// ==/UserScript==

setTimeout(() => {
    var like = function() {
        document.getElementsByClassName('like-btn')[0].click();
    };
    window.setInterval(like, 1000 * 2);
    like();
    window.inputValue = function (dom, st) {
        var evt = new InputEvent('input', {
            inputType: 'insertText',
            data: st,
            dataTransfer: null,
            isComposing: false
        });
        dom.value = st;
        dom.dispatchEvent(evt);
        }


        var targetNode = document.getElementsByClassName("live-feed-messages")[0]
        // 观察者的选项(要观察哪些突变)
        var config = { attributes: true, childList: true, subtree: true };
        var comments=["我来了我来了","我还在","在这在这","我来了","我回来了","不在","1111","????"]
        // 当观察到突变时执行的回调函数

        var callback = function (mutationsList, observer) {
            // Use traditional 'for loops' for IE 11
            console.log(mutationsList);
            console.log(observer);
            mutationsList.forEach(function (item, index) {
                var className = item["addedNodes"][index]["className"]
                if (className == "comment") {
                    console.log(item);
                    var message = item["addedNodes"][index]["innerText"].split(":")[1]

                    if (message.search("来|到|在|这") != -1&&comments.indexOf(message)!=-1) {
                        // document.getElementsByClassName('danmaku-input')[1].value=comments[Math.floor(Math.random() * comments.length)]
                        window.inputValue(document.getElementsByClassName('danmaku-input')[1],comments[Math.floor(Math.random() * comments.length)])
                        //document.getElementsByClassName('send-btn')[1].setAttribute("class","send-btn enable")
                        document.getElementsByClassName('send-btn enable')[0].click();
                    }
                }
            })
        };


        // 创建一个链接到回调函数的观察者实例
        var observer = new MutationObserver(callback);

        // 开始观察已配置突变的目标节点
        observer.observe(targetNode, config);
}, 3000);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址