Pixel-Precision Wheel Scroll

Add pixel-precision wheel scrolling capability using CTRL+SHIFT+Wheel for vertical scroll, and CTRL+ALT+Wheel for horizontal scroll, for any scrollable element which can be scrolled at pixel level.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Pixel-Precision Wheel Scroll
// @namespace    https://greasyfork.org/en/users/85671-jcunews
// @version      1.0.3
// @license      AGPL v3
// @author       jcunews
// @description  Add pixel-precision wheel scrolling capability using CTRL+SHIFT+Wheel for vertical scroll, and CTRL+ALT+Wheel for horizontal scroll, for any scrollable element which can be scrolled at pixel level.
// @match        *://*/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

addEventListener("wheel", (ev, ele) => {
  if (ev.ctrlKey) {
    ele = ev.target;
    while (ele && (ele.offsetWidth === ele.scrollWidth) && (ele.offsetHeight === ele.scrollHeight)) ele = ele.parentNode;
    ele = ele || window;
    if (ev.shiftKey && !ev.altKey) {
      ele.scrollBy(0, ev.deltaY > 0 ? 1 : -1);
      ev.stopPropagation();
      ev.preventDefault()
    } else if (ev.altKey && !ev.shiftKey) {
      ele.scrollBy(ev.deltaY > 0 ? 1 : -1, 0);;
      ev.stopPropagation();
      ev.preventDefault()
    }
  }
}, {capture: true, passive: false})