initial commit
This commit is contained in:
commit
bdcbd3d3aa
5 changed files with 222 additions and 0 deletions
127
autologin_at_ed.js
Normal file
127
autologin_at_ed.js
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
// ==UserScript==
|
||||
// @name AutoLogin@Ed
|
||||
// @namespace https://git.js0ny.net/
|
||||
// @version 0.2
|
||||
// @description Auto Login on University of Edinburgh websites
|
||||
// @author js0ny
|
||||
// @match *://edadfed.ed.ac.uk/*
|
||||
// @match *://login.microsoftonline.com/login.srf*
|
||||
// @match *://www.ease.ed.ac.uk/*
|
||||
// @match *://www.myed.ed.ac.uk/*
|
||||
// @match *://www.learn.ed.ac.uk/*
|
||||
// @match *://www.ed.ac.uk/*
|
||||
// @match *://www.wiki.ed.ac.uk/*
|
||||
// @icon https://www.google.com/s2/favicons?sz=64&domain=ed.ac.uk
|
||||
// @grant none
|
||||
// @noframes
|
||||
// ==/UserScript==
|
||||
// Forked from: Jiaxun Yang's original script
|
||||
|
||||
// FILL YOUR CREDENTIALS HERE
|
||||
var uun = "";
|
||||
var password = "";
|
||||
|
||||
(function() {
|
||||
|
||||
if (uun == "" || password == "") {
|
||||
alert("Please fill your credentials")
|
||||
return;
|
||||
}
|
||||
|
||||
// OAuth Redirection
|
||||
if (location.hostname === "edadfed.ed.ac.uk") {
|
||||
// alert("Debug");
|
||||
document.getElementById("userNameInput").value = uun + "@ed.ac.uk";
|
||||
document.getElementById("passwordInput").value = password;
|
||||
document.getElementById("submitButton").click();
|
||||
}
|
||||
|
||||
|
||||
// OAuth Microsoft Page
|
||||
if (location.href.startsWith("https://login.microsoftonline.com/login.srf")) {
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
const DELAY_MS = 3000;
|
||||
|
||||
setTimeout(function() {
|
||||
const titleElement = document.getElementById('appConfirmTitle');
|
||||
if (titleElement.textContent.includes("Do you trust ed.ac.uk?")) {
|
||||
document.getElementById("idSIButton9").click();
|
||||
}
|
||||
}, DELAY_MS);
|
||||
|
||||
})();
|
||||
}
|
||||
|
||||
// For ease login page
|
||||
if (location.hostname === "www.ease.ed.ac.uk") {
|
||||
|
||||
|
||||
// Input UUN
|
||||
if (location.pathname === "/cosign.cgi") {
|
||||
document.getElementById("login").value = uun;
|
||||
document.getElementById("submit").click();
|
||||
}
|
||||
|
||||
// Input password
|
||||
if (location.pathname === "/login/") {
|
||||
document.getElementById("password").value = password;
|
||||
document.getElementById("submit").click();
|
||||
}
|
||||
}
|
||||
|
||||
if (location.hostname === "www.myed.ed.ac.uk") {
|
||||
// MyEd use React to generate this element, so we must use observer
|
||||
function waitForElm(elmId) {
|
||||
return new Promise(resolve => {
|
||||
if (document.getElementById(elmId)) {
|
||||
return resolve(document.getElementById(elmId));
|
||||
}
|
||||
|
||||
const observer = new MutationObserver(mutations => {
|
||||
if (document.getElementById(elmId)) {
|
||||
resolve(document.getElementById(elmId));
|
||||
observer.disconnect();
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
waitForElm('login-btn').then((btn) => {
|
||||
btn.click();
|
||||
});
|
||||
}
|
||||
|
||||
if (location.hostname === "www.learn.ed.ac.uk") {
|
||||
// Hanlde Login button on homepage
|
||||
const div = document.getElementsByClassName('easelogin-bt');
|
||||
if (div) {
|
||||
div.item(0).click();
|
||||
}
|
||||
// Handle login button on login page
|
||||
const div1 = document.getElementById('ease');
|
||||
if (div1) {
|
||||
div1.getElementsByTagName('a')[0].click();
|
||||
}
|
||||
}
|
||||
|
||||
if (location.hostname === "www.ed.ac.uk") {
|
||||
const loginLinkElm = document.getElementsByClassName('footer-login-link');
|
||||
if (loginLinkElm) {
|
||||
loginLinkElm.item(0).href.click()
|
||||
}
|
||||
}
|
||||
|
||||
if (location.hostname === "www.wiki.ed.ac.uk") {
|
||||
const loginLinkElm = document.getElementById('login-link');
|
||||
if (loginLinkElm) {
|
||||
loginLinkElm.click()
|
||||
}
|
||||
}
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue