Widget:Parser debug info
From Notaclue Wiki
Widget to show parser debug comments.
Loading...
<script> const showDebugInfo = () => {
const displayElement = document.getElementById('parser-debug-info');
const parserOutput = document.querySelector('.mw-parser-output');
const getComments = ( elem ) => {
let comments = [];
for (let iii = 0; iii < elem.childNodes.length; iii++) {
const node = elem.childNodes[iii];
if (node.nodeType === elem.COMMENT_NODE) {
comments.push(node);
} else {
comments.push( ...getComments(node) );
}
}
return comments;
};
const parserComments = getComments(parserOutput).map(c => c.textContent).join('\n');
displayElement.textContent = parserComments.trim();
}; document.addEventListener( 'DOMContentLoaded', showDebugInfo ); </script>