您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
自动恢复视频播放进度,并在30天后清理旧记录
// ==UserScript== // @name 带自动清理的视频播放进度恢复脚本 // @namespace http://tampermonkey.net/ // @version 1.4 // @description 自动恢复视频播放进度,并在30天后清理旧记录 // @author CWJ // @match *://*/* // @grant none // ==/UserScript== (function() { 'use strict'; const videoSelector = 'video'; const expirationDays = 30; function getVideoId(video) { return video.src || window.location.href; } function displayAlert(message) { const alertBox = document.createElement('div'); alertBox.innerText = message; alertBox.style.position = 'fixed'; alertBox.style.zIndex = '10000'; alertBox.style.left = '50%'; alertBox.style.top = '10%'; alertBox.style.transform = 'translateX(-50%)'; alertBox.style.background = 'rgba(0, 0, 0, 0.7)'; alertBox.style.color = 'white'; alertBox.style.padding = '10px'; alertBox.style.borderRadius = '5px'; document.body.appendChild(alertBox); setTimeout(() => { document.body.removeChild(alertBox); }, 2000); } function clearExpiredData() { const data = localStorage.getItem('savedVideoData'); const videosData = data ? JSON.parse(data) : {}; const currentTime = new Date().getTime(); Object.entries(videosData).forEach(([key, value]) => { if (currentTime - value.timestamp > expirationDays * 24 * 60 * 60 * 1000) { delete videosData[key]; } }); localStorage.setItem('savedVideoData', JSON.stringify(videosData)); } window.addEventListener('load', () => { clearExpiredData(); const video = document.querySelector(videoSelector); if (video) { const videoId = getVideoId(video); const data = localStorage.getItem('savedVideoData'); const videosData = data ? JSON.parse(data) : {}; if (videosData[videoId] && videosData[videoId].currentTime) { video.currentTime = parseFloat(videosData[videoId].currentTime); displayAlert('从上次播放'); } video.addEventListener('timeupdate', () => { videosData[videoId] = { currentTime: video.currentTime, timestamp: new Date().getTime() }; localStorage.setItem('savedVideoData', JSON.stringify(videosData)); }); } }); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址