Skip to content

Instantly share code, notes, and snippets.

@syousif94
Created October 15, 2019 03:37
Show Gist options
  • Save syousif94/b18d0c9bdf583788f9fc6d9eeda2bcf0 to your computer and use it in GitHub Desktop.
Save syousif94/b18d0c9bdf583788f9fc6d9eeda2bcf0 to your computer and use it in GitHub Desktop.
infinite reddit
function run() {
console.log('sup')
$('#siteTable').jscroll({
nextSelector: 'span.nextprev a:last',
contentSelector: '#siteTable .thing, .nav-buttons',
callback: function() {
$('.nav-buttons').remove();
}
});
//if current URL contains the string 'comments', then click the 'more comments' button when scrolling at the end of the page
if (/(.*comments.*)/.test(document.location)) {
$(window).scroll(function() {
if ($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
// console.log('bottom!');
var element = unsafeWindow.document.getElementsByClassName('morecomments');
var last = element.length;
element[last - 1].firstChild.click();
}
});
}
}
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment