// ==UserScript== // @name Bilibili 进度条精确控制 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 按下ctrl或者shift键时,按下左右箭头键可以实现0.5秒或者0.1秒的快进快退 // @author You // @icon https://www.bilibili.com/favicon.ico // @match https://www.bilibili.com/video/* // @match https://www.bilibili.com/list/* // @match https://www.bilibili.com/bangumi/play/* // @match https://www.bilibili.com/cheese/play/* // @match https://www.bilibili.com/festival/* // @grant none // ==/UserScript== (function() { 'use strict'; document.addEventListener('keydown', (e) => { // 1. Determine Step based on modifier keys let step = 0; if (e.shiftKey) { step = 0.5; } else if (e.ctrlKey) { step = 0.1; } // 2. If no modifier key we care about, return if (step === 0) return; // 3. Check for Arrow keys if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return; // 4. Avoid triggering when typing in inputs const activeTag = document.activeElement ? document.activeElement.tagName.toUpperCase() : ''; if (activeTag === 'INPUT' || activeTag === 'TEXTAREA' || document.activeElement.isContentEditable) { return; } // 5. Find the video element const video = document.querySelector('video'); if (!video) return; // 6. Execute Seek e.preventDefault(); e.stopPropagation(); const sign = e.key === 'ArrowRight' ? 1 : -1; // Calculate new time with boundaries let newTime = video.currentTime + (sign * step); if (newTime < 0) newTime = 0; if (newTime > video.duration) newTime = video.duration; video.currentTime = newTime; }, true); // Use capture phase to ensure we intercept before site listeners })();