您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Press [ and ] to slow down/speed up the video, and shift+[ to reset the playback rate
当前为
- // ==UserScript==
- // @name Youtube playback rate shortcut
- // @namespace Violentmonkey Scripts
- // @match *://youtube.com/*
- // @match *://*.youtube.com/*
- // @grant none
- // @run-at document-idle
- // @version 1.0
- // @author qsniyg
- // @description Press [ and ] to slow down/speed up the video, and shift+[ to reset the playback rate
- // ==/UserScript==
- (function() {
- var playback_increment = 0.25;
- var set_playback = function(diff) {
- var video_el = document.querySelector("video.video-stream.html5-main-video");
- if (video_el) {
- if (diff === 0)
- video_el.playbackRate = 1;
- else {
- var new_pr = video_el.playbackRate + diff * playback_increment;
- if (new_pr > 0)
- video_el.playbackRate = new_pr;
- }
- }
- }
- document.addEventListener("keydown", function(e) {
- if (e.target && e.target.tagName === "INPUT" || e.target.tagName === "TEXTAREA")
- return;
- if (e.key === "[" && !e.shiftKey) {
- set_playback(-1);
- } else if (e.key === "]") {
- set_playback(1);
- } else if (e.shiftKey && (e.key === "[" || e.key === "{")) {
- set_playback(0);
- }
- });
- })();