BiliBiliVideoSpeed

调整B站视频速度

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

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         BiliBiliVideoSpeed
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  调整B站视频速度
// @author       Eilen https://github.com/EilenC
// @include      https://*.bilibili.com/*
// @match        https://www.bilibili.com/video/
// @grant        none
// ==/UserScript==

(function() {
    var video = document.getElementsByTagName("video")[0];

    function keyd(e){
        console.log(e.key);
        var speedLabel = document.getElementsByClassName('bilibili-player-video-btn-speed-name')[0];
        var speed = 1;
        if(e.key == "+"){
            speed = video.playbackRate + 0.20;
            video.playbackRate = speed.toFixed(3);
            console.log(video.playbackRate);
        }else if(e.key == "-"){
            speed = video.playbackRate - 0.20;
            video.playbackRate = speed.toFixed(3);
            console.log(video.playbackRate);
        }
        speedLabel.innerHTML=video.playbackRate+"x";
    }
    document.body.removeEventListener('keydown', keyd);
    document.body.addEventListener('keydown', keyd);
    // Your code here...
})();