Disable NYTimes Blog Smooth-Scrolling

Disables the smooth scrolling done by site's script

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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);
})();