🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/01/12 20:13:01
🔄 下次更新时间:2026/01/12 21:13:01
手动刷新缓存

VideoControl

Control video playback with keyboard shortcuts

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         VideoControl
// @namespace    https://greasyfork.org/zh-CN/users/1478188-kagenokeiyou
// @license      MIT
// @version      1.0.2
// @description  Control video playback with keyboard shortcuts
// @author       kagenokeiyou
// @match        https://www.youtube.com/*
// @match        https://player.cycanime.com/*
// @grant        none
// ==/UserScript==
(function () {
    'use strict';
    let video = document.querySelector('video');
    if (!video) {
        console.error('No video element found on the page.');
        return;
    }
    let tip = document.createElement('div');
    Object.assign(tip.style, {
        position: 'absolute',
        top: '10%',
        left: '50%',
        transform: 'translate(-50%, -50%)',
        background: 'rgba(0, 0, 0, 0.5)',
        color: 'rgb(222, 222, 222)',
        padding: '8px 16px',
        borderRadius: '10px',
        fontSize: '18px',
        zIndex: '9999',
        visibility: 'hidden',
    });
    if (video.parentElement) {
        if (getComputedStyle(video.parentElement).position === 'static') {
            video.parentElement.style.position = 'relative';
        }
        video.parentElement.style.width = '100%';
        video.parentElement.style.height = '100%';
        video.parentElement.appendChild(tip);
    }
    let tipTimeout = 0;
    function showTip(text, repeat = false) {
        tip.textContent = text;
        tip.style.visibility = 'visible';
        if (!repeat) {
            clearTimeout(tipTimeout);
            tipTimeout = setTimeout(() => {
                tip.style.visibility = 'hidden';
            }, 500);
        }
    }
    let isSpeedup = false;
    let speedupTimeout = 0;
    window.addEventListener('keydown', event => {
        if (event.code === 'ArrowRight') {
            event.preventDefault();
            event.stopPropagation();
            if (event.repeat)
                return;
            speedupTimeout = setTimeout(() => {
                video.playbackRate = 2.0;
                isSpeedup = true;
                showTip('2倍速播放', true);
            }, 500);
        }
        else if (event.code === 'ArrowLeft') {
            event.preventDefault();
            event.stopPropagation();
        }
    }, true);
    window.addEventListener('keyup', event => {
        if (event.code === 'ArrowRight') {
            event.preventDefault();
            event.stopPropagation();
            if (isSpeedup) {
                video.playbackRate = 1.0;
                isSpeedup = false;
                tip.style.visibility = 'hidden';
            }
            else {
                clearTimeout(speedupTimeout);
                video.currentTime += 5;
                showTip('快进5秒');
            }
        }
        else if (event.code === 'ArrowLeft') {
            event.preventDefault();
            event.stopPropagation();
            video.currentTime += 5;
            showTip('后退5秒');
        }
    }, true);
})();