视频播放速度控制 | 视频加速

通过按w和s键来控制网页视频的播放速度

// ==UserScript==
// @name         视频播放速度控制 | 视频加速
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  通过按w和s键来控制网页视频的播放速度
// @author       suhan
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAGJJJREFUeF7tnQm0dlVZx//OSAqSiZaiUgFmWgmlYipiTiQOOZSZppYJClo5gqaVE4pTpZiapWaDiZmahVNqRuKAmlYWYEKSpVALIcXUrNZvtc/i/e53793PHs4++5zzPGu9673fd/b43+f/7ukZriQXR8AR2BGBKzk2joAjsDMCThB/OxyBXRBwgvjr4Qg4QfwdcATyEPAZJA83z7USBJwgKxlo72YeAk6QPNw810oQcIKsZKC9m3kIOEHycPNcK0HACbKSgfZu5iHgBMnDzXOtBAEnyEoG2ruZh4ATJA83z7USBJwgKxlo72YeAk6QPNxq5tpX0v6SrhO+KftSSV8K35fXrMzLSkPACZKGV2rqG0o6TNKh4Zu/r7eFEFePFPr1LYS5WNI54XNu+P58asM8vQ0BJ4gNp1iqa0g6UtKdNsgAKa4Vy1jp+ZclDWTh+/2SzpL0tUrlr7YYJ0je0H+bpFuHz1GBGHkljZsLovD5qKSPSPr3catbXulOEPuY3k3S3QMpbm/P1lXKMwNR3inpXV21rNPGOEF2H5jbSrpX+Nyy0zHMbdbfSvrT8PlQbiFLz+cE2XuEb75Bih9e+gsQ+vfXG2T59Er6bOqmE+QKmO4v6eGSjjUht9xEb5f0Wkl/vNwu2nvmBPl/UjxC0h3tsK0i5QckvSaQZRUd3q6TayXIfmG2gBg/sNrRt3X8bzaIcpkty3JSrY0gHM8eH2aM75xwGLmf+C9JX93y4f+uKulbJR0Qvq88YTs3q/5sIMor1nRcvCaCPErSEyUd0vCFu0ASm96/3/L9lYQ2oIYCYfhwCw+xt36unVBeadLzJL1Q0qtKC5pD/jUQ5C6BGNxhjCkXSWLd/lfhFhtipBChpG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// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 获取页面中的第一个video元素
    const video = document.querySelector("video");

    // 检查是否找到了video元素
    if (video) {
        // 保存当前的速度
        let speed = 1;

        // 增加播放速度
        document.addEventListener('keydown', function(e) {
            if (e.key === 'w') {
                speed += 0.5;
                video.playbackRate = Math.min(speed, 16); // 设置最大速度限制为16倍速
            }
        });

        // 减少播放速度
        document.addEventListener('keydown', function(e) {
            if (e.key === 's') {
                speed -= 0.5;
                video.playbackRate = Math.max(speed, 0.5); // 设置最小速度限制为0.5倍速
            }
        });
    } else {
        console.log("No video element found on the page.");
    }
})();