ChatGPT Scroll Fix 1

Fix scroll issues on ChatGPT for Safari iOS 15/16

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         ChatGPT Scroll Fix 1
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Fix scroll issues on ChatGPT for Safari iOS 15/16
// @author       0xkuj
// @match        https://chatgpt.com/*
// @match        https://chat.openai.com/*
// @license MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Allow scrolling on all possible containers
    const elements = [
        document.documentElement,
        document.body,
        document.querySelector('main'),
        document.querySelector('.overflow-hidden'),
        document.querySelector('[role="presentation"]'),
        ...document.querySelectorAll('.overflow-hidden'),
        ...document.querySelectorAll('[style*="overflow: hidden"]'),
        ...document.querySelectorAll('[style*="position: fixed"]')
    ];

    elements.forEach(el => {
        if (el) {
            el.style.cssText = `
                overflow: auto !important;
                position: relative !important;
                height: auto !important;
                max-height: none !important;
                overscroll-behavior: auto !important;
                -webkit-overflow-scrolling: touch !important;
            `;
        }
    });

    // Force layout recalculation
    window.dispatchEvent(new Event('resize'));

    // Remove any classes that might block scrolling
    document.querySelectorAll('*').forEach(el => {
        if (el.classList.contains('overflow-hidden')) {
            el.classList.remove('overflow-hidden');
        }
    });
})();