问卷星自动填写

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

// ==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()
        }
    },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)

升级版

let questions = document.querySelectorAll('.div_question .div_table_radio_question .ulradiocheck');


questions = Array.from(questions);

questions.forEach(item=>{
	const a = item.querySelectorAll('li a');
	const temp = item.querySelectorAll('li input');
	if(temp[0].getAttribute('type') === 'radio') {
		// 单选
		const index = Math.floor(Math.random() * temp.length);
		a[index].click();
	}else{
		console.log(item)
		// 多选
		let flag = false;//防止一个未选
		for(let i = 0;i<temp.length;i++) {
			const index = Math.random();
			if(index > 0.5) {
				a[i].click();
				flag = true;
			}
		}
		if(!flag) {
			// 一个都未选
			a[0].click();
		}
	}
})

const alert_box = document.querySelector('#alert_box .mainBgColor')
if(alert_box){
	alert_box.click()
}

const captchaout = document.querySelector('#captchaout #rectMask')
if(captchaout){
	captchaout.click()
}
// 提交按钮
const submit = document.querySelector('#submit_div #submit_button')
setTimeout(()=>{
	submit.click();
},1000)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值