unlimited scroll

scroll infinitely up and down

  1. // ==UserScript==
  2. // @name unlimited scroll
  3. // @namespace http://tampermonkey.net/
  4. // @version 6.9
  5. // @description scroll infinitely up and down
  6. // @author therandomdude
  7. // @match *://*/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. const contentDiv = document.createElement('div');
  16. contentDiv.style.width = '10000px';
  17. contentDiv.style.height = '10000px';
  18. document.body.appendChild(contentDiv);
  19.  
  20. window.addEventListener('scroll', function() {
  21. const scrollX = window.scrollX;
  22. const scrollY = window.scrollY;
  23.  
  24. if (scrollX + window.innerWidth >= contentDiv.offsetWidth) {
  25. contentDiv.style.width = (contentDiv.offsetWidth + window.innerWidth) + 'px';
  26. }
  27.  
  28. if (scrollY + window.innerHeight >= contentDiv.offsetHeight) {
  29. contentDiv.style.height = (contentDiv.offsetHeight + window.innerHeight) + 'px';
  30. }
  31. });
  32. })();