Logging hinzugefügt
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name academyFIVE::AddSelectBox
|
||||
// @namespace dakp/academyfive
|
||||
// @version 2026.04.005
|
||||
// @version 2026.04.006
|
||||
// @description Füge Selectbox für Kohorten/Planungsgruppen hinzu
|
||||
// @author Dims Akpan
|
||||
// @match https://a5.fhdw-hannover.de/*
|
||||
@@ -15,20 +15,32 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
const LOG = '[A5-SelectBox]';
|
||||
|
||||
// ─── Gemeinsame Hilfsfunktionen ───────────────────────────────────────────
|
||||
|
||||
function insertSelectButtons(selectSelector) {
|
||||
const select = document.querySelector(selectSelector);
|
||||
if (!select) return false;
|
||||
if (!select) {
|
||||
console.log(LOG, 'select nicht gefunden:', selectSelector);
|
||||
return false;
|
||||
}
|
||||
|
||||
const dropdownContainer = select.closest('.btn-group.bootstrap-select');
|
||||
if (!dropdownContainer) return false;
|
||||
if (!dropdownContainer) {
|
||||
console.log(LOG, 'closest(.btn-group.bootstrap-select) nicht gefunden');
|
||||
return false;
|
||||
}
|
||||
|
||||
const searchBox = dropdownContainer.querySelector('.bs-searchbox');
|
||||
if (!searchBox) return false;
|
||||
if (!searchBox) {
|
||||
console.log(LOG, '.bs-searchbox nicht gefunden im Container');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (searchBox.nextElementSibling?.classList.contains('bs-actionsbox')) {
|
||||
return true; // bereits vorhanden
|
||||
console.log(LOG, 'Buttons bereits vorhanden, überspringe');
|
||||
return true;
|
||||
}
|
||||
|
||||
const actionsBox = document.createElement('div');
|
||||
@@ -41,27 +53,36 @@
|
||||
`;
|
||||
|
||||
searchBox.insertAdjacentElement('afterend', actionsBox);
|
||||
console.log('Select/Deselect Buttons eingefügt für:', selectSelector);
|
||||
console.log(LOG, 'Buttons erfolgreich eingefügt für:', selectSelector);
|
||||
return true;
|
||||
}
|
||||
|
||||
function waitAndInsert(tryFn) {
|
||||
console.log(LOG, 'waitAndInsert gestartet | readyState:', document.readyState, '| URL:', window.location.href);
|
||||
|
||||
if (tryFn()) return;
|
||||
|
||||
console.log(LOG, 'Erster Versuch fehlgeschlagen, starte Observer + Polling');
|
||||
|
||||
const observer = new MutationObserver(() => {
|
||||
if (tryFn()) observer.disconnect();
|
||||
if (tryFn()) {
|
||||
console.log(LOG, 'Observer: Buttons eingefügt, Observer beendet');
|
||||
observer.disconnect();
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(document.body, { childList: true, subtree: true });
|
||||
|
||||
// Polling für initialen Seitenaufruf (Bootstrap Select initialisiert sich
|
||||
// asynchron nach DOMContentLoaded)
|
||||
let attempts = 0;
|
||||
const poll = setInterval(() => {
|
||||
attempts++;
|
||||
if (tryFn() || attempts >= 50) {
|
||||
if (tryFn()) {
|
||||
console.log(LOG, 'Polling: Buttons eingefügt nach', attempts, 'Versuchen');
|
||||
clearInterval(poll);
|
||||
if (attempts >= 50) observer.disconnect();
|
||||
} else if (attempts >= 50) {
|
||||
console.log(LOG, 'Polling: Timeout nach 50 Versuchen');
|
||||
clearInterval(poll);
|
||||
observer.disconnect();
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
@@ -90,11 +111,14 @@
|
||||
|
||||
function init() {
|
||||
const url = window.location.href;
|
||||
console.log(LOG, 'init() | URL:', url);
|
||||
|
||||
if (url.includes('/course/planning-group/list')) {
|
||||
planningGroupList_init();
|
||||
} else if (url.includes('/course/list')) {
|
||||
courseList_init();
|
||||
} else {
|
||||
console.log(LOG, 'URL passt zu keiner bekannten Seite, Script inaktiv');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user