75 lines
2.5 KiB
JavaScript
75 lines
2.5 KiB
JavaScript
// ==UserScript==
|
|
// @name academyFIVE::AddSelectBox
|
|
// @namespace dakp/academyfive
|
|
// @version 2026.04.002
|
|
// @description Füge Selectbox für Kohorten/Planungsgruppen hinzu
|
|
// @author Dims Akpan
|
|
// @match https://a5.fhdw-hannover.de/*
|
|
// @match https://a5.fhdw.de/*
|
|
// @match https://fhdw.academyfive-preview.net/*
|
|
// @match https://fhdw-hannover.academyfive-preview.net/*
|
|
// @grant none
|
|
// @icon https://www.academyfive.com/typo3conf/ext/sitepackage/Resources/Public/build/assets/images/favicon-academyfive.ico
|
|
// ==/UserScript==
|
|
|
|
(function() {
|
|
'use strict';
|
|
|
|
function getDropdownSelector() {
|
|
const url = window.location.href;
|
|
if (url.includes('/course/planning-group/list')) {
|
|
return 'select[name="cohort-ids[]"]';
|
|
}
|
|
if (url.includes('/course/list')) {
|
|
return 'select[name="planningGroupIds[]"]';
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function addSelectButtons() {
|
|
const selector = getDropdownSelector();
|
|
if (!selector) return;
|
|
|
|
const dropdown = document.querySelector(selector);
|
|
|
|
if (!dropdown) {
|
|
console.log('Dropdown nicht gefunden:', selector);
|
|
return;
|
|
}
|
|
|
|
const dropdownContainer = dropdown.closest('.btn-group.bootstrap-select');
|
|
const searchBox = dropdownContainer?.querySelector('.bs-searchbox');
|
|
|
|
if (!searchBox) {
|
|
console.log('Searchbox nicht gefunden');
|
|
return;
|
|
}
|
|
|
|
// Prüfe ob schon vorhanden
|
|
if (searchBox.nextElementSibling?.classList.contains('bs-actionsbox')) {
|
|
console.log('Select/Deselect Buttons bereits vorhanden');
|
|
return;
|
|
}
|
|
|
|
const actionsBox = document.createElement('div');
|
|
actionsBox.className = 'bs-actionsbox';
|
|
actionsBox.innerHTML = `
|
|
<div class="btn-group btn-group-sm btn-block">
|
|
<button type="button" class="actions-btn bs-select-all btn btn-default">Alles auswählen</button>
|
|
<button type="button" class="actions-btn bs-deselect-all btn btn-default">Nichts auswählen</button>
|
|
</div>
|
|
`;
|
|
|
|
searchBox.insertAdjacentElement('afterend', actionsBox);
|
|
|
|
console.log('Select/Deselect Buttons erfolgreich eingefügt');
|
|
}
|
|
|
|
// Versuche es direkt
|
|
addSelectButtons();
|
|
|
|
// Falls das Element noch nicht da ist, warte auf DOMContentLoaded
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', addSelectButtons);
|
|
}
|
|
})(); |