2010-04-10 83 views
2

我想要自動提交表單,但我不確定如何使用此按鈕來完成。 按鈕似乎具有以下特性如何使用Greasemonkey自動提交表單?

a class="blue-button" href="javascript:void(0)" onclick="Form.submit(this);" 

,我在上面看到的唯一形式

<form xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://www.blizzard.com/ns/store" action="/account/management/add-game.xml" autocomplete="off" method="post"> 

的頁面是here您可以使用「[email protected]」和「A1A1A1A1」爲登錄。

回答

5
document.getElementsByTagName('form')[0].submit(); 

請注意,這將只在頁面上的第一個表單。如果需要,可以將數組索引增加到[1],或者遍歷數組以查找正確的表單。

+0

謝謝,該代碼確實工作。 – magixx 2010-04-15 16:11:48

+1

同樣,您可以使用document.nameOfYourForm.submit()。這將提交一個特定的表格,而不必擔心正確的索引。這假定你可以給你的表單一個名字。 – 2011-06-01 14:25:31

+0

出於某種原因'document.nameOfYourForm.submit();'不適合我。然而,'var myForm = document.getElementByID('nameOfYourForm'); myForm.submit();'工作得很好。謝謝,james.garriss! – 2014-03-15 15:43:21

1

後,你得填寫用戶名和密碼字段,這樣做:

unsafeWindow.Form.submit(document.getElementsByClassName('submit')[0]); 

檢查unsafeWindow文檔here

+1

不幸的是,這段代碼沒有工作。 – magixx 2010-04-11 17:24:58