Skip to content

Instantly share code, notes, and snippets.

@sanjeed5
Created June 28, 2024 17:54
Show Gist options
  • Select an option

  • Save sanjeed5/16998811c29e3e5e4413643f5196b8a3 to your computer and use it in GitHub Desktop.

Select an option

Save sanjeed5/16998811c29e3e5e4413643f5196b8a3 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Mangasee123 Fast Scroll
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Simulate Option + Down arrow when I just press down arrow on mangasee123.com with smooth scrolling.
// @author You
// @match https://mangasee123.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function smoothScroll(duration, distance) {
let start = null;
const easeInOutQuad = (t) => t<.5 ? 2*t*t : 1-((t-1)*(t-1)*2);
requestAnimationFrame(function step(timestamp) {
if (!start) start = timestamp;
const progress = timestamp - start;
const easedProgress = easeInOutQuad(Math.min(progress / duration, 1));
window.scrollBy(0, distance * easedProgress);
if (easedProgress < 1) {
requestAnimationFrame(step);
}
});
}
document.addEventListener('keydown', function(event) {
if (event.keyCode === 40 && !event.ctrlKey && !event.shiftKey && !event.altKey) {
// Down arrow pressed without modifiers (Ctrl, Shift, Alt)
event.preventDefault();
smoothScroll(150, 300); // Adjust duration (ms) and scroll amount as needed
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment