Skip to content

Instantly share code, notes, and snippets.

@Ivanca
Last active December 2, 2017 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ivanca/ba60581bdd2c9023a7ea1ecdaef366cc to your computer and use it in GitHub Desktop.
Save Ivanca/ba60581bdd2c9023a7ea1ecdaef366cc to your computer and use it in GitHub Desktop.
(function ajaxLoadNextPage () {
var more = document.querySelector('.comment-tree > tbody > tr:last-child a');
if (more && more.innerHTML === "More") {
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState === XMLHttpRequest.DONE) {
if (httpRequest.status === 200) {
more.remove();
var div = document.createElement('div');
div.innerHTML = httpRequest.responseText;
var nextHTML = div.querySelector('.comment-tree > tbody').innerHTML;
document.querySelector('.comment-tree > tbody').innerHTML += nextHTML;
ajaxLoadNextPage();
} else {
alert('There was a problem with the request to ' + more.href);
}
}
};
httpRequest.open('GET', more.href);
httpRequest.send();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment