Last active
April 11, 2021 14:20
-
-
Save kvn1351/719fc70fc804d68d8f70d5f225bc9599 to your computer and use it in GitHub Desktop.
Ilias Autologin [Tampermonkey]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Ilias Autologin | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description 1337 | |
// @author kvn1351 | |
// @icon https://www.google.com/s2/favicons?domain=unibe.ch | |
// @downloadURL https://gist.github.com/kvn1351/719fc70fc804d68d8f70d5f225bc9599/raw/55c02529faa5d38b82e373c9e58399d8ed876c82/ilias.user.js | |
// @grant none | |
// @run-at document-end | |
// @include https://ilias.unibe.ch/login* | |
// @include https://aai-idp.unibe.ch/idp/profile/SAML2/Redirect/* | |
// ==/UserScript== | |
const USER_NAME = 'kvn'; | |
const PASSWORD = '123'; | |
const UNI = 'Universität Bern'; | |
(function() { | |
'use strict'; | |
window.addEventListener("load", () => { | |
const iliasLogin = () => { | |
let field = document.getElementById('user_idp_iddtext'); | |
field.value = UNI; | |
document.getElementById('wayf_submit_button').click(); | |
}; | |
const unibeLogin = () => { | |
document.getElementById('username').value = USER_NAME; | |
document.getElementById('password').value = PASSWORD; | |
//check if there's a login error before clicking. This is to prevent infinite sign-in attempts. | |
if (!document.getElementsByClassName('login_error').length){ | |
document.getElementsByClassName('aai_login_button')[0].click(); | |
} | |
}; | |
if (document.URL.match(/.*ilias.unibe.*/i)) { | |
iliasLogin(); | |
} | |
else if (document.URL.match(/.*aai-idp.unibe.*/i)) { | |
unibeLogin(); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment