Reddit Infinite Scrolling

Adds infinite scrolling to subreddits and to comments.

当前为 2016-08-19 提交的版本,查看 最新版本

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