TUM Everywere Login BETA

Adds redirection and automated login for tum.moodle.de. Also performs login process on Shibboleth-LRZ with your TUM (Technnische Universitaet Muenchen) credentials.

As of 2017-10-11. See the latest version.

// ==UserScript==
// @name            TUM Everywere Login BETA
// @version         0.1
// @description     Adds redirection and automated login for tum.moodle.de. Also performs login process on Shibboleth-LRZ with your TUM (Technnische Universitaet Muenchen) credentials. 
// @author          zsewa
// @namespace       https://greasyfork.org/users/57483

// @match           https://greasyfork.org/de/scripts/34008-tum-everywere-login-beta
// @match           https://www.moodle.tum.de/
// @match           https://tumidp.lrz.de/idp/profile/SAML2/Redirect/SSO*

// @require         https://code.jquery.com/jquery-3.1.0.min.js

// @grant GM_setValue
// @grant GM_getValue
// @grant GM_registerMenuCommand
// @grant GM_openInTab
// ==/UserScript==



(function() {
    //check if credentials are saved, triggered on first startup
    if(GM_getValue('tel_credentials', 0) === 0){
        first_startup();
    }
    
    //getting values for webpage check
    var domain = location.href;
    
    //__Page redirect or login function__
    //Set-Up Page
    if(domain.indexOf('greasyfork.org/de/scripts/34008-tum-everywere-login-beta') != -1){
        alert('Startup');
    }

    //TUM-Moodle Startpage
    if(domain.indexOf('https://www.moodle.tum.de/') != -1){
        location.href='https://www.moodle.tum.de/Shibboleth.sso/Login?providerId=https%3A%2F%2Ftumidp.lrz.de%2Fidp%2Fshibboleth&target=https%3A%2F%2Fwww.moodle.tum.de%2Fauth%2Fshibboleth%2Findex.php';
    }
    
    //Shibboleth Login on LRZ
    if(domain.indexOf('tumidp.lrz.de/idp/profile/SAML2') != -1){
        login_via_shibboleth();
    }
    
})();


function first_startup() {
    //set-up dialog
    alert('Welcome. You triggered "TUM Everywere Login BETA" for the first time. The setup-page will now open in a new tab.');
    GM_openInTab( 'www.google.com', true );
}

function login_via_shibboleth() {
    var username = '###';
    var password = '###';
    
    $('input#username').val(username);
    $('input#password').val(password);
    $('button.btnLogin').click();
}