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

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

目前为 2023-04-04 提交的版本。查看 最新版本

// ==UserScript==
// @name        Youtube-like Progress Bar Navigation 类 Youtube 按数字键进度条
// @description  允许使用数字键导航Bilibili视频,类似于Youtube的进度条导航功能。小键盘数字没有生效,为什么
// @author  chenjiamian
// @namespace    http://tampermonkey.net/
// @version      1.1.3
// @match        https://www.bilibili.com/video/*
// @match        https://www.bilibili.com/list/watchlater*
// @match        http://*/videos/*
// @match        https://*/videos/*
// @match        http://*/video/*
// @match        https://*/video/*
// @match        https://*/*/play/*
// @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 = 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;
            }
        }
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址