Deepseek No Auto-Scroll (Stable)

Robust scroll blocking with multiple fallbacks

当前为 2025-03-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Deepseek No Auto-Scroll (Stable)
  3. // @description Robust scroll blocking with multiple fallbacks
  4. // @match *://*.deepseek.com/*
  5. // @version 0.0.1.20250316190240
  6. // @namespace https://greasyfork.org/users/1435046
  7. // ==/UserScript==
  8.  
  9. (function() {
  10. 'use strict';
  11. const SCROLL_SELECTORS = [
  12. '[class*="overflow-auto"]', // Class contains "overflow-auto"
  13. '[class*="scroll-container"]', // Class contains "scroll-container"
  14. 'main > div > div', // Structural fallback
  15. 'div[style*="overflow"]' // Inline style overflow
  16. ];
  17.  
  18. let activeContainer = null;
  19.  
  20. const blockScroll = (container) => {
  21. if(container.__scrollBlocked) return;
  22. // Nuclear option: Remove all scroll behaviors
  23. container.style.overflow = 'hidden !important';
  24. container.style.overscrollBehavior = 'none !important';
  25. // Block all scroll methods
  26. const scrollMethods = ['scrollTo', 'scrollBy', 'scrollIntoView'];
  27. scrollMethods.forEach(method => {
  28. container[method] = () => {};
  29. });
  30.  
  31. // Prevent wheel/touch events
  32. container.addEventListener('wheel', e => e.stopPropagation(), true);
  33. container.addEventListener('touchmove', e => e.stopPropagation(), true);
  34. container.__scrollBlocked = true;
  35. };
  36.  
  37. const findScrollContainer = () => {
  38. return SCROLL_SELECTORS.reduce((found, selector) => {
  39. return found || document.querySelector(selector);
  40. }, null);
  41. };
  42.  
  43. const initScrollBlock = () => {
  44. const newContainer = findScrollContainer();
  45. if(newContainer && newContainer !== activeContainer) {
  46. activeContainer = newContainer;
  47. blockScroll(newContainer);
  48. }
  49. };
  50.  
  51. // Run every 500ms + on mutations
  52. setInterval(initScrollBlock, 500);
  53. new MutationObserver(initScrollBlock).observe(document.body, {
  54. childList: true,
  55. subtree: true,
  56. attributes: true
  57. });
  58. })();