2025年9月3日星期三

问卷星答题任务脚本

1.购买服务器阿里云:服务器购买地址https://t.aliyun.com/U/PfsP97若失效,可用地址

1.购买服务器

阿里云:

服务器购买地址

https://t.aliyun.com/U/PfsP97

若失效,可用地址

https://www.aliyun.com/activity/wuying/dj?source=5176.29345612&userCode=49hts92d

腾讯云:

https://curl.qcloud.com/wJpWmSfU

若失效,可用地址

https://cloud.tencent.com/act/cps/redirect?redirect=2446&cps_key=ad201ee2ef3b771157f72ee5464b1fea&from=console

华为云

https://activity.huaweicloud.com/cps.html?fromacct=64b5cf7cc11b4840bb4ed2ea0b2f4468&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905

2.部署教程

2024年最新青龙面板跑脚本教程(一)持续更新中

3.代码如下

(function ($) {    'use strict';    let A = 0, B = 1, C = 2, D = 3, E = 4, F = 5, G = 6;    let shuffle = function (array) {        for (var j, x, i = array.length; i; j = parseInt(Math.random() * i), x = array[--i], array[i] = array[j], array[j] = x) ;        return array;    };    let url = {        jq/https:\/\/www\.wjx\.cn\/jq\/\w+\.aspx/.test(location.href),        hj/https:\/\/www\.wjx\.cn\/hj\/\w+\.aspx/.test(location.href),        m/https:\/\/www\.wjx\.cn\/m\/\w+\.aspx/.test(location.href)    };
    (function (setValue) {
    })(GM.setValue);
    var $fieldset = $('#fieldset1');
    $.extend({        // 1. 选择题(单选+多选)        selectQuestionfunction (option) {            var options = $.extend({                $fieldsetundefined,   // 表单                questionSelector'',   // 每个问题的selector                titleSelector'',      // 每个问题的标题selector                answerSelector'',     // 每个问题的答案selector                isRadiofunction ($answers) {                    return true;                },                isCheckboxfunction ($answers) {                    return true;                }            }, option);
            options.$fieldset.find(options.questionSelector).each(function () {                var $this = $(this);                var $answers = $this.find(options.answerSelector);
                let fillInput = function (value) {                    // 1. 单选题自动填写                    if (options.isRadio($answers)) {                        // 默认随机填写                        if(!value) { value = Math.round(Math.random() * ($answers.length - 1)); }                        $answers.eq(value).click();                    }
                    // 2. 多选题自动填写, 打乱按钮顺序, 默认随机点击多个答案                    if (options.isCheckbox($answers)) {                        // 默认随机点击多个答案                        if(!value || !value.length) {                            value = [];                            $answers = shuffle($answers); // 打乱顺序                            let num = Math.round(Math.random() * ($answers.length - 1)) || 1;                            for (let i = 0, len = num; i < len; i++) {                                value.push(i);                            }                        }                        $.each(value, (index, item) => $answers.eq(item).click());                    }                };
                // 1. 初始化 是否记住选项的checkbox                let $title = $this.find(options.titleSelector), title = $title.text();
                let $remember = $('<input type="checkbox" name="' + title + 'Remember">');                $remember.on('change'function () {                    let checked = $(this).is(':checked');                    GM.setValue(title+'Remember', pattern);                });

                $title.append($remember).append('(记住选项)');
                // 2. 恢复上次选中的选项                GM.getValue(title+'Remember').then(function (value) {                    $remember.prop('checked', !!value);                    fillInput(value);                });            });        },        // 2. 比重题        ratingQuestionfunction (option) {            return;            var options = $.extend({                $fieldsetundefined,   // 表单                answerSelector''      // 答案的selector            }, option);            options.$fieldset.find(options.answerSelector).each(function () {                var $this = $(this);                var $td = $this.children('td');                // 随机点击某一个选项                $td.eq(Math.round(Math.random() * ($td.length - 1))).click();            });

        },        // 3. 自动提交        autoSubmitfunction (option) {            var options = $.extend({                enabledfalse,     // 默认关闭自动提交                autoReopenfalse,  // 提交后是否重新打开问卷, 用于刷问卷                $buttonundefined  // 提交按钮            }, option);
            // 1. 点击获取验证码            $('#yucinput').click().focus();            // 2. 自动提交, 或者滚动到页面底部            if (options.enabled) {                options.$button.click();            } else {                $("html, body").animate({scrollTop: $(document).height()}, 1000);            }            // 3. 提交时在新标签页打开问卷            if (options.autoReopen) {                var reopen = function () {                    window.open(location.href'_blank');                    setTimeout(function () {                        window.close();                    }, 1000);                };                $('#yucinput').keypress(function (e) {                    if (e.which == 13) {                        reopen();                    }                });                options.$button.on('click', reopen);            }        }    });
    (function () {        let valid = url.jq || url.hj;        if (!valid) {            return;        }        console.log('匹配jq模式问卷');        $.selectQuestion({            $fieldset: $fieldset,            questionSelector'.div_question',            titleSelector'.div_title_question',            answerSelector'.div_table_radio_question .ulradiocheck li',            isRadiofunction ($answers) {                return $answers.find('a:first').hasClass('jqRadio');            },            isCheckboxfunction ($answers) {                return $answers.find('a:first').hasClass('jqCheckbox');            }        });        $.ratingQuestion({            $fieldset: $fieldset,            answerSelector'div.div_table_radio_question tbody tr'        });        $.autoSubmit({            enabledfalse,            autoReopenfalse,            $button: $('input.submitbutton')        });    })();
    (function () {        let valid = url.m;        if (!valid) {            return;        }        console.log('匹配m模式问卷');        $.selectQuestion({            $fieldset: $fieldset,            questionSelector'.field',            titleSelector'.field-label',            answerSelector'.ui-controlgroup div',            isRadiofunction ($answers) {                return $answers.hasClass('ui-radio');            },            isCheckboxfunction ($answers) {                return $answers.hasClass('ui-checkbox');            }        });        $.ratingQuestion({            $fieldset: $fieldset,            answerSelector'.matrix-rating tbody tr[tp]'        });        $.autoSubmit({            enabledfalse,            autoReopenfalse,            $button: $('#divSubmit').find('a.button')        });    })();})(jQuery);

解析

该脚本为问卷星自动随机填写脚本,主要作用包括:

  • 在问卷星页面(PC 的 jq/hj 模式与移动端 m 模式)自动随机作答

    • 支持单选题多选题比重/打分题(rating);

    • 可选 自动提交 与 提交后自动重新打开(用于刷卷)。

  • 允许为每道题开启"记住上次选项"(基于 GM.setValue / GM.getValue)以复用之前的回答。

结构与关键点

  • URL 适配:用正则判断当前是 jqhj 还是 m 模式,从而选择不同的 DOM 选择器与逻辑。

  • 随机打乱工具shuffle(array) 用于多选题时随机化选项点击顺序。

  • 入口:根据模式分别执行一组初始化(PC 一组、移动端一组)。

核心方法与职责

1) $.selectQuestion(options)

用于单选/多选题的随机选择与(可选)记忆:

  • 传入题块、题目标题、选项的选择器,以及如何判定是单选/多选的回调:

    • isRadio($answers):判断该题是否单选;

    • isCheckbox($answers):判断该题是否多选。

  • 逻辑:

    • 单选题:随机选中一个选项(或使用"记住"的值)。

    • 多选题:先打乱选项顺序,随机决定勾选数量与具体项(或使用"记住"的值)。

  • 题目标题处会追加一个"(记住选项)"复选框;若勾选,则把本题的选择写入 GM.setValue,下次进入页面时通过 GM.getValue 恢复并自动勾选。

小提示:源码里 $remember.on('change') 里 GM.setValue(title+'Remember', pattern) 的 pattern 变量未定义,实际应保存当前选择的值(如单选的索引或多选的索引数组)。这是一个小 bug,需自行修正。

2) $.ratingQuestion(options)

用于比重/打分题(矩阵评分等):

  • 根据传入的评分行选择器,随机点击一列作为该行评分。

  • 当前文件里在函数开头 return; 直接返回,相当于暂时禁用。想启用可移除该行。

3) $.autoSubmit(options)

控制验证码聚焦/自动提交/自动重开

  • enabled:是否自动点"提交";

  • autoReopen:提交后是否新开标签再重新加载问卷(用于循环刷答卷);

  • 会自动点击验证码输入框 #yucinput 并聚焦;若未开启自动提交则滚动到页底。

两套初始化(根据页面形态)

  • PC(jq/hj)
    传入:

    • questionSelector: '.div_question'

    • titleSelector: '.div_title_question'

    • answerSelector: '.div_table_radio_question .ulradiocheck li'

    • isRadio:检查子元素是否带 jqRadio

    • isCheckbox:检查子元素是否带 jqCheckbox

    • rating 用 div.div_table_radio_question tbody tr

    • 提交按钮 input.submitbutton

  • 移动端(m)
    传入:

    • questionSelector: '.field'

    • titleSelector: '.field-label'

    • answerSelector: '.ui-controlgroup div'

    • isRadio:是否有 ui-radio

    • isCheckbox:是否有 ui-checkbox

    • rating 用 .matrix-rating tbody tr[tp]

    • 提交按钮 #divSubmit a.button



注意

本文部分变量已做脱敏处理,仅用于测试和学习研究,禁止用于商业用途,不能保证其合法性,准确性,完整性和有效性,请根据情况自行判断。技术层面需要提供帮助,可以通过打赏的方式进行探讨。


历史脚本txt文件获取>>

服务器搭建,人工服务咨询>>

没有评论:

发表评论

问卷星答题任务脚本

1.购买服务器阿里云:服务器购买地址https://t.aliyun.com/U/PfsP97若失效,可用地址 1.购买服务器 阿里云: 服务器购买地址 https : //t.aliyun.com/U/PfsP97 若失效,可用地址 https ://www.aliyun....