Widget:RemoveParserOutputParentDiv: Difference between revisions

From Tsadra Commons
((by SublimeText.Mediawiker))
((by SublimeText.Mediawiker))
 
Line 16: Line 16:
});
});
}
}
unwrapElementsByClass('mw-parser-output', 'remoteValue');
unwrapElementsByClass('mw-parser-output', 'remoteValue');
</script>
</script>

Latest revision as of 18:30, 14 February 2025

<script> function unwrapElementsByClass(className, parentId) { const container = document.getElementById(parentId); if (!container) return;

const elements = container.getElementsByClassName(className);

// Convert to array since we'll be modifying the live HTMLCollection Array.from(elements).forEach(element => { // Move all children before the wrapper while (element.firstChild) { element.parentNode.insertBefore(element.firstChild, element); } // Remove the empty wrapper element.parentNode.removeChild(element); }); } unwrapElementsByClass('mw-parser-output', 'remoteValue'); </script>