Skip to content

Instantly share code, notes, and snippets.

@gavinn212
Last active May 12, 2020 10:26
Show Gist options
  • Save gavinn212/8364e2d5aab5037abfabc03bf12c12a7 to your computer and use it in GitHub Desktop.
Save gavinn212/8364e2d5aab5037abfabc03bf12c12a7 to your computer and use it in GitHub Desktop.
Auto-login McMaster Account for Mac Websites
var username = "REPLACE WITH YOUR USERNAME";
var password = "REPLACE WITH YOUR PASSWORD";
var email = "REPLACE WITH YOUR MAC EMAIL";
// ==UserScript==
// @name Auto-login McMaster Account for Mac Websites
// @namespace https://greasyfork.org/en/scripts/403133
// @version 1.1
// @description Auto-login to McMaster Websites
// @author Gavinnn Zhang 北稱
// @include https://avenue.mcmaster.ca/?target=*
// @include https://www.oscarplusmcmaster.ca/notLoggedIn*
// @match https://www.childsmath.ca/childsa/forms/main_login.php
// @include https://login.echo360.ca/login?*
// @include https://epprd.mcmaster.ca/psp/prepprd/?cmd=login*
// @match https://loncapa.mcmaster.ca/adm/menu
// @include https://cap.mcmaster.ca/mcauth/login.jsp?*
// @include https://sso.mcmaster.ca/idp/profile/SAML2/Redirect/SSO?execution=*
// @include https://sso.mcmaster.ca/shibboleth-idp/profile/SAML2/Redirect/SSO?execution=*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var url=window.location.href;
// test which web is opened and click login - a2l
if(url.indexOf("https://avenue.mcmaster.ca/?target=") > -1)
{document.getElementById("login_button").click();}
// test which web is opened and click login - childmath
if(url.indexOf("https://www.childsmath.ca/childsa/forms/main_login.php?") > -1)
{document.getElementById("submit").click();}
// test which web is opened and click login - echo 360
if(url.indexOf("https://login.echo360.ca/login?") > -1)
{document.getElementById("email").value=email;
document.getElementById("submitBtn").click();}
// test which web is opened and click login - Mosaic
if(url.indexOf("https://epprd.mcmaster.ca/psp/prepprd/?cmd=login") > -1)
{document.getElementById("userid").value=username;
document.getElementById("pwd").value=password;
document.getElementsByClassName("ps-button")[0].click();}
// test which web is opened and click login - LON-CAPA
if(url.indexOf("https://loncapa.mcmaster.ca/adm/menu") > -1)
{document.getElementById("uname").value=username;
var intput1 = document.getElementsByTagName('input');
for(var i=0;i<intput1.length;i++)
{if(intput1[i].type.toUpperCase()=='PASSWORD')
{intput1[i].value = password;}}
var intput2 = document.getElementsByTagName('input');
for(var j=0;j<intput2.length;j++)
{if(intput2[j].type.toUpperCase()=='SUBMIT')
{intput2[j].click();}}}
// test which web is opened and click login - OSCAR plus
if(url.indexOf("https://www.oscarplusmcmaster.ca/notLoggedIn") > -1)
{var intput3 = document.getElementsByTagName('a');
for(var k=0;k<intput3.length;k++)
{if(intput3[k].text =='Student/Alumni Login')
{intput3[k].click();}}}
// BUGGGGGGGGGGGGGGGGGG HERE with one entry - not affect performance, fix it later
// auto fill and login entry 1
if(url.indexOf("https://cap.mcmaster.ca/mcauth/login.jsp?") > -1)
{
if (username !== undefined)
{
document.getElementById("user_id").value = username;
document.getElementById("pin").value = password;
document.getElementsByClassName("btn btn-primary btn-arrow")[0].click();
}
}
// auto fill and login entry 2
if(url.indexOf(url.indexOf("https://sso.mcmaster.ca/idp/profile/SAML2/Redirect/SSO?execution=") > -1 ))
{
if (username !== undefined)
{
document.getElementById("username").value = username;
document.getElementById("password").value = password;
document.getElementsByClassName("btn btn-primary btn-arrow")[0].click();
}
}
// auto fill and login entry 3
if(url.indexOf(url.indexOf("https://sso.mcmaster.ca/shibboleth-idp/profile/SAML2/Redirect/SSO?execution=") > -1 ))
{
if (username !== undefined)
{
document.getElementById("username").value = username;
document.getElementById("password").value = password;
document.getElementsByClassName("btn btn-primary btn-arrow")[0].click();
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment