From de8ebbbc32a6d5fcfa802f8b672ca42d42015423 Mon Sep 17 00:00:00 2001
From: Rsge <rsge@web.de>
Date: Sun, 8 Dec 2024 22:06:54 +0100
Subject: [PATCH] Added support for Surfmail & fixed login.uni-hamburg

---
 README.md                       |  9 ++++++++-
 Uni Hamburg Auto Logins.user.js | 19 ++++++++++++++++---
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 6488c67..c7770c2 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,16 @@
 # Uni Hamburg Auto Logins
 
-
 Automatically logs you in to a few different Uni Hamburg sites, given the login data is provided automatically or input manually.
 
 ---
 
 Loggt Dich automatisch in verschiedene Seiten der Uni Hamburg ein, gegeben, dass die Login-Daten automatisch ausgefüllt oder manuell eingegeben werden.
 
+---
+
+### Supported Sites / Unterstützte Seiten
+
+* Moodle
+* OpenOlat
+* STiNE
+* Surfmail (Uni-Mail)
\ No newline at end of file
diff --git a/Uni Hamburg Auto Logins.user.js b/Uni Hamburg Auto Logins.user.js
index a7d0c62..287bef5 100644
--- a/Uni Hamburg Auto Logins.user.js	
+++ b/Uni Hamburg Auto Logins.user.js	
@@ -5,7 +5,7 @@
 // @description    Automatically logs you in to a few different Uni Hamburg sites, given automated password filling.
 // @description:de Loggt Dich automatisch in verschiedene Seiten der Uni Hamburg ein, gegeben, dass die Login-Daten automatisch ausgefüllt werden.
 
-// @version        2.1.2
+// @version        2.2.0
 // @copyright      2023+, Jan G. (Rsge)
 // @license        Mozilla Public License 2.0
 // @icon           https://www.uni-hamburg.de/favicon.ico
@@ -14,7 +14,7 @@
 // @homepageURL    https://github.com/Rsge/Uni-Hamburg-Auto-Login
 // @supportURL     https://github.com/Rsge/Uni-Hamburg-Auto-Login/issues
 // @downloadURL    https://update.greasyfork.org/scripts/481691/Uni%20Hamburg%20Auto%20Logins.user.js
-// @updateURL      https://update.greasyfork.org/scripts/481691/Uni%20Hamburg%20Auto%20Logins.user.js
+// @updateURL      https://update.greasyfork.org/scripts/481691/Uni%20Hamburg%20Auto%20Logins.meta.js
 
 // @match          https://lernen.min.uni-hamburg.de/login/*
 // @match          https://www.openolat.uni-hamburg.de/dmz/*
@@ -22,6 +22,7 @@
 // @match          https://stine.uni-hamburg.de/scripts/*
 // @match          https://www.stine.uni-hamburg.de/scripts/*
 // @match          https://cndsf.ad.uni-hamburg.de/IdentityServer/Account/*
+// @match          https://surfmail.rrz.uni-hamburg.de/login.php?*
 
 // @run-at         document-end
 // @grant          none
@@ -43,12 +44,14 @@
 
   // Carries out login sequence.
   window.addEventListener('load', function() {
+    // -- Moodle --
     // lernen.min.uni-hamburg.de
     let lernenMINLoginButtons = document.getElementsByClassName("btn login-identityprovider-btn btn-primary btn-lg btn-block");
     if (lernenMINLoginButtons.length > 0) {
       lernenMINLoginButtons[0].click();
       return;
     }
+    // -- OpenOlat --
     // openolat.uni-hamburg.de
     let openOlatLoginButtonDivs = document.getElementsByClassName("o_block");
     if (openOlatLoginButtonDivs.length > 0) {
@@ -66,13 +69,15 @@
       }, 800);
       return;
     }*/
+    // -- Moodle & OpenOlat --
     // login.uni-hamburg.de
-    let loginLoginButtons = document.getElementsByClassName("form-element form-button");
+    let loginLoginButtons = document.getElementsByName("_eventId_proceed");
     if (loginLoginButtons.length > 0) {
       let pwdInput = document.getElementById("password");
       checkPwdLogin(pwdInput, loginLoginButtons[0]);
       return;
     }
+    // -- STiNE --
     // stine.uni-hamburg.de
     let stineOpenLoginButton = document.getElementById("logIn_btn");
     if (stineOpenLoginButton) {
@@ -86,5 +91,13 @@
       checkPwdLogin(pwdInput, campusNetLoginButtons[0]);
       return;
     }
+    // -- Uni-Mail --
+    // surfmail.rrz.uni-hamburg.de
+    let surfmailLogInLoginButton = document.getElementById("login-button");
+    if (surfmailLogInLoginButton) {
+      let pwdInput = document.getElementById("horde_pass");
+      checkPwdLogin(pwdInput, surfmailLogInLoginButton);
+      return;
+    }
   }, false);
 })();
-- 
GitLab