Greasy Fork

Greasy Fork is available in English.

自定义哔哩哔哩视频播放速度

custom bilibili video play speed

当前为 2021-04-07 提交的版本,查看 最新版本

// ==UserScript==
// @name         自定义哔哩哔哩视频播放速度
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  custom bilibili video play speed
// @author       felix
// @match        https://www.bilibili.com/video/*
// @grant        none
// ==/UserScript==
(function () {
    'use strict';

    var autoAddInterval = setInterval(addCopyBtn, 2000);
    function addCopyBtn() {
        clearInterval(autoAddInterval);
        var viewbox_report = document.getElementById("arc_toolbar_report");
        var div = document.createElement("div");
        div.innerHTML = '<button id="reduce" style="width:15px;margin:0 3px">-<button/><button style="width:30px"><sapn id="speed">1<span/><button/><button id="add" style="width:15px;margin:0 3px">+<button/>';
        viewbox_report.appendChild(div);

        document.getElementById("reduce").onclick = function () {
            var speed = document.getElementById("speed");
            speed.innerText = Number(Number(Number(speed.innerText) * 10 - 1) / 10).toFixed(1);
            changeSpeed();
        };

        document.getElementById("add").onclick = function () {
            var speed = document.getElementById("speed");
            speed.innerText = Number(Number(Number(speed.innerText) * 10 + 1) / 10).toFixed(1);
            changeSpeed();
        };
    }

    function changeSpeed() {
        var speed = document.getElementById("speed");
        var playSpeed = Number(speed.innerText);
        document.querySelector('video').playbackRate = playSpeed;
    }
})();