Reddit Infinite Scrolling

Adds infinite scrolling to subreddits and to comments.

当前为 2018-04-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Reddit Infinite Scrolling
  3. // @namespace darkred
  4. // @author darkred
  5. // @license MIT
  6. // @description Adds infinite scrolling to subreddits and to comments.
  7. // @version 2018.4.25
  8. // @include https://www.reddit.com/*
  9. // @include https://old.reddit.com/*
  10. // @grant unsafeWindow
  11. // @require http://code.jquery.com/jquery-2.1.4.min.js
  12. // @require https://greasyfork.org/scripts/11636-jscroll/code/jScroll.js
  13. // ==/UserScript==
  14.  
  15. // Jscroll code
  16. $('#siteTable').jscroll({
  17. nextSelector: 'span.nextprev a:last',
  18. contentSelector: '#siteTable .thing, .nav-buttons',
  19. callback: function() {
  20. $('.nav-buttons').remove();
  21. }
  22. });
  23.  
  24.  
  25. //if current URL contains the string 'comments', then click the 'more comments' button when scrolling at the end of the page
  26. if (/(.*comments.*)/.test(document.location)) {
  27. $(window).scroll(function() {
  28. if ($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
  29. // console.log('bottom!');
  30. var element = unsafeWindow.document.getElementsByClassName('morecomments');
  31. var last = element.length;
  32. element[last - 1].firstChild.click();
  33. }
  34. });
  35. }