BiliBiliVideoSpeed

调整B站视频速度

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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