Bamp (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Bamp (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung Markierung: Zurückgesetzt |
||
Zeile 21: | Zeile 21: | ||
}).done(function(data) { | }).done(function(data) { | ||
if (data.includes("disabled")) return; | if (data.includes("disabled")) return; | ||
$('#mw-content-text').prepend('<div class="global-message" style="margin-bottom: 10px">' + removeUnusedStuff(data) + '</div>'); | $('#mw-content-text').prepend('<div class="global-message" style="margin-bottom: 10px">' + removeUnusedStuff(data) + '</div>'); //Citizen, Vector 2010, Vector 2022 | ||
$('#bodyContent').prepend('<div class="global-message" style="margin-bottom: 10px">' + removeUnusedStuff(data) + '</div>'); //MinervaNeue | |||
}); | }); | ||
} | } |
Version vom 5. August 2023, 14:55 Uhr
/* Das folgende JavaScript wird für Benutzer aller Skins geladen */ function removeUnusedStuff(html) { const tempElement = document.createElement('div'); tempElement.innerHTML = html; if (tempElement.querySelector('div')) { tempElement.querySelector('div').remove(); } const lastParagraph = tempElement.querySelectorAll('p')[tempElement.querySelectorAll('p').length - 1]; if (lastParagraph) { lastParagraph.remove(); } return tempElement.innerHTML; } function loadGlobalMessage() { // Überprüfe, ob die Meldung bereits auf der aktuellen Seite geladen wurde if (!$('.global-message').length) { $.ajax({ url: mw.util.getUrl('MediaWiki:GlobalMessage', { action: 'render' }), // action=render, um nur den Inhalt zu erhalten dataType: 'html' }).done(function(data) { if (data.includes("disabled")) return; $('#mw-content-text').prepend('<div class="global-message" style="margin-bottom: 10px">' + removeUnusedStuff(data) + '</div>'); //Citizen, Vector 2010, Vector 2022 $('#bodyContent').prepend('<div class="global-message" style="margin-bottom: 10px">' + removeUnusedStuff(data) + '</div>'); //MinervaNeue }); } } loadGlobalMessage();