Disable pull to refresh

Disables pull to refresh

  1. // ==UserScript==
  2. // @name Disable pull to refresh
  3. // @namespace disablepullrefresh
  4. // @match *
  5. // @grant none
  6. // @version 1.7
  7. // @run-at document-end
  8. // @author ab498
  9. // @description Disables pull to refresh
  10. // ==/UserScript==
  11.  
  12. let startY = null;
  13.  
  14. document.addEventListener('touchstart', function(event) {
  15. // Record the starting Y position of the touch event
  16. startY = event.touches[0].clientY;
  17. }, { passive: true });
  18.  
  19. document.addEventListener('touchmove', function(event) {
  20. if (startY !== null && event.touches.length > 0) {
  21. // Calculate the distance moved in the Y direction
  22. let deltaY = event.touches[0].clientY - startY;
  23. console.log('deltaY',deltaY);
  24. // Check if the user is at the top of the page and scrolling downwards
  25. if (window.pageYOffset === 0 && deltaY > 0) {
  26. // Prevent the default action (e.g., pull-to-refresh)
  27. event.preventDefault();
  28. }
  29.  
  30. // Update the starting Y position for the next touchmove event
  31. startY = event.touches[0].clientY;
  32. }
  33. }, { passive: false });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址