tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

bug1922498-www.ilgeniodellapizza.com-fix-broken-scrolling.js (967B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 /**
      8 * Bug 1922498 - scrolling is broken on www.ilgeniodellapizza.com
      9 *
     10 * The site is expecting wheelDeltaY to have the opposite sign, breaking scrolling.
     11 * We can override the value to flip the sign and scale down the value.
     12 */
     13 
     14 /* globals exportFunction */
     15 
     16 console.info(
     17  "wheelDeltaY is being overriden for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1922498 for details."
     18 );
     19 
     20 const proto = window.wrappedJSObject.WheelEvent.prototype;
     21 const descriptor = Object.getOwnPropertyDescriptor(proto, "wheelDeltaY");
     22 const { get } = descriptor;
     23 
     24 descriptor.get = exportFunction(function () {
     25  const value = get.call(this);
     26  return -value / 40;
     27 }, window);
     28 
     29 Object.defineProperty(proto, "wheelDeltaY", descriptor);