Reddit jScroll

adds infinite scrolling to Reddit subreddits, eg, https://www.reddit.com/r/technology/

当前为 2015-08-17 提交的版本,查看 最新版本

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