Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!