簡體   English   中英

如何填寫表格並按頁面加載提交

[英]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可能就是您在這里尋找的東西。

JS Cookie界面上的MDN文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM