TierMaker AdBlock Scroll Fix

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         TierMaker AdBlock Scroll Fix
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Fixes page scrolling issue after using ad blockers | 修复使用广告屏蔽工具后页面无法滚动的问题
// @author       jotenbai
// @match        *://tiermaker.com/*
// @license      MIT
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    // 核心修复函数
    const fixScroll = () => {
        // 强制覆盖HTML和body元素的overflow样式
        document.documentElement.style.overflow = 'auto';
        document.body.style.overflow = 'auto';

        // 创建防篡改样式标签
        const style = document.createElement('style');
        style.innerHTML = `
            html, body {
                overflow: auto !important;
                position: static !important;
            }
            body.prevent-scroll {
                overflow: auto !important;
            }
        `;
        document.head.appendChild(style);
    };

    // 初始执行
    fixScroll();

    // 持续监控防止网站重新锁定
    const observer = new MutationObserver((mutations) => {
        if (document.documentElement.style.overflow === 'hidden' ||
            document.body.style.overflow === 'hidden') {
            fixScroll();
        }
    });

    // 监控HTML和body的属性变化
    observer.observe(document.documentElement, {
        attributes: true,
        attributeFilter: ['style']
    });
    observer.observe(document.body, {
        attributes: true,
        attributeFilter: ['style']
    });

    // 添加定时保险(每2秒检查一次)
    setInterval(fixScroll, 2000);
})();