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.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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