// ==UserScript== // @name 按下0键重置视频 // @namespace http://tampermonkey.net/ // @version 2024年8月16日06点26分 // @description 按下数字0键时,将页面上的所有视频重置到开头 // @author onionycs // @match https://www.bilibili.com/video/* // @match https://www.mashibing.com/* // @match https://live.shixiseng.com/review/* // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 监听键盘按下事件 document.addEventListener('keydown', function(event) { // 检查按下的键是否是数字0(注意:这里不区分大小写,但数字键通常没有大小写) if (event.key === '0') { // 显示确认对话框 if (confirm('确定要将所有视频重置到开头吗?')) { // 获取页面上所有的video标签 const videos = document.querySelectorAll('video'); // 遍历每个video标签,并将其currentTime设置为0 videos.forEach(video => { video.currentTime = 0; video.pause(); // 如果需要,可以在这里添加额外的逻辑,比如暂停或播放视频 }); alert("已退回开头,空格键播放") } } if (event.key === 'k') { const videos = document.querySelectorAll('video'); videos.forEach(video => { // 如果视频当前是暂停的,则播放;如果是播放的,则暂停 if (video.paused) { video.play(); } else { video.pause(); } }); } if (event.key === 'j') { const videos = document.querySelectorAll('video'); videos.forEach(video => { video.currentTime -= 10; }); } if (event.key === 'l') { const videos = document.querySelectorAll('video'); videos.forEach(video => { video.currentTime += 10; }); } }); })();