JavaScript automatically comments on Bilibili videos

Code:

// ==UserScript==
// @name         自动评论哔哩哔哩视频
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://www.bilibili.com/*
// @grant        none
// ==/UserScript==
(function(){
    // 等待两秒钟再进行评论

    setTimeout(function(){
        var c=["陌生人好好的呦。","别看啦,照顾好自己","喧闹的世界,看到这条评论。洗洗睡吧吧!"];
        var n = -1;
        var m = 3;
        var temp_count = Math.floor(Math.random()*(n-m+1))+m;//取m-n之间的随机数 [m,n]
        //document.getElementsByClassName("tool-item-comment")[0].click();//能够打开评论区啦

        var time = new Date();
        var t = "    我在: " +time.getFullYear()+"年 "+(time.getMonth()+1)+"月 "+time.getDate()+"日   "+time.getHours()+":"+time.getMinutes()+":"+time.getSeconds()+"  来过!";
        //document.getElementById("comment_content").value = t//评论时间
        document.getElementsByClassName("ipt-txt")[0].value = c[temp_count] + t;//能够赋值啦
        document.getElementsByClassName("comment-submit")[0].click(); //发表评论成功!

},9999);//ajax do something
})();

result:

Published 625 original articles · praised 1697 · 1.21 million views

Guess you like

Origin blog.csdn.net/weixin_42859280/article/details/105612950