getComments
by Victor
HTML
<script src="https://cdn.rawgit.com/victornpb/getComments.js/e712264f75bceabd90fa62d049a16b57549ef234/getComments.js"></script>
<a href="https://github.com/victornpb/getComments.js">https://github.com/victornpb/getComments.js</a>
<!-- a -->
<!-- b -->
<!-- c -->
<!-- test 1 -->
<!-- foo -->
<!-- test 2 -->
<!-- bar -->
<!-- test 3 -->
<!-- hi -->
<!--
hello
world!
-->
JavaScript
//examples
//get all comments
console.log(getComments());
//get all comments in a element
console.log(getComments(document.body));
//get the first comment that match a regex pattern
console.log(getComments(document, /test/));
//get the first comment is filtered by a function
console.log(getComments(document, function(text, comment) {
this.breakOnFirst = true;
return text.match(/test/) !== null;
}));
//get all comments that match a regex pattern
console.log(getComments(document, /test/g));
//get all comments filtered by a function
console.log(getComments(document, function(text, comment) {
return text.match(/test/) !== null;
}));