Script to automate the passing credentials to next page

I have one URL which asks me to " click here to login" then the next page loads. once the next page loads I need to pass the credential. tried the below script it clicks on the button but doesn’t pass the credentials on second page

the process should be: in first-page script is clicking on next button
in second page script is passing the credentials .


$( document ).ready(function() 
{ if document.location.href==""
then {