TierMaker AdBlock Scroll Fix

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

当前为 2025-05-31 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);
})();