Reddit Infinite Scrolling

Adds infinite scrolling to subreddits and to comments.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==UserScript==
// @name        Reddit Infinite Scrolling
// @namespace   darkred
// @version     2018.4.25
// @description Adds infinite scrolling to subreddits and to comments.
// @author      darkred
// @license     MIT
// @include     https://www.reddit.com/*
// @include     https://old.reddit.com/*
// @grant       unsafeWindow
// @require     http://code.jquery.com/jquery-2.1.4.min.js
// @require     https://cdnjs.cloudflare.com/ajax/libs/jscroll/2.4.1/jquery.jscroll.min.js
// @supportURL  https://github.com/darkred/Userscripts/issues
// ==/UserScript==

// Jscroll code
$('#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();
		}
	});
}