TierMaker AdBlock Scroll Fix

Fixes page scrolling issue after using ad blockers | 修复使用广告屏蔽工具后页面无法滚动的问题

  1. // ==UserScript==
  2. // @name TierMaker AdBlock Scroll Fix
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Fixes page scrolling issue after using ad blockers | 修复使用广告屏蔽工具后页面无法滚动的问题
  6. // @author jotenbai
  7. // @match *://tiermaker.com/*
  8. // @license MIT
  9. // @grant none
  10. // @run-at document-idle
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // 核心修复函数
  17. const fixScroll = () => {
  18. // 强制覆盖HTML和body元素的overflow样式
  19. document.documentElement.style.overflow = 'auto';
  20. document.body.style.overflow = 'auto';
  21.  
  22. // 创建防篡改样式标签
  23. const style = document.createElement('style');
  24. style.innerHTML = `
  25. html, body {
  26. overflow: auto !important;
  27. position: static !important;
  28. }
  29. body.prevent-scroll {
  30. overflow: auto !important;
  31. }
  32. `;
  33. document.head.appendChild(style);
  34. };
  35.  
  36. // 初始执行
  37. fixScroll();
  38.  
  39. // 持续监控防止网站重新锁定
  40. const observer = new MutationObserver((mutations) => {
  41. if (document.documentElement.style.overflow === 'hidden' ||
  42. document.body.style.overflow === 'hidden') {
  43. fixScroll();
  44. }
  45. });
  46.  
  47. // 监控HTML和body的属性变化
  48. observer.observe(document.documentElement, {
  49. attributes: true,
  50. attributeFilter: ['style']
  51. });
  52. observer.observe(document.body, {
  53. attributes: true,
  54. attributeFilter: ['style']
  55. });
  56.  
  57. // 添加定时保险(每2秒检查一次)
  58. setInterval(fixScroll, 2000);
  59. })();