(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