简体   繁体   English

来自 javascript 控制台 Chrome 的输入表单

[英]Input form from javascript console Chrome

I try to use Chrome console to input form Username and Password on this website: https://ucp.nordvpn.com/login/ but when click button Log in. It shows error "Username cannot be blank"我尝试使用 Chrome 控制台在此网站上输入表单用户名和密码: https : //ucp.nordvpn.com/login/但是当单击按钮登录时,它显示错误“用户名不能为空”

Please help me.请帮我。 Thank you谢谢

// Input prompt format user:password
var account = prompt('Account?');
if (account) {
    account = account.split(":");
    console.log(account);
    document.querySelector("#ucp_login_email_field").value = account[0];
    document.querySelector("#ucp_login_password_field").value = account[1];
    document.querySelector(".Button").click();
}

This worked for me.这对我有用。 please try this.请试试这个。 But at first check account is empty or not.但首先检查帐户是否为空。

// Input prompt format user:password
    var account = ["demo@gmail.com", "123456"]; 
    if (account) {
        console.log(account);
        document.querySelector("#ucp_login_email_field").value = account[0];
        document.querySelector("#ucp_login_password_field").value = account[1];
    };
    if (document.querySelector("#ucp_login_email_field").value != "" && document.querySelector("#ucp_login_password_field").value != ""){
        document.querySelector("form").submit();
    } else{
        console.log("fields are not filled correctly");
    }

When you type the values in the text box, values(username, password) are stored in variables.当您在文本框中键入值时,值(用户名、密码)存储在变量中。 While submitting the form, values are taken from variable and overwrite your values(you assigned via chrome console) in the textbox.提交表单时,值取自变量并覆盖文本框中的值(您通过 chrome 控制台分配)。

So, your values can not be submitted through chrome console unless it is typed in the textbox.因此,除非在文本框中键入值,否则无法通过 chrome 控制台提交值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM