Fix PageUp and PageDown scrolling for ChatGPT

Redirects PageUp and PageDown keys to scroll the conversation window while typing in the input field.

As of 2024-12-01. See the latest version.

نووسەر
Devulsky
Ratings
0 0 0
وەشان
0.1
Created
2024-12-01
Updated
2024-12-01
Size
1.85 KB
مۆڵەت
MIT
Applies to

--- Explanation of Changes ---
The original script fixed issues with the PageUp, PageDown, Home, and End keys in ChatGPT but had unintended side effects:
1. Home and End Keys Issue:
- It intercepted the `Home` and `End` keys globally, including in text fields, breaking default browser shortcuts like `Ctrl + Home` and `Shift + End`.
- This was problematic for users relying on standard Windows/browser behavior.

2. Focus Interference:
- The script required the user to click outside the input field for PageUp and PageDown to work, disrupting workflow.

3. Redundant Logic:
- The original code contained duplicated logic for finding the scrollable container and handling key events, making it harder to maintain.

How This Version Fixes These Issues:
- Preserves Home and End Behavior: Home and End keys now retain their default functionality.
- Focus-Free Scrolling: PageUp and PageDown work directly on the conversation window, even when typing in the input field.
- Improved Readability: Functions are now modular and descriptive, with no redundant checks or duplication.
- Minimal Interference: Only PageUp and PageDown are intercepted; all other keys behave as expected.

This approach ensures compatibility with standard shortcuts while fixing the scrolling issues.

Original Version: https://gf.zukizuki.org/users/877912
This version: https://gf.zukizuki.org/en/scripts/519486