Skip to content

Instantly share code, notes, and snippets.

@DediqaTech
Last active May 31, 2026 13:28
Show Gist options
  • Select an option

  • Save DediqaTech/4b59556703c0173cd304cd39c3bed0ce to your computer and use it in GitHub Desktop.

Select an option

Save DediqaTech/4b59556703c0173cd304cd39c3bed0ce to your computer and use it in GitHub Desktop.
Force instant native scrolling
// ==UserScript==
// @name Force instant native scrolling
// @namespace https://dediqa.tech
// @version 2026-05-31
// @author DediqaTech
// @match https://hardstyle.com/*
// @icon https://icons.duckduckgo.com/ip2/hardstyle.com.ico
// @grant none
// @run-at document-start
// @downloadURL https://gist.github.com/DediqaTech/4b59556703c0173cd304cd39c3bed0ce/raw//force-instant-native-scrolling.user.js
// @updateURL https://gist.github.com/DediqaTech/4b59556703c0173cd304cd39c3bed0ce/raw//force-instant-native-scrolling.user.js
// ==/UserScript==
(function () {
'use strict';
function injectCss() {
const css = `
html,
body,
* {
scroll-behavior: auto !important;
overscroll-behavior: auto !important;
}
html,
body {
overflow: auto !important;
}
`;
const style = document.createElement('style');
style.id = 'force-instant-scroll-css';
style.textContent = css;
const append = () => {
if (!document.getElementById(style.id)) {
(document.head || document.documentElement).appendChild(style);
}
};
append();
document.addEventListener('DOMContentLoaded', append);
}
function forceInstantScrollApi() {
const originalWindowScrollTo = window.scrollTo.bind(window);
const originalWindowScrollBy = window.scrollBy.bind(window);
window.scrollTo = function (...args) {
if (typeof args[0] === 'object') {
args[0] = {
...args[0],
behavior: 'auto',
};
}
return originalWindowScrollTo(...args);
};
window.scrollBy = function (...args) {
if (typeof args[0] === 'object') {
args[0] = {
...args[0],
behavior: 'auto',
};
}
return originalWindowScrollBy(...args);
};
const originalElementScrollTo = Element.prototype.scrollTo;
const originalElementScrollBy = Element.prototype.scrollBy;
const originalScrollIntoView = Element.prototype.scrollIntoView;
Element.prototype.scrollTo = function (...args) {
if (typeof args[0] === 'object') {
args[0] = {
...args[0],
behavior: 'auto',
};
}
return originalElementScrollTo.apply(this, args);
};
Element.prototype.scrollBy = function (...args) {
if (typeof args[0] === 'object') {
args[0] = {
...args[0],
behavior: 'auto',
};
}
return originalElementScrollBy.apply(this, args);
};
Element.prototype.scrollIntoView = function (...args) {
if (typeof args[0] === 'object') {
args[0] = {
...args[0],
behavior: 'auto',
};
}
return originalScrollIntoView.apply(this, args);
};
}
function destroyKnownSmoothScrollers() {
try {
if (window.lenis && typeof window.lenis.destroy === 'function') {
window.lenis.destroy();
}
} catch (e) {}
try {
if (window.locomotiveScroll && typeof window.locomotiveScroll.destroy === 'function') {
window.locomotiveScroll.destroy();
}
} catch (e) {}
try {
if (window.ScrollSmoother && window.ScrollSmoother.get) {
window.ScrollSmoother.get()?.kill();
}
} catch (e) {}
}
function forceDirectWheelScrolling() {
window.addEventListener('wheel', function (event) {
const scrollElement = document.scrollingElement || document.documentElement;
event.preventDefault();
event.stopImmediatePropagation();
scrollElement.scrollTop += event.deltaY;
scrollElement.scrollLeft += event.deltaX;
}, {
capture: true,
passive: false,
});
}
injectCss();
forceInstantScrollApi();
forceDirectWheelScrolling();
window.addEventListener('DOMContentLoaded', destroyKnownSmoothScrollers);
window.addEventListener('load', destroyKnownSmoothScrollers);
setInterval(destroyKnownSmoothScrollers, 500);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment