Restrict auto-refresh

Обновление на всех страницах откладывается по движению курсора/задержанию тапа на моб. устройстве

  1. // ==UserScript==
  2. // @name Restrict auto-refresh
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.2
  5. // @description Обновление на всех страницах откладывается по движению курсора/задержанию тапа на моб. устройстве
  6. // @author Something begins
  7. // @license none
  8. // @include /^https{0,1}:\/\/((www|my)\.(heroeswm|lordswm)\.(ru|com)|178\.248\.235\.15)\/.+/
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=heroeswm.ru
  10. // @grant none
  11. // ==/UserScript==
  12. const timeout = 3;
  13.  
  14. (function() {
  15. if (!Delta) return;
  16. document.addEventListener("mousemove", event =>{
  17. if (Delta <= timeout) Delta = timeout;
  18. });
  19. document.addEventListener("scroll", event =>{
  20. if (Delta <= timeout) Delta = timeout;
  21. });
  22. let tapHoldInterval;
  23. let isHolding = false;
  24. element.addEventListener('touchstart', (e) => {
  25.  
  26. isHolding = true;
  27. tapHoldInterval = setInterval(() => {
  28. if (isHolding) {
  29. if (Delta <= timeout) Delta = timeout;
  30. }
  31. }, 100);
  32. });
  33.  
  34.  
  35. element.addEventListener('touchend', (e) => {
  36. // Stop the interval when the touch ends
  37. clearInterval(tapHoldInterval);
  38. isHolding = false;
  39. });
  40. })();