Restrict auto-refresh

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

当前为 2024-09-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Restrict auto-refresh
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  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. let tapHoldInterval;
  20. let isHolding = false;
  21. element.addEventListener('touchstart', (e) => {
  22.  
  23. isHolding = true;
  24. tapHoldInterval = setInterval(() => {
  25. if (isHolding) {
  26. if (Delta <= timeout) Delta = timeout;
  27. }
  28. }, 100);
  29. });
  30.  
  31.  
  32. element.addEventListener('touchend', (e) => {
  33. // Stop the interval when the touch ends
  34. clearInterval(tapHoldInterval);
  35. isHolding = false;
  36. });
  37. })();