Bamp (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Bamp (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
Zeile 3: | Zeile 3: | ||
function removeUnusedStuff(html) { | function removeUnusedStuff(html) { | ||
const tempElement = document.createElement('div'); | const tempElement = document.createElement('div'); | ||
tempElement.innerHTML = | tempElement.innerHTML = html; | ||
if (tempElement.querySelector('div')) { tempElement.querySelector('div').remove(); } | if (tempElement.querySelector('div')) { tempElement.querySelector('div').remove(); } |
Version vom 5. August 2023, 14:43 Uhr
/* Das folgende JavaScript wird für Benutzer des Citizen-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; } // Ü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) { $('#mw-content-text').prepend('<div class="global-message" style="margin-bottom: 10px">' + removeUnusedStuff(data) + '</div>'); }); }