簡體   English   中英

Greasemonkey:如何自動填寫登錄表單?

[英]Greasemonkey: how can I autofill the login form?

我想在( https://my.evon-home.com/login.html )上自動填寫我的登錄表單。

我正在使用 Greasemonkey,我寫了一點 Javascript。 但它不起作用。

這是我的 JS 代碼:

// ==UserScript==
// @name     user
// @namespace  https://my.evon-home.com/login.html
// @version  1
// @grant    none
// ==/UserScript==
document.getElementById("relayid").value = "123"
document.getElementById("user").value = "test";
document.getElementById("password").value = "test"

等待頁面加載。 嘗試這個

window.addEventListener('load', function() {
    document.getElementById("relayid").value = "999"
    document.getElementById("user").value = "demo";
    document.getElementById("password").value = "demo"
}, false);

如果要提交表單,則可以使用表單的選擇器然后提交。

window.addEventListener('load', function() {
    document.getElementById("relayid").value = "999"
    document.getElementById("user").value = "demo";
    document.getElementById("password").value = "demo"

    document.getElementsByClassName('form')[0].submit()
}, false);

在我看來,使用 IceRaven(在 Android 上)在 Violentmonkey 上添加偵聽器無法正常工作。 可以改用@run-at元塊(參見https://wiki.greasespot.net/Metadata_Block#.40run-at ),它似乎可以跨平台和跨插件工作:

// ==UserScript==
// @name     user
// @namespace  https://my.evon-home.com/login.html
// @version  1
// @run-at   document-end
// @grant    none
// ==/UserScript==
document.getElementById("relayid").value = "123"
document.getElementById("user").value = "test";
document.getElementById("password").value = "test"

暫無
暫無

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

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