JavaScript實現自動評論嗶哩嗶哩視頻

代碼:

// ==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
})();

結果:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章