我第一次嘗試訪問工作中的網頁時,我被重定向到一個內部託管的網頁,其中包含IT指南和一個帶有兩個按鈕「同意」和「不同意」的表單, 。點擊「同意」,然後允許當天外部互聯網訪問,並將您發送到您最初尋找的網站。使用Greasemonkey提交表格
我想製作一個自動提交表單的Greasemonkey腳本,因爲我已經有一個批處理文件啓動所有我的普通應用程序在啓動時,這將允許我離開電腦,而它每天做20分鐘啓動;)
頁面只有一個形式:
<form method="post">
<input type="submit" value="I Agree" class="agree" onsubmit="submitonce(this)" />
<input type="button" onclick="javascript:window.close();" value="I Disagree"
class="disagree"/>
</form>
而且不知道,如果它很重要,因爲我只需要點擊,但功能submitonce
是:
function submitonce(theform) {
//if IE 4+ or NS 6+
console.log("Submitting");
if (document.all || document.getElementById) {
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i = 0; i < theform.length; i++) {
var tempobj = theform.elements[i];
if (tempobj.type.toLowerCase() == "submit" ||
tempobj.type.toLowerCase() == "reset")
//disable em
tempobj.disabled = true;
}
}
}
我有其餘的來源,但它看起來不像其他任何相關的東西。在Greasemonkey/JS中我沒有真正編碼,所以任何幫助,將不勝感激。我正在玩an existing userscript,使用Ctrl輸入點擊按鈕。
顯然我不在乎它是虛擬的「點擊」還是隻是提交函數的觸發器,因爲我會說他們是同一件事情,不是嗎?
你打算使用什麼瀏覽器? – 2012-07-19 07:01:36
它們不一樣,'submit()'不會將提交按鈕的名稱和值與數據一起發送。 – Adi 2012-07-19 07:06:26
再次看看你的html,我不認爲'input'元素有'onsubmit'屬性。 – 2012-07-19 07:09:40