Disable NYTimes Blog Smooth-Scrolling

Disables the smooth scrolling done by site's script

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Disable NYTimes Blog Smooth-Scrolling
// @namespace   DisableNYTimesBlogSmoothScrolling
// @description Disables the smooth scrolling done by site's script
// @author      jcunews
// @match       *://*.nytimes.com/*
// @version     1.0.1
// @grant       none
// @run-at      document-start
// ==/UserScript==

(function() {
  var ele = document.createElement("SCRIPT");

  ele.text = "(" + (function() {

    var orgKeyDownHandler;
    
    //save original document's addEventListener function
    var docAddEventListener = document.addEventListener;

    //our keydown handler
    function newKeyDownHandler(ev) {
      //check key pressed
      switch (ev.key) {
        case "PageDown":
        case "PageUp":
        case " ": //spacebar
          //don't call original handler for these keys
          break;
        default:
          //call original handler for other keys
          return orgKeyDownHandler.apply(this, arguments);
      }
    }

    //hook document's addEventListener function
    document.addEventListener = function(name, func, capture) {
      if ((name === "keydown") && !orgKeyDownHandler) {
        //use our handler for keydown event
        orgKeyDownHandler = func; //save original handler
        func = newKeyDownHandler; //replace it with our handler
      }
      return docAddEventListener.apply(this, arguments);
    };

  }).toString() + ")()";

  document.head.appendChild(ele);
})();