Greasy Fork

Greasy Fork is available in English.

西瓜视频自动回复评论

自动回复西瓜视频的评论

当前为 2022-03-26 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         西瓜视频自动回复评论
// @namespace    http://tampermonkey.net/
// @version      0.82
// @description  自动回复西瓜视频的评论
// @author       cpp
// @license      MIT
// @require      https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js
// @match        https://studio.ixigua.com/comment
// @icon         https://www.google.com/s2/favicons?sz=64&domain=toutiao.com
// @run-at       document-idle
// @grant        none
// ==/UserScript==

/*/
var importJs=document.createElement('script')  //在页面新建一个script标签
importJs.setAttribute("type","text/javascript")  //给script标签增加type属性
importJs.setAttribute("src", 'https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js') //给script标签增加src属性, url地址为cdn公共库里的
document.getElementsByTagName("head")[0].appendChild(importJs) //把importJs标签添加在页面
//*/

    function sleep(delay) {
      var start = (new Date()).getTime();
      while ((new Date()).getTime() - start < delay) {
        continue;
      }
    }
    
    function post(commentId, userId, comment) {
        var da = {
            "ReplyToCommentId": commentId,
            "ReplyToReplyId": 0,
            "ReplyToUserId": userId,
            "Content": comment,
            "ImageList": []
        };

        $.ajax({
            type: "POST",
            url: "https://studio.ixigua.com/api/comment/CommentReply",
            contentType: "application/json charset=utf-8",
            data: JSON.stringify(da),
            headers: {
              "accept": "*/*",
              "content-type": "application/json"
            },
            dataType: "json",
            success: function (message) {
              console.log("msg:" + JSON.stringify(message));
            },
            error: function (message) {
                console.error("" + message)
            }
        });
    }

    function clickButton(){
        var comments=[
            "感谢支持[玫瑰][玫瑰][玫瑰]",
            "谢谢您的支持[比心][比心][比心]",
            "谢谢支持,愿您平安健康,[祈祷][祈祷][祈祷]",
            "感恩支持,祝您幸福快乐,[玫瑰][玫瑰][玫瑰]",
            "感谢支持,祝您天天开心,笑口常开[祈祷][祈祷][祈祷]",
            "感谢支持,祝您幸福无限,百事可乐[祈祷][祈祷][祈祷]",
            "感谢支持,祝您永享幸福,财源滚滚[祈祷][祈祷][祈祷]",
            "感谢支持,祝您岁岁平安,蒸蒸日上[祈祷][祈祷][祈祷]",
            "感谢支持,祝您幸福安康,金玉满堂[祈祷][祈祷][祈祷]",
            "感谢支持,祝您顺心如意,大展宏图[祈祷][祈祷][祈祷]",
            "感谢支持,祝您心想事成,财源广进[祈祷][祈祷][祈祷]",
            "感谢支持,祝您幸福快乐,恭喜发财[祈祷][祈祷][祈祷]",
            "感谢支持,祝您身体倍儿棒,吃嘛嘛香[比心][比心][比心]"
        ];
        var START = 0;
        var END = comments.length;

        var userComments = $(".m-comment-item");
        var userImages = $(".user-img");
        var diggButtons = $(".m-digg-btn");
        for (var i=0; i<userComments.length; i++) {
            var commentId = userComments[i].id;
            var userImageUrl = userImages[i].href;
            var userId = parseInt(userImageUrl.substring(userImageUrl.lastIndexOf("/")+1, userImageUrl.lastIndexOf("?")));
            var randomIndex = Math.floor(Math.random()*(END-START));
            var comment = comments[randomIndex];
            (function(i) {
                setTimeout(function() {
                    console.log(i);
                    post(commentId, userId, comment);
                }, (i + 1) * 3000);
            })(i);
        }
    }

    var button = document.createElement("button");
    button.id = "reply-button";
    button.textContent = "一键回复评论";
    button.style.width = "100px";
    button.style.height = "28px";
    button.style.align = "center";
    button.style.color = "white";
    button.style.background = "#e33e33";
    button.style.border = "1px solid #e33e33";
    button.style.borderRadius = "4px";
    document.getElementsByClassName("m-menu")[0].appendChild(button);

    document.addEventListener('click', event => {
        if (event.target.id == "reply-button") {
            event.stopPropagation();
            clickButton();
            console.log("sdfasdfa");
            return;
        }
    }, true);