Deepseek No Auto-Scroll (Stable)

Robust scroll blocking with multiple fallbacks

目前為 2025-03-16 提交的版本,檢視 最新版本

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Deepseek No Auto-Scroll (Stable)
// @description  Robust scroll blocking with multiple fallbacks
// @match        *://*.deepseek.com/*
// @version 0.0.1.20250316190240
// @namespace https://greasyfork.org/users/1435046
// ==/UserScript==

(function() {
    'use strict';
    
    const SCROLL_SELECTORS = [
        '[class*="overflow-auto"]', // Class contains "overflow-auto"
        '[class*="scroll-container"]', // Class contains "scroll-container"
        'main > div > div', // Structural fallback
        'div[style*="overflow"]' // Inline style overflow
    ];

    let activeContainer = null;

    const blockScroll = (container) => {
        if(container.__scrollBlocked) return;
        
        // Nuclear option: Remove all scroll behaviors
        container.style.overflow = 'hidden !important';
        container.style.overscrollBehavior = 'none !important';
        
        // Block all scroll methods
        const scrollMethods = ['scrollTo', 'scrollBy', 'scrollIntoView'];
        scrollMethods.forEach(method => {
            container[method] = () => {};
        });

        // Prevent wheel/touch events
        container.addEventListener('wheel', e => e.stopPropagation(), true);
        container.addEventListener('touchmove', e => e.stopPropagation(), true);
        
        container.__scrollBlocked = true;
    };

    const findScrollContainer = () => {
        return SCROLL_SELECTORS.reduce((found, selector) => {
            return found || document.querySelector(selector);
        }, null);
    };

    const initScrollBlock = () => {
        const newContainer = findScrollContainer();
        if(newContainer && newContainer !== activeContainer) {
            activeContainer = newContainer;
            blockScroll(newContainer);
        }
    };

    // Run every 500ms + on mutations
    setInterval(initScrollBlock, 500);
    new MutationObserver(initScrollBlock).observe(document.body, {
        childList: true,
        subtree: true,
        attributes: true
    });
})();