autoload tumblr post when scroll to the bottom of page for mobile

当滚动到接近页面底部时直接加载手机版tumblr信息

  1. // ==UserScript==
  2. // @name autoload tumblr post when scroll to the bottom of page for mobile
  3. // @description 当滚动到接近页面底部时直接加载手机版tumblr信息
  4. // @version 0.4
  5. // @include http://*.tumblr.com/*
  6. // @include https://*.tumblr.com/*
  7. // @author yechenyin
  8. // @namespace https://greasyfork.org/users/3586-yechenyin
  9. // @require https://code.jquery.com/jquery-1.11.2.min.js
  10. // ==/UserScript==
  11.  
  12. var $window = $(window);
  13. var scroll = function() {
  14. if ($window.scrollTop() + $window.height() > $('.post').slice(-5,-4).offset().top) {
  15. console.log('load_more_posts');
  16. $('#load_more_posts')[0].click();
  17. }
  18. };
  19.  
  20. var waiting = false;
  21. $(window).scroll(function () {
  22. if (waiting) {
  23. return;
  24. }
  25. waiting = true;
  26.  
  27. scroll();
  28.  
  29. setTimeout(function () {
  30. waiting = false;
  31. }, 1000);
  32. });