Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.

Support Moodle and 2FA #6

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
55 changes: 46 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,67 @@ This is a browser script, that performs an automatic login for the following TU
- [Mailbox@TUD](https://msx.tu-dresden.de/owa)
- [LSKOnline](https://lskonline.tu-dresden.de)
- [ShareLaTeX](https://tex.zih.tu-dresden.de)
- and any other service with the TUD Login Page
- [Moodle](https://tud.uni-leipzig.de/moodle2/)
- and any other service with the TUD Login Page (maybe something new comes soon).

## Installation
## Installation for use with an application or for manual input
1. Install [Tampermonkey](https://www.tampermonkey.net) for your browser
2. Download the [TUD-AutoLogin UserScript](https://raw.githubusercontent.com/spyfly/TUD-AutoLogin/master/script.user.js)
2. Download the [TUD-AutoLogin UserScript](https://raw.githubusercontent.com/FurTactics/TUD-AutoLogin/master/script.user.js)
3. Click the install button to complete the installation
4. Visit the [configuration page](https://tud-autologin.spyfly.xyz/configuration) after installing the script, to add your login credentials
5. (optional) You can use [2FAS Browser Extension](https://2fas.com/browser-extension/) to automate the entry, but confirmation on your phone will be required each time
6. Enjoy :partying_face:

## Configuration
Visit the [configuration page](https://tud-autologin.spyfly.xyz/configuration) after installing the script, to add your login credentials.
## Installation for those who want to forever forget about the existence of login pages (nothing manual)
1. Install [Tampermonkey](https://www.tampermonkey.net) for your browser
2. Download the [TUD-AutoLogin UserScript](https://raw.githubusercontent.com/FurTactics/TUD-AutoLogin/master/script_only_for_Geeks.user.js)
3. Click the install button to complete the installation
4. Visit the [configuration page](https://tud-autologin.spyfly.xyz/configuration) after installing the script, to add your login credentials
> You need a 32-digit secret code (Geheimschlüssel), which can be found in the [2FAS](https://2fas.com/) app or by decoding the QR code.
5. Enjoy more :partying_face:

**else:** check [Known Issues](https://github.com/FurTactics/TUD-AutoLogin/tree/master?tab=readme-ov-file#known-issues-and-faq) or open a [new issue](https://github.com/FurTactics/TUD-AutoLogin/issues).
## Compatibility
This script is compatible with any browser capable of supporting [Tampermonkey](https://www.tampermonkey.net) or [Greasemonkey (Firefox only)](https://addons.mozilla.org/de/firefox/addon/greasemonkey/)

Compatible Platforms:
- Windows
- Linux
- MacOS
- Android (tested with [Firefox Nightly](https://blog.mozilla.org/addons/2020/09/29/expanded-extension-support-in-firefox-for-android-nightly/))
- Android (tested with [Firefox Nightly](https://blog.mozilla.org/addons/2020/09/29/expanded-extension-support-in-firefox-for-android-nightly/) and [Kiwi](https://kiwibrowser.com/))
- iOS/iPadOS via [Custom Shortcut](https://www.icloud.com/shortcuts/b3bef7f4836d461fb73bc3a39f9e3411) (Safari only)

## Usage
Visit your favorite TUD websites and enjoy automatic login.

On iOS/iPadOS you will have to run the [Custom Shortcut](https://www.icloud.com/shortcuts/b3bef7f4836d461fb73bc3a39f9e3411) via the Share Menu in Safari.
On iOS/iPadOS you will have to run the Custom Shortcut via the Share Menu in Safari.

## Future Development and Issues
If you have improvement ideas or encounter issues with the script don't hesitate to open a [new issue](https://github.com/FurTactics/TUD-AutoLogin/issues). This could be a request for adding more supported services or reporting a bug.


## Future development and issues
If you have improvement ideas or encounter issues with the script don't hesitate to open a [new issue](https://github.com/spyfly/TUD-AutoLogin/issues). This could be a request for adding more supported services or reporting a bug.
## Known Issues and FAQ
<details>
<summary><b>No notifications</b></summary>
<p>
You don't see notifications from the configuration site after clicking the test button.
</p>
<b>Windows</b>
<p>
Try turning off do not disturb mode and allowing browser notifications.
</p>
<b>Mac OS</b>
<p>
<i>(unclear)</i> Try turning on notifications in your browser settings (<i>System Preferences > Notifications > Chrome or another Browswer</i>)
<a href="https://i.sstatic.net/bxqUA.png">check screenshot</a>.
</p>
</details>
<details>
<summary><b>Where is my 32-digit secret code?</b></summary>
<p>The best and most secure way to find a token is to look it up in the <a href="https://2fas.com/">2FAS</a> app. Long hold the <code>TU Dresden</code> card, then <code>edit</code>. You need a 32-digit key that needs to be copied.
</p>
</details>
<details>
<summary><b>If I don't use 2FAS?</b></summary>
<p>If you do not use 2FAS, then all similar applications should have a function for viewing the secret code. If not, you can install the <a href="https://2fas.com/">2FAS</a> app and export your <code>TU Dresden</code> entry there.</p>
</details>
81 changes: 54 additions & 27 deletions script.user.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
// ==UserScript==
// @name TUD AutoLogin
// @namespace http://tampermonkey.net/
// @version 0.3.5
// @description Stop wasting your time entering login credentials or pressing useless buttons!
// @author spyfly
// @website https://tud-autologin.spyfly.xyz/
// @match https://bildungsportal.sachsen.de/*
// @match https://idp2.tu-dresden.de/*
// @match https://jexam.inf.tu-dresden.de/*
// @match https://selma.tu-dresden.de/*
// @match https://exam.zih.tu-dresden.de/*
// @match https://exam2.zih.tu-dresden.de/*
// @match https://exam3.zih.tu-dresden.de/*
// @match https://qis.dez.tu-dresden.de/qisserver/*
// @match https://msx.tu-dresden.de/owa/auth/logon*
// @match https://lskonline.tu-dresden.de/lskonline/de/102.0.1*
// @match https://idp.tu-dresden.de/idp*
// @match https://tud-autologin.spyfly.xyz/configuration/
// @match https://tex.zih.tu-dresden.de/*
// @supportURL https://github.com/spyfly/TUD-AutoLogin/issues
// @updateURL https://raw.githubusercontent.com/spyfly/TUD-AutoLogin/master/script.user.js
// @grant GM_getValue
// @grant GM_setValue
// @name TUD AutoLogin
// @namespace https://tud-autologin.spyfly.xyz/
// @version 0.4.2
// @description Stop wasting your time entering login credentials or pressing useless buttons! (updated from spyfly)
// @description:de Verschwende keine Zeit mehr mit dem Eingeben von Anmeldedaten oder dem Drücken sinnloser Tasten!
// @description:ru Перестань тратить время на ввод данных или кликанье бесполезных кнопок!
// @author FurTactics
// @icon https://upload.wikimedia.org/wikipedia/commons/a/a3/Logo_TU_Dresden_small.svg
// @match https://bildungsportal.sachsen.de/*
// @match https://idp2.tu-dresden.de/*
// @match https://jexam.inf.tu-dresden.de/*
// @match https://selma.tu-dresden.de/*
// @match https://exam.zih.tu-dresden.de/*
// @match https://exam2.zih.tu-dresden.de/*
// @match https://exam3.zih.tu-dresden.de/*
// @match https://qis.dez.tu-dresden.de/qisserver/*
// @match https://msx.tu-dresden.de/owa/auth/logon*
// @match https://lskonline.tu-dresden.de/lskonline/de/102.0.1*
// @match https://idp.tu-dresden.de/idp*
// @match https://tud-autologin.spyfly.xyz/configuration/
// @match https://tex.zih.tu-dresden.de/*
// @match https://tud.uni-leipzig.de/moodle2/*
// @supportURL https://github.com/FurTactics/TUD-AutoLogin/issues
// @updateURL https://raw.githubusercontent.com/FurTactics/TUD-AutoLogin/master/script.user.js
// @downloadURL https://raw.githubusercontent.com/FurTactics/TUD-AutoLogin/master/script.user.js
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==

(async function () {
Expand All @@ -47,8 +51,10 @@
const isLskOnline = (window.location.host == "lskonline.tu-dresden.de");
const isTudIdp = (window.location.host == "idp.tu-dresden.de");
const isShareLatex = (window.location.host == "tex.zih.tu-dresden.de");
const isMoodle = (window.location.host == "tud.uni-leipzig.de")

const credentialsAvailable = (tud.username.length > 0 && tud.password.length > 0);
var stats;

if (isConfigPage) {
document.getElementById("notinstalled").remove();
Expand All @@ -60,6 +66,7 @@
username: document.getElementById("username").value,
password: document.getElementById("password").value
});
GM_setValue("stats", null);
alert("Configuration updated!")
});
} else if (isOpalLoginPage || isTudExamLoginPage) {
Expand Down Expand Up @@ -89,23 +96,28 @@
}
loginSelector.selectedIndex = loginIndex;

//Press Login Button
// Press Login Button
document.querySelector("button[name$='shibLogin']").click();
}
} else if (isTudLoginPage || isTudIdp) {
// We are on the TUD I2DP Page
const hasLoginField = (document.getElementById("username") != undefined);
const hasSecretField = (document.getElementById("fudis_otp_input") != undefined);

if (hasLoginField) {
// Try to fill in credentials
document.getElementById("username").value = tud.username;
document.getElementById("password").value = tud.password;
if (credentialsAvailable) {
document.getElementsByName("_eventId_proceed")[0].click();
GM_setValue("stats", GM_getValue("stats") + 1);
}
} else {
// Just press the continue button
document.getElementsByName("_eventId_proceed")[0].click();
}
if (hasSecretField) {
while (document.getElementById("fudis_otp_input").value.length < 6) {
await sleep(1500);
}
document.getElementsByName("_eventId_proceed")[0].click();
}
} else if (isJExam) {
// AutoLogin for JExam 5
Expand All @@ -116,6 +128,7 @@
document.getElementById("username").value = tud.username;
document.getElementById("password").value = tud.password;
if (credentialsAvailable) {
GM_setValue("stats", GM_getValue('stats') + 1);
document.getElementsByClassName("submit")[0].click();
}
}
Expand All @@ -128,12 +141,25 @@
document.getElementById("logIn_btn").click();
}
}
} else if (isMoodle) {
// AutoLogin for Moodle
if (window.location.pathname == "/moodle2/login/index.php") {
// Check if we are on the login page
document.querySelector('[href="https://tud.uni-leipzig.de/moodle2/auth/shibboleth/index.php"]').click();
} else {
//Go to the login page if we need to login
const loginBtn = document.querySelector('[href="https://tud.uni-leipzig.de/moodle2/login/index.php"]');
if (loginBtn) {
loginBtn.click();
}
}
} else if (isQisServer) {
//AutoLogin for QISServer
if (document.getElementsByClassName("loginuser").length >= 1) {
document.getElementsByClassName("loginuser")[0].value = tud.username;
document.getElementsByClassName("loginpass")[0].value = tud.password;
if (credentialsAvailable) {
GM_setValue("stats", GM_getValue('stats') + 1);
document.getElementsByClassName("submit")[0].click();
}
}
Expand All @@ -142,6 +168,7 @@
document.getElementById('username').value = tud.username;
document.getElementById('password').value = tud.password;
if (credentialsAvailable) {
GM_setValue("stats", GM_getValue('stats') + 1);
document.getElementsByClassName("signinbutton")[0].click();
}
} else if (isLskOnline) {
Expand Down
Loading