您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Control playback speed, and seek for fullscreen videos
- // ==UserScript==
- // @name Fullscreen Video Speed Controller
- // @version 2.1.1
- // @description Control playback speed, and seek for fullscreen videos
- // @author Wanten
- // @copyright 2025 Wanten
- // @license MIT
- // @supportURL https://gist.github.com/WantenMN/c0afabc32a911d4dd10e06cff6bcb211
- // @homepageURL https://gist.github.com/WantenMN/c0afabc32a911d4dd10e06cff6bcb211
- // @namespace https://greasyfork.org/en/scripts/536243
- // @run-at document-end
- // @match https://*/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // Helper function to get the fullscreen video element
- function getFullscreenVideo() {
- if (document.fullscreenElement && document.fullscreenElement.tagName === 'VIDEO') {
- return document.fullscreenElement;
- }
- const videos = document.getElementsByTagName('video');
- for (const video of videos) {
- if (video.offsetWidth === window.innerWidth && video.offsetHeight === window.innerHeight) {
- return video;
- }
- }
- return null;
- }
- // Function to set the video speed
- function setVideoSpeed(speed) {
- const video = getFullscreenVideo();
- if (video && video.playbackRate != speed) {
- video.playbackRate = speed;
- if (video.playbackRate === 1){
- // Fix audio/video synchronization issues
- video.currentTime = video.currentTime;
- }
- }
- }
- // Function to seek the video forward or backward
- function seekVideo(offset) {
- const video = getFullscreenVideo();
- if (video) {
- video.currentTime += offset;
- }
- }
- // Event listeners for key presses
- document.addEventListener('keydown', function(event) {
- switch(event.key) {
- case 'j':
- setVideoSpeed(1);
- break;
- case 'k':
- setVideoSpeed(2);
- break;
- case 'l':
- setVideoSpeed(3);
- break;
- case 'h':
- seekVideo(-5); // Rewind 5 seconds
- break;
- case ';':
- seekVideo(5); // Fast-forward 5 seconds
- break;
- }
- });
- })();