Disable YouTube Number Keyboard Shortcuts

disables the 0-9 keyboard shortcuts

目前為 2021-03-29 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Disable YouTube Number Keyboard Shortcuts
// @namespace   https://github.com/timmontague/youtube-disable-number-seek
// @description disables the 0-9 keyboard shortcuts
// @version     1.0

// @match       *://www.youtube.com/*

// @match       *://vid.puffyan.us/*
// @match       *://invidious.fdn.fr/*
// @match       *://invidious.048596.xyz/*
// @match       *://invidious.site/*
// @match       *://yewtu.be/*
// @match       *://invidiou.site/*
// @match       *://invidious.himiko.cloud/*
// @match       *://invidious.snopyta.org/*
// @match       *://invidious.namazso.eu/*
// @match       *://invidious.xyz/*
// @match       *://ytprivate.com/*
// @match       *://invidious.kavin.rocks/*
// @match       *://invidious.tinfoil-hat.net/*
// @match       *://tube.connect.cafe/*
// @match       *://invidious.tube/*
// ==/UserScript==

function keyboard_event_handler(e) {
    // Don't prevent entering numbers in input areas
    if (e.target.tagName == 'INPUT' ||
	e.target.tagName == 'SELECT' ||
	e.target.tagName == 'TEXTAREA' ||
	e.target.isContentEditable) {
	return;
    }
    // Trap number keys
    if (e.key >= '0' && e.key <= '9') {
	e.stopImmediatePropagation();
    }
}
window.addEventListener('keydown', keyboard_event_handler, true);