Enter values and click the button automatically at the set time

Asked

Viewed 390 times

0

I have a website with a small screen with a login form.

And my idea is to schedule the automatic login for such a time.

For example, I want to have a simple way to change the code as well.

The idea is this:

When giving 18:00 at night or other time I inform in the code, the site load with my login and password and call the click on Submit automatically.

How can I do that? Really you are finding strange my intention and will say that it is not safe etc, but I want to style a macro to edit a site I already have using element inspection and then adapt.

But in the current situation, I want to do with my website shown below:

   <!DOCTYPE html>
<html>
<head>
<title> Teste macro </title>
</head>
<body>
<p> Login: </p>
<input type="text" name="txtLogin"/></input>
<p> Senha: </p>
<input type="password" name="txtSenha"/>
<br>
<br>
<input type="submit" name="btSubmit"/>
</body>
</html>

I’m not able to dock html right here on the screen where you can put css, html, etc, is crashing on my pc.

Which way to go to create this macro?

  • Your "[...] but I want to style a macro to edit a site I already have [...]" leads me to believe that the best option for you is not Javascript, and yes Autohotkey. :)

1 answer

1

I imagine you have to make a loop to test the time, if the time fills the fields and gives a Submit in the form.

var horario = {
        hora: 18,
        minutos: 0
    },
    login = {
        email: "[email protected]",
        senha: "secret"
    }
    input_email = document.getElementById("input_email"),
    input_senha = document.getElementById("input_senha"),
    form = document.getElementById("meu-form");


// Executa a função a cada segundo e guarda o identificados do Interval (caso seja necessário cancelar o timer)
var timer = setInterval(function(){
    var now = Date.now();

    if( now.getHours() === horario.hora && now.getMinutes() === horario.minutos) {

        clearInterval(timer);

        input_email.value = login.email;
        input_senha.value = login.senha;
        form.submit();
    }

}, 1000);
  • Can you increase the interval to 60000 (one minute) not to be processing without need

Browser other questions tagged

You are not signed in. Login or sign up in order to post.