youtube直播自动评论机器人 Auto live comment bot for youtube
// ==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);