Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

212
Visualizações
How to automatically click log in button using JavaScript

I want to save some JavaScript code as a bookmark in chrome so it automatically opens my university login site and clicks on on the login button. I am completely inexperienced in JavaScript, so I have no clue how to do this. I snipped together the following code, which opens the correct website, but then does not click on anything. The first URL automatically puts me to the login site (third URL in the code) in case I have not logged in yet in this window.

(function() {
    window.location.replace("https://lms.uzh.ch/auth/MyCoursesSite/0");
    window.onload = function(){
        if (current_url.startswith('https://lms.uzh.ch/auth/MyCoursesSite/0')) {
            return;
        }
        if (current_url.startsWith('https://lms.uzh.ch/dmz/')) {
            document.getElementById("wayf_submit_button").click();
        }
    };
})();

I'm sorry if this is too obvious a question and annoys any experts but as I said I am a complete beginner. I would of course add the "javascript:" at the beginning for chrome to understand the bookmark.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

When you use window.location.replace, you change the address and you code can't work anymore.

I can suggest using some browser extension, your "click function" should work then.

I guess you could also try to make some simple html page with iframe, you call your "click function" at this page, but you target it to the iframe. After that you can change browser's location to the university's webpage as you should already be logged in.

<html>
 <head>
 </head>
 <body>
  <iframe src="your_university_address.com" id="some_id" onload="click_button()"></iframe>
  <script>
   function click_button()
   {
    my_iframe=document.getElementById('some_id');
    my_iframe.contentDocument.getElementById('your_button_id').click();
   }
  </script>
 </body>
</html>

Very simple but it should do that job. (You can achieve similar result by using window.open() I guess)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda