Anti Scroll Lock

Previne sites de desabilitar o scrolling

  1. // ==UserScript==
  2. // @name Anti Scroll Lock
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Previne sites de desabilitar o scrolling
  6. // @match *://*/*
  7. // @grant none
  8. // @license GPLv3
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. function enableScroll() {
  15. // Remove estilos que bloqueiam o scrolling
  16. document.body.style.overflow = 'auto';
  17. document.documentElement.style.overflow = 'auto';
  18.  
  19. // Remove event listeners que possam estar prevenindo o scrolling
  20. window.onscroll = null;
  21. window.onwheel = null;
  22. window.ontouchmove = null;
  23. document.onkeydown = null;
  24.  
  25. // Remove classes que possam estar bloqueando o scroll
  26. document.body.classList.remove('no-scroll');
  27.  
  28. // Sobrescreve o método addEventListener para ignorar certos tipos de eventos
  29. const originalAddEventListener = EventTarget.prototype.addEventListener;
  30. EventTarget.prototype.addEventListener = function(type, listener, options) {
  31. if(type === 'wheel' || type === 'touchmove' || type === 'scroll') {
  32. return;
  33. }
  34. originalAddEventListener.call(this, type, listener, options);
  35. };
  36. }
  37.  
  38. // Executa a função imediatamente e a cada 1 segundo
  39. enableScroll();
  40. setInterval(enableScroll, 1000);
  41. })();