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

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

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

VideoControl

Control video playback with keyboard shortcuts

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

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

公众号二维码

扫码关注【爱吃馍】

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

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

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

公众号二维码

扫码关注【爱吃馍】

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

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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);
})();