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.2
// @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
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    
    // 发送head请求获取x-secsdk-csrf-token
    function head(){
        var settings = {
           "url": "https://studio.ixigua.com/api/comment/CommentReply",
           "method": "HEAD",
           "timeout": 0,
           "headers": {
              "authority": "studio.ixigua.com",
              "x-secsdk-csrf-version": "1.2.7",
              "x-secsdk-csrf-request": "1"
           },
        };

        $.ajax(settings).done(function (response, status, xhr) {
           console.log("resp: " + response);
           console.log("status: " + status);
           console.log("xhr: "+ xhr.getAllResponseHeaders())
        });
    }
    
    var button = document.createElement("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"; //按钮四个角弧度
    button.addEventListener("click", clickButton) //监听按钮点击事件

    document.getElementsByClassName("byte-list-header")[0].appendChild(button);

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

    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("" + message);
                  var ff = message.data[0];
                  console.log(ff);
                },
                error: function (message) {
                    console.error("" + message)
                }
            });
    }
    
    
    function sleep(ms) {
        var start = Date.now(), expire = start + ms;
        while (Date.now() < expire) ;
        return;
    }

    function clickButton(){

        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];

            post(commentId, userId, comment);
            sleep(5000);
        }
    }
    

})();