Skip to content

Instantly share code, notes, and snippets.

@kvn1351
Last active April 11, 2021 14:20
Show Gist options
  • Save kvn1351/719fc70fc804d68d8f70d5f225bc9599 to your computer and use it in GitHub Desktop.
Save kvn1351/719fc70fc804d68d8f70d5f225bc9599 to your computer and use it in GitHub Desktop.
Ilias Autologin [Tampermonkey]
// ==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