Greasy Fork is available in English.

Youtube-like Progress Bar Navigation 类 Youtube 按数字键进度条

允许使用数字键导航Bilibili视频,类似于Youtube的进度条导航功能。小键盘数字没有生效,为什么

// ==UserScript==
// @name        Youtube-like Progress Bar Navigation 类 Youtube 按数字键进度条
// @description  允许使用数字键导航Bilibili视频,类似于Youtube的进度条导航功能。小键盘数字没有生效,为什么
// @author  chenjiamian
// @namespace    http://tampermonkey.net/
// @version      2.0
// @match        https://www.bilibili.com/video/*
// @match        https://www.bilibili.com/list/watchlater*
// @match        http*://*/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    document.addEventListener('keydown', function(event) {
        const video = Array.from(document.querySelectorAll('video')).find(i=>i.duration > 0);
        //const video = document.querySelector('video');
        if (event.keyCode >= 48 && event.keyCode <= 57) {//横向的0-9
            const percentage = (event.keyCode - 48) * 10;
            if (video) {
                video.currentTime = video.duration * percentage / 100;
            }
        }else if (event.keyCode >= 96 && event.keyCode <= 105) {//小键盘的0-9
            const percentage = (event.keyCode - 96) * 10;
            if (video) {
                video.currentTime = video.duration * percentage / 100;
            }
        }
    });
})();