-
Notifications
You must be signed in to change notification settings - Fork 5
/
tuwien-autologin.user.js
72 lines (64 loc) · 2.1 KB
/
tuwien-autologin.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// ==UserScript==
// @name Autologin for TU Wien SSO, TISS, TUWEL and OpenCast
// @namespace https://vowi.fsinf.at/
// @include https://tiss.tuwien.ac.at/*
// @include https://tuwel.tuwien.ac.at/*
// @include https://oc-presentation.ltcc.tuwien.ac.at/*
// @match https://idp.zid.tuwien.ac.at/simplesaml/module.php/core/loginuserpass.php
// @match https://toss.fsinf.at/
// @grant none
// @version 1.7
// @downloadURL https://fsinf.at/userscripts/tuwien-autologin.user.js
// @updateURL https://fsinf.at/userscripts/tuwien-autologin.user.js
// ==/UserScript==
function tuwelRefreshSession() {
setTimeout(function() {
fetch("https://tuwel.tuwien.ac.at/my/", {method: "HEAD"});
tuwelRefreshSession();
}, 15*60*1000);
}
async function openCastAutoLogin(){
let response = await fetch('/info/me.json');
if (response.ok){
let info = await response.json();
if (info.user.username == 'anonymous'){
localStorage.returnURL = location.toString();
window.location = 'https://tuwel.tuwien.ac.at/mod/lti/launch.php?id=385097';
}
}
}
switch(location.host){
case 'idp.zid.tuwien.ac.at':
if (document.querySelector('input[name="password"]').value)
document.querySelector('input[name="password"]').form.submit()
break;
case 'tiss.tuwien.ac.at':
if (document.getElementsByClassName("loading").length > 0) {
// Don't run the script on sites which only contain the loading animation.
return;
}
login = document.querySelector(".toolLogin");
if (login != null) {
login.click();
}
break;
case 'tuwel.tuwien.ac.at':
if (location.pathname == "/theme/university_boost/login/index.php") {
document.querySelector("a[title='TU Wien Login']").click();
} else {
tuwelRefreshSession();
}
break;
case 'oc-presentation.ltcc.tuwien.ac.at':
if (location.search == '?epFrom=d264f820-6d51-4cb1-a4f2-bb74e2094149&e=1&p=1' && localStorage.returnURL){
let returnURL = localStorage.returnURL;
localStorage.removeItem('returnURL');
window.location = returnURL;
} else {
openCastAutoLogin();
}
break;
case 'toss.fsinf.at':
hasTES = true;
break;
}