TierMaker AdBlock Scroll Fix

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

目前為 2025-05-31 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
})();