User:InvalidOS/ShowComments.js

importStylesheet('User:InvalidOS/ShowComments.css');

function filterNone {   return NodeFilter.FILTER_ACCEPT; }

// comment node NodeType is 8

function getCommentInfo {   var comments = ; // Fourth argument, which is actually obsolete according to the DOM4 standard, is required in IE 11 // Thanks stack overflow // var iterator = document.createNodeIterator(document.getElementById("mw-content-text"), NodeFilter.SHOW_COMMENT, filterNone, false); var el = document.getElementById("mw-content-text"); // var curNode; /*   while (curNode = iterator.nextNode) {       var arrayToPush = []; arrayToPush[0] = curNode; arrayToPush[1] = curNode.textContent; comments.push(arrayToPush); }   */    var node; var push; // thanks to stack overflow for helping me find this for (var i = 0; i < el.childNodes.length; i++) {       node = el.childNodes[i]; push = []; if (node.nodeType === 8) {           console.log("Node " + i.toString +  "is a comment."); console.log("Node value: " + node.nodeValue.toString); pushArr = [node, node.nodeValue.toString]; comments.push(pushArr); }       else {           console.log("Node " + i.toString +  "not a comment."); }   }    return comments; }

$(document).ready(function {	var commentInfo = getCommentInfo;	for (x = 0; x < commentInfo.length; x++)	{		commentInfo[x][0].OuterHTML = ' &lt;!--' + commentInfo[x][1] + '--&rt; ';	} });

/*$(document).ready(renderComments);*/