youtube直播自动评论机器人

youtube直播自动评论机器人 Auto live comment bot for youtube

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         youtube直播自动评论机器人
// @namespace    http://www.youtube.com/
// @version      0.4
// @description  youtube直播自动评论机器人 Auto live comment bot for youtube
// @author       lanxiuying
// @match        *.youtube.com/*
// @grant        none
// ==/UserScript==


//需要发送的评论
var contentArr = [];
contentArr.push('别吵了');
contentArr.push('love & peace');
//评论时间间隔(频道回复自带一分钟多的CD时间)
var intervalTime = 90 * 1000;
var timer = 0;
var cLength = contentArr.length;

window.inputValue = function (dom, st) {

    var evt = new InputEvent('input', {
        inputType: 'insertText',
        data: st,
        dataTransfer: null,
        isComposing: false
    });
    dom.innerHTML = st;
    dom.dispatchEvent(evt);
}

setInterval(function () {
    var cIndex = timer % cLength;
    var shtml = document.querySelectorAll("#input");
    var commentInput = shtml[1];
    if(commentInput){
        window.inputValue(commentInput, contentArr[cIndex]);
        commentInput.focus();
        commentInput.click();
        var buttons = document.querySelectorAll("#send-button");
        if (buttons && buttons.length > 0) {
            var button = buttons[0];
            var childNodes = button.childNodes;
            var childNode = childNodes[0];
            childNode.click();
            timer++;
        }
    }else{
        console.log("油猴脚本错误:");
        console.log(commentInput);
    }
}, intervalTime);