HighlightStudyRow - neues Script

This commit is contained in:
2026-10-07 12:21:38 +02:00
parent 8bd0ffb15b
commit 79430bbea4
+61
View File
@@ -0,0 +1,61 @@
// ==UserScript==
// @name academyFIVE::HighlightStudyRow
// @namespace dakp/academyfive
// @version 2026.10.003
// @description Hebt beim Hovern einer Zelle die gesamte <tr>-Zeile der Studiensemester-Tabelle (profil_studenten_edit.php4) per CSS hervor
// @author Dims Akpan
// @match https://a5.fhdw-hannover.de/admin/*
// @match https://a5.fhdw.de/admin/*
// @match https://fhdw.academyfive-preview.net/admin/*
// @match https://fhdw-hannover.academyfive-preview.net/admin/*
// @grant none
// @icon https://www.academyfive.com/typo3conf/ext/sitepackage/Resources/Public/build/assets/images/favicon-academyfive.ico
// ==/UserScript==
(function() {
'use strict';
const STYLE_CLASS = 'a5-row-hl';
const HOVER_COLOR = 'rgba(0, 120, 200, 0.12)';
// Reines CSS: Hover wird nativ vom Browser verfolgt
const style = document.createElement('style');
style.textContent = `
table.${STYLE_CLASS} tr:hover th,
table.${STYLE_CLASS} tr:hover td {
background-color: ${HOVER_COLOR} !important;
}
`;
(document.head || document.documentElement).appendChild(style);
// Studiensemester-Tabelle anhand typischer Eingabefelder erkennen
function isStudyTable(table) {
return !!table.querySelector('input[name*="hochschulsemester"], input[name*="fachsemester"], input[name*="as_gesamt"]');
}
function markTable(table) {
if (table.dataset.a5RowHl || table.classList.contains(STYLE_CLASS)) return;
table.dataset.a5RowHl = 'true';
table.classList.add(STYLE_CLASS);
}
function scanTables() {
document.querySelectorAll('table').forEach(table => {
if (isStudyTable(table)) markTable(table);
});
}
function onDocReady() {
scanTables();
// Für dynamisch nachgeladene Tabellen: Klassenzuweisung ist idempotent,
// daher dünner Observer mit kindList/childList.
new MutationObserver(scanTables)
.observe(document.documentElement, { childList: true, subtree: true });
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', onDocReady);
} else {
onDocReady();
}
})();