HTML5 Video Playback Speed Control Keyboard Shortcut

Add keyboard shortcuts to decrease (CTRL+,), increase (CTRL+.), and reset (CTRL+;) HTML5 video playback rate. Available playback speeds are between 0.25 to 2.0 inclusive in 0.25 increments. Speed of 1.0 is used when resetting playback speed. Note: the video playback speed menu selection on YouTube will not be affected.

目前為 2017-09-12 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        HTML5 Video Playback Speed Control Keyboard Shortcut
// @namespace   HTML5VideoPlaybackSpeedControlKeyboardShortcut
// @description Add keyboard shortcuts to decrease (CTRL+,), increase (CTRL+.), and reset (CTRL+;) HTML5 video playback rate. Available playback speeds are between 0.25 to 2.0 inclusive in 0.25 increments. Speed of 1.0 is used when resetting playback speed. Note: the video playback speed menu selection on YouTube will not be affected.
// @version     1.0.2
// @author      jcunews
// @include     http://*/*
// @include     https://*/*
// @grant       none
// ==/UserScript==

addEventListener("keydown", function(ev) {
  var ele = document.querySelector("VIDEO"), rate;
  if (ele && ev.ctrlKey) {
    rate = rate = ele.playbackRate;
    if ((ev.key === ",") || (ev.keyIdentifier === "U+00BC")) {
      rate -= 0.25;
      if (rate < 0.25) rate = 0.25;
    } else if ((ev.key === ".") || (ev.keyIdentifier === "U+00BE")) {
      rate += 0.25;
      if (rate > 2) rate = 2;
    } else if ((ev.key === ";") || (ev.keyIdentifier === "U+00BA")) {
      rate = 1;
    }
    rate = Math.trunc(rate * 4) / 4;
    ele.playbackRate = rate;
  }
});