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 提交的版本,檢視 最新版本

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址