其他分享
首页 > 其他分享> > 问卷星自动填写

问卷星自动填写

作者:互联网

油猴上使用的脚本不过要修改一下单选框和多选框的序号,问卷的地址,但有时候验证会出错。

// ==UserScript==
// @name         问卷星自动填写
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  自动填写问卷星的问卷,要修改单选框和多选框
// @author       You
// @match        https://www.wjx.cn/vm/*  
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bing.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const content = document.querySelectorAll('div.ui-field-contain');
    //跳过是否填过该问卷要重复填
    const confirm_box = document.getElementById('confirm_box');
    if(confirm_box){
     const as = confirm_box.querySelectorAll('#confirm_box > div:nth-of-type(2) div:nth-of-type(3) button:first-child');
     console.log(as)
     as[0].click()
    }
    const checkbox = [17,19,20];//多选框
    const radio = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18];//单选框
    let t2 = setInterval(()=>{
        let temp1 = content[checkbox[0]].querySelectorAll('.ui-controlgroup .jqcheck');
        if(temp1){
            clearInterval(t2);
            for(let i =0;i<checkbox.length;i++){
                let temp = content[checkbox[i]].querySelectorAll('.ui-controlgroup .jqcheck');
                const index = Math.floor(Math.random() * temp.length)+1;
                for(let j = 0;j<index;j++){
                    temp[j].click();
                }
            }
        }
    },200);

    for(let i =0;i<radio.length;i++){
        let temp = content[radio[i]].querySelectorAll('.ui-controlgroup .jqradio')
        const index = Math.floor(Math.random() * temp.length);
        temp[index].click();
    }

    let timer;
    timer = setTimeout(()=>{
        const rectMask = document.getElementById('rectMask');
        // 智能验证
        if(rectMask){
            rectMask.click()
        }
        const ctlNext = document.getElementById('ctlNext');
        // 提交按钮
        setTimeout(()=>{
            ctlNext.click();
        },1000)
            window.open('自己的问卷地址')
        const rectMask1 = document.getElementById('rectMask');
        // 智能验证
        if(rectMask1){
            rectMask1.click()
        }
        const rectMask1 = document.getElementById('nc_1_n1z');
        if(rectMask1){
            
        }
    },1000)


    // Your code here...
})();

 在浏览器控制台使用的:注意要改单选框和多选框

const content = document.querySelectorAll('div.ui-field-contain');

const checkbox = [2,4,7,8,9];//多选框
const radio = [0,1,3,5,6,10];//单选框

// // 跳过是否填过该问卷要重复填
// if(typeof confirm_box !== 'undefined'){
// 	const as = confirm_box.querySelectorAll('#confirm_box > div:nth-of-type(2) div:nth-of-type(3) button:first-child');
// 	console.log(as)
// 	as[0].click()
// }

for(let i =0;i<checkbox.length;i++){
	let temp = content[checkbox[i]].querySelectorAll('.ui-controlgroup .jqcheck')
	const index = Math.floor(Math.random() * temp.length)+1;
	for(let j = 0;j<index;j++){
		temp[j].click();
	}
	
}

for(let i =0;i<radio.length;i++){
	let temp = content[radio[i]].querySelectorAll('.ui-controlgroup .jqradio')
	const index = Math.floor(Math.random() * temp.length);
	temp[index].click();
}

let timer;
timer = setTimeout(()=>{
	// 智能验证
	if(typeof rectMask !== 'undefined'){
		rectMask.click()
	}
	// 提交按钮
	ctlNext.click();
},1000)

标签:box,rectMask,const,confirm,自动,填写,document,click,问卷
来源: https://blog.csdn.net/qq_45808923/article/details/121959041