[英]Greasemonkey: how can I autofill the login form?
I want to auto fill my login form on ( https://my.evon-home.com/login.html ).我想在( https://my.evon-home.com/login.html )上自动填写我的登录表单。
I am using Greasemonkey and I wrote a little Javascript.我正在使用 Greasemonkey,我写了一点 Javascript。 But it is not working.
但它不起作用。
Here is my JS code:这是我的 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"
Wait for the page to load.等待页面加载。 Try this
尝试这个
window.addEventListener('load', function() {
document.getElementById("relayid").value = "999"
document.getElementById("user").value = "demo";
document.getElementById("password").value = "demo"
}, false);
If you want to submit the form then you can use the form's selector and then submit it.如果要提交表单,则可以使用表单的选择器然后提交。
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);
It seems to me that adding the listener does not work properly on Violentmonkey with IceRaven (on Android).在我看来,使用 IceRaven(在 Android 上)在 Violentmonkey 上添加侦听器无法正常工作。 One could instead use the
@run-at
metablock (cf. https://wiki.greasespot.net/Metadata_Block#.40run-at ) which seems to work cross-platform and cross-plugin:可以改用
@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.