我想编写一个简单的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>
非常感谢您的帮助! :)
答案 0 :(得分:1)
这样的事可能吗?
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();
}
}
答案 1 :(得分:0)
很难准确地说出来,但饼干可能就是你在这里寻找的。 p>