Last active
December 2, 2017 00:30
-
-
Save Ivanca/ba60581bdd2c9023a7ea1ecdaef366cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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