Last active
May 24, 2026 15:46
-
-
Save WillPresley/ec209f684ac856cc63316f47880bd515 to your computer and use it in GitHub Desktop.
Scroll Hijacking Fixer (Selective)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Scroll Hijacking Fixer (Selective) | |
| // @namespace https://willpresley.com/ | |
| // @version 1.7 | |
| // @description Selectively disable scroll hijacking on specific domains. | |
| // @author Billy Presley | |
| // @license Apache-2.0 | |
| // @match *://*/* | |
| // @grant GM_setValue | |
| // @grant GM_getValue | |
| // @grant GM_registerMenuCommand | |
| // @grant GM_addStyle | |
| // @run-at document-start | |
| // @updateURL https://gist.github.com/WillPresley/ec209f684ac856cc63316f47880bd515/raw/userscript_scroll-hijack-fixer.user.js | |
| // @downloadURL https://gist.github.com/WillPresley/ec209f684ac856cc63316f47880bd515/raw/userscript_scroll-hijack-fixer.user.js | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| // 1. GUARD: Do not run inside iframes. | |
| if (window.top !== window.self) return; | |
| // 2. NORMALIZE: Strip 'www.' so subdomains share the same fix. | |
| const currentDomain = window.location.hostname.replace(/^www\./, ''); | |
| let fixedDomains = GM_getValue('saved_scroll_fixes', []); | |
| const applyScrollFix = () => { | |
| // --- JS FIX: INJECT INTO MAIN PAGE CONTEXT --- | |
| const pageContextLogic = `(function() { | |
| const originalAdd = EventTarget.prototype.addEventListener; | |
| EventTarget.prototype.addEventListener = function(type, listener, options) { | |
| if (['wheel', 'mousewheel', 'DOMMouseScroll', 'touchstart', 'touchmove'].includes(type)) { | |
| let newOptions = { passive: true }; | |
| if (typeof options === 'boolean') newOptions.capture = options; | |
| else if (options && typeof options === 'object') newOptions = Object.assign({}, options, { passive: true }); | |
| return originalAdd.call(this, type, listener, newOptions); | |
| } | |
| return originalAdd.call(this, type, listener, options); | |
| }; | |
| const originalPreventDefault = Event.prototype.preventDefault; | |
| Event.prototype.preventDefault = function() { | |
| if (this.type === 'keydown' && ['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', ' ', 'Home', 'End'].includes(this.key)) return; | |
| if (['wheel', 'mousewheel', 'DOMMouseScroll', 'touchmove'].includes(this.type)) return; | |
| originalPreventDefault.call(this); | |
| }; | |
| })();`; | |
| const scriptEl = document.createElement('script'); | |
| scriptEl.textContent = pageContextLogic; | |
| if (document.documentElement) { | |
| document.documentElement.appendChild(scriptEl); | |
| scriptEl.remove(); | |
| } | |
| // --- CSS FIX: SURGICAL WRAPPER REMOVAL --- | |
| const cssOverride = ` | |
| html, body { overflow: auto !important; overflow-x: hidden !important; height: auto !important; overscroll-behavior: auto !important; } | |
| #page { overflow: visible !important; } | |
| #smooth-wrapper, #smooth-content, [data-scroll-container], [asscroll-container], [data-scrollbar], #luxy, #butter { | |
| overflow: visible !important; transform: none !important; position: static !important; height: auto !important; min-height: 0 !important; max-height: none !important; width: auto !important; | |
| } | |
| `; | |
| document.addEventListener("DOMContentLoaded", () => { | |
| if (typeof GM_addStyle !== 'undefined') GM_addStyle(cssOverride); | |
| else { | |
| const style = document.createElement('style'); | |
| style.textContent = cssOverride; | |
| document.head.appendChild(style); | |
| } | |
| }); | |
| }; | |
| const isDomainFixed = fixedDomains.includes(currentDomain); | |
| if (isDomainFixed) applyScrollFix(); | |
| GM_registerMenuCommand(isDomainFixed ? `❌ Remove fix for ${currentDomain}` : `✅ Fix site scrolling (${currentDomain})`, () => { | |
| if (isDomainFixed) fixedDomains = fixedDomains.filter(d => d !== currentDomain); | |
| else fixedDomains.push(currentDomain); | |
| GM_setValue('saved_scroll_fixes', fixedDomains); | |
| window.location.reload(); | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment