hiya
no need for scripts. MS needs only your domain to know where to redirect to your ADFS/SAML service. all you need is a properly formatted URL
read this - https://chamonixvue.wordpress.com/2016/05/23/how-to-bypass-the-office-365-login-redirect-page-with-adfs/