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