(过程需要,问卷星链接需要在浏览器打开,在直接打开的链接本脚本⽆法使⽤)
①安装脚本:
②点击图⽚中红框位置按钮(因为我已经下载了,所以显⽰的是已安装)
③拉到页⾯最下⽅,点击添加⾄Chrome按钮
④添加完成后,在Chrome浏览器的右上⽅有下图所⽰按钮,点击之后,选择添加新脚本
多少金额可以立案⑤复制如下代码⾄“添加新脚本”页⾯内
/
/ ==UserScript==
// @name 问卷星测试——⽀持input radio checkbox
// @version 1.1
// @description 测试
// @author 蛋⽚鸡
// @match p/*
// @match www.wjx/*
// @grant none
// @require code.jquery/jquery-3.4.1.min.js
// ==/UserScript==
/*
**info 第⼀个参数:对应的填⼊选项(字符串)
**info 第⼆个参数:匹配的标题(正则表达式)
**info 第三个参数:(可选),当答题框为单选|多选时匹配的选项(正则表达式)*/
(function() {
'use strict';
const info=[
["蛋⽚鸡",/(姓名)|(名字)/],
["单选框_年级",/(年级)/,/(18级)/],
["18711111",/(学号)/],
["11011001100",/(联系⽅式)|(电话)|(⼿机)|(⼿机号)/],
["多选框_你好呀",/(你好呀)/,/(开始)|(中间)|(结束)/]
]
;
const ini={
module:".field.ui-field-contain",//每个问题模块
title:".field-label",//标题
type:{ //key对应别名,value对应html的节点
"input_text":".ui-input-text",
"radio":".ui-radio",
"checkbox":".ui-checkbox"
}
};
$(document).ready(function(){
let itemNum = 0;
$(dule).each(function(){
itemNum += 1;
let title=$(this).find(ini.title).text();
console.log("each循环" + itemNum);
//判断类别
let count = 0 ;
for(let i=0;i<info.length;i++){//匹配⽤户信息
if(info[i][1].test(title)){//匹配到⼀处信息,判断答题框类型,加break! for(let tp pe){周公解梦 梦见掉牙齿
let dom=$(this).pe[tp]);
if(dom.length>0){
switch(tp){
case "input_text":
$("#q"+itemNum)[0].value = info[i][0]; //赋值
break;
case "radio":
$(this).find(".ui-radio").each(function(){
if(info[i].length>=3&&info[i][2].test($(this).text())){ var id=$(this).find('input').attr('id');
$("#"+id).prop("checked",true);
}
});
break;
case "checkbox":
case "checkbox":
$(this).find(".ui-checkbox").each(function(){
console.log("outsidebox" + count);
if(info[i].length>=3&&info[i][2].test($(this).text())){ var id=$(this).find('input').attr('id');
$("#"+id).prop("checked",true);
}
});
break;
default:console.log("pe中没有匹配"+tp+"的键值"); }
break;
}
}
break;
}
}
});
//$("#ctlNext")[0].click();
死去的明星});
})();
⑥在“添加⾄新脚本”页⾯中,点击左上⾓的保存按钮
⑦打开问卷星地址,已经实现根据设定的答案,⾃动填写。
⑧额外说明:
a、因为本⼈对js不太熟悉,所以有个问题要说明。当我们刷新页⾯的时候,发现填空题填写了,但是单选和多选是没有选上的,其实
在js脚本⾥⾯,代码⾥是已经选上对应的选项了的,只不过不知道样式怎么不显⽰。(可以通过创建和我⼀样问题的问卷,然后做⼀下这份
问卷,再提交问卷,最后到问卷后台查看提交的记录中是否有单选和多选记录即可)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="/1999/xhtml">
<head>
<title>测试使⽤</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1,user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<link rel="canonical" href="www.wjx/jq/49588636.aspx" />
<meta property="og:type" content="article" />
<meta property="og:release_date" content="2019-11-12" />
<meta property="og:image" content="image.wjx/images/wlogo.png" />
<meta property="og:title" content="测试使⽤" />
<meta property="og:description" content="我在问卷星上发布了问卷《测试使⽤》,请帮忙填写,⾮常感谢!" />
<meta name="applicable-device" content="mobile" />
<link rel="dns-prefetch" href="//sojump-hangzhou.log.aliyuncs" />
<script type="text/javascript">
var maxCheatTimes = 0;
var activityId =49588636;
if (window.location.hash) {
window.location.hash = "";
window.location.href = window.place("#", "");
}
var isWeiXin=0;
</script>
<link rel="stylesheet" href="/joinnew/css/jqmobo.css?v=973" />
<script src="staticfile.qnssl/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
!window.jQuery && document.write('<script src="/js/jquery-1.10.2.min.js"><\/script>');
</script>
<script src="/joinnew/js/hintinfo.js?v=2" type="text/javascript"></script>
<script src="/joinnew/js/jqmobo2.js?v=973" type="text/javascript"></script>
<style>
</style>
</head>
<body>
<div id="divTip" tipHeight" ></div>
<div id="divWorkError">
</div>
<form id="form1" method="post" action="www.wjx/joinnew/processjq.ashx?curid=49588636" >
<div id="divLoadAnswer" >
</div>
<div id="toptitle">
<h1 class="htitle" id="htitle"> 测试使⽤</h1>
</div>
<div id="divBackgroundWrap"></div>
<div id="divMaxTime" spanTimeTip"></span>
<span id="spanMaxTime"></span>
</div>
<div id="divContent" class="divContent">
<div class="checkInMode__head clearfix" id="divCheckInMode" >
<div class="wjxCountDown__wrap game_time">
<div class="countDown__hold">
<div class="round round1"></div>
</div>
</div>
<div class="countDown__hold">
<div class="round round2"></div>
</div>
<div class="countDown__bg"></div>
<div class="CountDown__frame"></div>
<div class="countDown__time">
<div class="countDown__time--num" id="divCGMaxTime">
10
</div>
<div class="countDown__time--unit">
秒
</div>
</div>
</div>
<div class="icon decoration-icon pull-left"></div>
<div class="schedule-wrap pull-right">
<div id="schedule">
1
</div> /
<span id="cgtotal">5</span>题
</div>
</div>
<div id="divDesc" class="formfield">
<span class="description"> 哈哈哈</span>
</div>
<div id="divQuestion">
<fieldset class="fieldset" id="fieldset1">
<div class="field ui-field-contain" id="div1" topic="1" data-role="fieldcontain" type="1">
<div class="field-label">
1. 姓名
</div>
<div class="ui-input-text" >
<input type="text" id="q1" value="" name="q1" />
</div>
<div class="errorMessage"></div>
</div>
<div class="field ui-field-contain" id="div2" req="1" topic="2" data-role="fieldcontain" type="3">
<div class="field-label">
2. 年级
<span class="req">*</span>
</div>
新车多少公里换机油<div class="ui-controlgroup">
<div class="ui-radio">
<span class="jqradiowrapper"><input type="radio" value="1" id="q2_1" name="q2" /><a class="jqradio" href="javascript:;"></a></span> <div class="label" for="q2_1">
16级
</div>
</div>
<div class="ui-radio">
张天录音<span class="jqradiowrapper"><input type="radio" value="2" id="q2_2" name="q2" /><a class="jqradio" href="javascript:;"></a></span> <div class="label" for="q2_2">
17级
</div>
</div>
<div class="ui-radio">
<span class="jqradiowrapper"><input type="radio" value="3" id="q2_3" name="q2" style="display:no
ne;" /><a class="jqradio" href="javascript:;"></a></span> <div class="label" for="q2_3">
18级
</div>
</div>
<div class="ui-radio">
<span class="jqradiowrapper"><input type="radio" value="4" id="q2_4" name="q2" /><a class="jqradio" href="javascript:;"></a></span> <div class="label" for="q2_4">
19级
</div>
发布评论