[英]How to complete a form and press submit on page load
我想编写一个简单的Greasemonkey脚本,以在每次页面加载时完成并提交此表单。
在脚本中输入预定义的电子邮件地址(email@gmail.com),然后每次提交
<div class="col-md-4">
<label for="Content_C001_LI_02_txtEmail">Send proof of delivery email to:</label>
</div>
<div class="col-md-5">
<input name="ctl00$Content$C001$LI_02_txtEmail" type="text" value="email@gmail.com" id="Content_C001_LI_02_txtEmail" class="form-control" onkeypress="return clickButton(event,'Content_C001_LI_02_btnSend')"><span id="Content_C001_ctl23" style="display:none;"></span>
</div>
<div class="col-md-3">
<button onclick="if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate('LI_02'); __doPostBack('ctl00$Content$C001$LI_02_btnSend','')" id="Content_C001_LI_02_btnSend" type="button" class="btn btn-primary btn-inline-label" validationgroup="LI_02">Send</button>
</div>
提交表单后,这部分代码将更改。
因此,我将需要弄清楚如何仅在之前尚未提交脚本的情况下运行该脚本。
<div id="Content_C001_ctl00" class="alert alert-success" style="display:none;">
至
<div id="Content_C001_ctl00" class="alert alert-success">
Proof of delivery has been successfully emailed to email@gmail.com <br>
非常感谢您的帮助! :)
像这样的东西?
document.addEventListener ("DOMContentLoaded", checkSubmitEmail);
function checkSubmitEmail(){
var myEmail = 'vns@gmail.com';
// 1- check if email has been submitted
var submitted = document.getElementById('Content_C001_ctl00').innerHTML.startsWith('\nProof of delivery has been successfully emailed to ' + myEmail);
// 2- if not continue
if (!submitted){
// 3- fill in email
document.getElementById('Content_C001_LI_02_txtEmail').value='' + myEmail;
// 4- click button
document.getElementById('Content_C001_LI_02_btnSend').click();
}
}
很难准确说出,但是cookie可能就是您在这里寻找的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.