html5 video speed controller (vlc like)

Simple html5 video speed control with '{', '}', and '=' (vlc like). '{': decrease by 0.1, '}': increase by 0.1, '=': back to 1.0x

Tính đến 09-02-2021. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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

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

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

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        html5 video speed controller (vlc like)
// @namespace   github.com/sky-bro
// @version     1.0.0
// @description Simple html5 video speed control with '{', '}', and '=' (vlc like). '{': decrease by 0.1, '}': increase by 0.1, '=': back to 1.0x
// @author      https://sky-bro.github.io
// @match       https://www.youtube.com/*
// @match       *://*.zhihuishu.com/*
// @grant       none
// ==/UserScript==

(function() {
    'use strict';
    window.addEventListener('keypress', function(event) {
        var player = document.querySelector("video");
        console.log(event);
        var curRate = Number(player.playbackRate);
        // vlc actually uses '[' and ']', but they are used by vimium
        if (event.key == "{") {
            console.log("{ pressed");
            curRate -= 0.1;
            player.playbackRate = (curRate < 0.1) ? 0.1 : curRate;
        } else if (event.key == "}") {
            console.log("} pressed");
            curRate += 0.1;
            player.playbackRate = (curRate > 10) ? 10 : curRate;
        } else if (event.key == "=") {
            console.log("= pressed");
            player.playbackRate = 1;
        }
        console.log("playing in %sx", (player.playbackRate).toFixed(1));
    });
})();