Remove tp-modal-open on Technology Review

Removes the tp-modal-open class from <body> on load and DOM changes

// ==UserScript==
// @name         Remove tp-modal-open on Technology Review
// @description  Removes the tp-modal-open class from <body> on load and DOM changes
// @match        https://www.technologyreview.com/*
// @version 0.0.1.20250404080811
// @namespace https://gf.qytechs.cn/users/1435046
// ==/UserScript==

(function() {
    'use strict';

    const removeOverflowFromClass = () => {
        for (const sheet of document.styleSheets) {
            let rules;
            try {
                rules = sheet.cssRules;
            } catch (e) {
                continue; // avoid CORS-restricted stylesheets
            }

            if (!rules) continue;

            for (const rule of rules) {
                if (
                    rule.selectorText === 'body.tp-modal-open' ||
                    rule.selectorText === '.tp-modal-open' ||
                    rule.selectorText === 'body.tp-modal-open, .tp-modal-open'
                ) {
                    if (rule.style && rule.style.overflow) {
                        rule.style.removeProperty('overflow');
                    }
                }
            }
        }
    };

    // Run after DOM is ready
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', removeOverflowFromClass);
    } else {
        removeOverflowFromClass();
    }

    // Re-run when styles might be added dynamically
    const observer = new MutationObserver(removeOverflowFromClass);
    observer.observe(document.documentElement, {
        childList: true,
        subtree: true
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址