GitHub Network graph Intercept arrow keys

Stops the arrow keys from scrolling the page, because GitHub forgot to use "e.preventDefault();" when they made the keyboard shortcuts for the Network graph.

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        GitHub Network graph Intercept arrow keys
// @namespace   Violentmonkey Scripts
// @match       https://github.com/*
// @grant       none
// @version     1.0
// @description Stops the arrow keys from scrolling the page, because GitHub forgot to use "e.preventDefault();" when they made the keyboard shortcuts for the Network graph.
// @license MIT
// @inject-into content
// ==/UserScript==
const regex = /^https:\/\/github\.com\/\S+\/network$/;
document.addEventListener("keydown", function(e){
  if (e.keyCode==37 || e.keyCode==38 || e.keyCode==39 || e.keyCode==40){
    if (document.location.href.match(regex)){
      if(document.activeElement.tagName!="INPUT"){
        e.preventDefault();
      }
    }
  }
});