Greasy Fork

Greasy Fork is available in English.

知到/智慧树讨论区复读机

知到/智慧树讨论区复读机,刷互动分。

目前为 2021-06-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         知到/智慧树讨论区复读机
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  知到/智慧树讨论区复读机,刷互动分。
// @author       bakapppp
// @match        *://qah5.zhihuishu.com/*
// @grant        none
// @require      http://code.jquery.com/jquery-1.11.0.min.js
// ==/UserScript==

(function() {
    function logmsg(content) {
        var ele = String(content);
        $('#msg').append(ele);
        $('#msg').append('<br>');
    }

    function start(){


        var tim = 1000;
        var courseId = "";
        var recruitId = "";
        var url = window.location.href;
        var temp = url.split("/").pop();
        var queue = [];
        courseId = temp.split("?")[0];
        temp = url.split("?").pop();
        recruitId = temp.split("&")[1].split("=").pop();

        //console.log(courseId, recruitId);

        var uuid = "";
        /*
    $.ajaxSetup({
        crossDomain: true,
        xhrFields:{
            withCrendentials: true
        }
    });
*/
        function do_comment(questionId) {
            logmsg("正在回答 "+String(questionId));
            console.log(questionId);
            console.log(queue.length);
            //return;
            $.get(
                "https://creditqa.zhihuishu.com/creditqa/web/qa/getAnswerInInfoOrderByTime",
                //?uuid=XAZ1PgWn&questionId=424914534&sourceType=2&courseId=1000006154&recruitId=4402
                {
                    uuid: uuid,
                    questionId: questionId,
                    sourceType: 2,
                    courseId: courseId,
                    recruitId: recruitId,
                },
                function(data){
                    //console.log(data);
                    var content = "不知道";
                    var temp = data.rt.answerInfos;
                    if(temp.length>=1){
                        content = temp[0].answerContent;
                    }
                    logmsg("自动复读内容为: "+content);
                    $.post(
                        "https://creditqa.zhihuishu.com/creditqa/web/qa/saveAnswer",
                        {
                            uuid: uuid,
                            annexs: [],
                            qid: questionId,
                            source: 2,
                            aContent: content,
                            courseId: courseId,
                            recruitId: recruitId,
                        },
                        function(data) {
                            console.log(data);
                            logmsg(String(data.msg));
                        }
                    );
                }
            )
        }

        var fin = false;
        function check(){
            if(queue.length!=0){
                logmsg("剩余 "+String(queue.length) + " 个问题");
                do_comment(queue.pop());
            }
            else {
                if(!fin) {
                    logmsg('已复读完全部问题');
                    fin = true;
                }
            }
        }

        function solve(index=0){
            //console.log(uuid);
            if(index == -1)
            {
                logmsg("共 "+String(queue.length)+" 个问题");
                setInterval(check, 5*1000);
                return;
            }
            $.get(
                "https://creditqa.zhihuishu.com/creditqa/web/qa/getHotQuestionList",
                {
                    "uuid": uuid,
                    "courseId": courseId,
                    "pageIndex": index,
                    "pageSize": 50,
                    "recruitId": recruitId,
                },
                function(data){
                    //console.log(data);
                    var temp = data.rt.questionInfoList;
                    for(var i=0;i<temp.length;++i){
                        //setTimeout(do_comment(temp[i].questionId),tim);
                        //tim+=1000*30;
                        queue.push(temp[i].questionId);
                    }
                    solve(data.rt.pageIndex);
                }
            );
            //alert("xxx");
        }

        $.ajax({
            type: "GET",
            url: "https://creditqa.zhihuishu.com/creditqa/login/getLoginUserInfo",
            useCORS: true,
            xhrFields: {
                withCredentials: true //允许跨域带Cookie
            },
            success: function(data) {
                uuid = data.result.uuid;
                solve(0);
            }
        })
    }



    $("body").append(" <div id='mymain' style='left: 10px;bottom: 10px;overflow:scroll;background: #1a59b7;color:#ffffff;overflow: hidden;z-index: 9999;position: fixed;padding:5px;text-align:center;width: 300;border-bottom-left-radius: 4px;border-bottom-right-radius: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;'></div>");
    $('#mymain').append('知到讨论区复读机<br>')
    $('#mymain').append('<div id="msg"></div>')
    $('#mymain').append('<button type="button" id="gkd" style="color:black;">开始复读</button>')

    var flag = false;

    $('#gkd').click(function(){
        if(!flag) {
            flag = true;
            start();
            logmsg('开始复读');
        }
    })

    //$.get("https://creditqa.zhihuishu.com/creditqa/login/getLoginUserInfo",function(data){console.log(data)});
})();