视频加速

网页内视频内容加速播放。使用方法:右键-Tampermonkey-视频加速-点击修改

// ==UserScript==
// @name         视频加速
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  网页内视频内容加速播放。使用方法:右键-Tampermonkey-视频加速-点击修改
// @author       Coldarra
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @match        http://*/*
// @match        https://*/*
// @icon         data:image/svg+xml;base64,PHN2ZyB0PSIxNjkxNzI1NDUyNjgyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjQzMjMiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMTg1LjA5IDUzOC43NWMwLTkuODkgMC41OC0xNC44NSAxLjcxLTI0LjQ0IDE0LjQ3LTEyMi42MyAxMTguNzctMjE3Ljc1IDI0NS4yOC0yMTcuNzVzMjMwLjkzIDk1LjIzIDI0NS4zMSAyMThhMTc0Ljc3IDE3NC43NyAwIDAgMSAxLjY4IDI0LjI0IiBmaWxsPSIjMjc5QUNDIiBwLWlkPSI0MzI0Ii8+PHBhdGggZD0iTTUxMS4zMyA2NzIuMDRtLTgzLjYzIDBhODMuNjMgODMuNjMgMCAxIDAgMTY3LjI2IDAgODMuNjMgODMuNjMgMCAxIDAtMTY3LjI2IDBaIiBmaWxsPSIjMjc5QUNDIiBwLWlkPSI0MzI1Ii8+PHBhdGggZD0iTTUxMS4zMyA3NjMuMjJBOTEuMTkgOTEuMTkgMCAxIDEgNjAyLjUxIDY3MmE5MS4yOSA5MS4yOSAwIDAgMS05MS4xOCA5MS4yMnogbTAtMTMxLjkxQTQwLjczIDQwLjczIDAgMSAwIDU1Mi4wNiA2NzJhNDAuNzcgNDAuNzcgMCAwIDAtNDAuNzMtNDAuNjl6IiBmaWxsPSIjMzAzMDMwIiBwLWlkPSI0MzI2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xOCAwIDAgMS0xNy44NCA3LjM5ek0zODkuMjcgNDE3LjUyYTI1LjIgMjUuMiAwIDAgMS0xNy44NS03LjM5TDMzOSAzNzcuNzNhMjUuMjMgMjUuMjMgMCAwIDEgMzUuNjgtMzUuNjhsMzIuNCAzMi40YTI1LjI0IDI1LjI0IDAgMCAxLTE3Ljg0IDQzLjA3ek0zMzguNzEgNTM5LjU4aC00NS44MmEyNS4yMyAyNS4yMyAwIDEgMSAwLTUwLjQ1aDQ1LjgyYTI1LjIzIDI1LjIzIDAgMSAxIDAgNTAuNDV6TTcyOS43OCA1MzkuNThINjg0YTI1LjIzIDI1LjIzIDAgMSAxIDAtNTAuNDVoNDUuODJhMjUuMjMgMjUuMjMgMCAwIDEgMCA1MC40NXpNNTMxLjE0IDYzNC4zNWEyNS4yMyAyNS4yMyAwIDAgMS0yMy41Ni0zNC4yM0w1NTcuNjYgNDY5YTI1LjIyIDI1LjIyIDAgMSAxIDQ3LjEzIDE4bC01MC4wOCAxMzEuMTJhMjUuMjMgMjUuMjMgMCAwIDEtMjMuNTcgMTYuMjN6IiBmaWxsPSIjMzAzMDMwIiBwLWlkPSI0MzI5Ii8+PC9zdmc+
// @license MIT

// ==/UserScript==
(function () {
    'use strict';
    // 🟢🔴
    let menuCommand = 0;
    let speed = 1;
    const ConfigSpeed = () => {
        let elements = document.getElementsByTagName('video');
        if (elements.length === 0) {
            alert('页面中没有找到视频');
            return;
        }
        const result = prompt('请输入倍速', speed);
        let sp = parseFloat(result);
        if (sp >= 0 && sp <= 100 && elements.length > 0) {
            speed = sp;
            try {
                elements.playbackRate = sp;
            }
            catch { }
            elements.forEach((el) => {
                el.playbackRate = sp;
            });
            GM_unregisterMenuCommand(menuCommand);
            RegisterMenuCommand();
        }
    };
    const RegisterMenuCommand = () => {
        menuCommand = GM_registerMenuCommand(`🟢当前视频倍速:${speed},点击修改`, ConfigSpeed);
    };
    RegisterMenuCommand();
})();