JavaScript自动评论,记下你看博客的时间

参考:https://www.w3school.com.cn/js/js_date_methods.asp

 

代码:

// ==UserScript==
// @name         自动评论旧版本CSDN
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://blog.csdn.net/*
// @grant        none
// ==/UserScript==
(function() {
    // 等待两秒钟再进行评论
    setTimeout(function(){

        var c=["本条消息自动评论。","别看啦,程序自己写的评论","喧闹的世界,收下这条来自机器的评论吧!","花不凋零,水不流!","890"];
        var n = -1;
        var m = 5;
        var temp_count = Math.floor(Math.random()*(n-m+1))+m;//取m-n之间的随机数 [m,n]

                document.getElementsByClassName("btn-comments")[1].click();//能够滑到旧版评论区啦

        //document.getElementById("comment_content").value = c[temp_count];//能够赋值啦

        var time = new Date();

        document.getElementById("comment_content").value ="我在: " +time.getFullYear()+"年 "+(time.getMonth()+1)+"月 "+time.getDate()+"日   "+time.getHours()+":"+time.getMinutes()+":"+time.getSeconds()+"  看过本篇博客!";//评论时间

        document.getElementsByClassName("btn-comment")[0].click();//发表评论成功!


},2000);//ajax do something

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