// ==UserScript== // @name 视频加速(防检测版) // @namespace http://tampermonkey.net/ // @version 1.0 // @description 无需外部依赖,直接加速计时器、跳过广告、视频倍速(绕过检测) // @author // @match *://*/* // @grant none // @run-at document-start // @license MIT // ==/UserScript== (function() { 'use strict'; if (window.TimerHookerRunning) return; window.TimerHookerRunning = true; console.log("[TimerHooker] 防检测版启动中..."); let speed = 1.0; let lastRealTime = Date.now(); let lastHookTime = Date.now(); // ========================================= // 防检测:隐藏加速特征 // ========================================= function hidePlaybackRate() { const originalDescriptor = Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'playbackRate'); if (originalDescriptor) { Object.defineProperty(HTMLMediaElement.prototype, 'playbackRate', { get: function() { return 1; // 返回1,让检测以为没加速 }, set: function(value) { const realSpeed = Math.min(value, 16); this._realPlaybackRate = realSpeed; originalDescriptor.set.call(this, realSpeed); }, configurable: true }); } // 监控新添加的视频 const observer = new MutationObserver(function(mutations) { document.querySelectorAll('video').forEach(function(video) { if (!video._hooked) { video._hooked = true; video._realPlaybackRate = speed; try { Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'playbackRate') .set.call(video, speed); } catch(e) {} } }); }); observer.observe(document.documentElement, { childList: true, subtree: true }); } // ========================================= // 劫持 setTimeout/setInterval/Date.now // ========================================= const originalSetTimeout = window.setTimeout; window.setTimeout = function(cb, delay) { const realDelay = delay / speed; return originalSetTimeout(cb, realDelay); }; const originalSetInterval = window.setInterval; window.setInterval = function(cb, delay) { const realDelay = delay / speed; return originalSetInterval(cb, realDelay); }; const originalDateNow = Date.now; Date.now = function() { const now = originalDateNow(); const delta = now - lastRealTime; lastRealTime = now; lastHookTime += delta * speed; return lastHookTime; }; const originalPerformanceNow = performance.now.bind(performance); performance.now = function() { return originalPerformanceNow() * speed; }; // ========================================= // 设置视频速度 // ========================================= function setVideoSpeed(value) { speed = Math.min(16, Math.max(0.1, value)); document.querySelectorAll('video').forEach(function(video) { try { Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'playbackRate') .set.call(video, speed); video._realPlaybackRate = speed; } catch(e) {} }); // 更新UI显示 updateUISpeed(); console.log('[TimerHooker] 当前倍速:', speed); } // ========================================= // UI 界面(修复版 - 确保可见) // ========================================= let speedDisplay = null; let mainButton = null; function updateUISpeed() { if (mainButton) { mainButton.textContent = `x${speed.toFixed(1)}`; } if (speedDisplay) { speedDisplay.textContent = `x${speed.toFixed(1)}`; speedDisplay.classList.remove('th-hide'); setTimeout(() => speedDisplay.classList.add('th-hide'), 500); } } function createUI() { // 样式 const style = document.createElement('style'); style.textContent = ` .th-ui-container { position: fixed !important; right: 20px !important; bottom: 100px !important; z-index: 9999999 !important; display: flex !important; flex-direction: column !important; gap: 8px !important; background: rgba(0, 0, 0, 0.85) !important; padding: 12px !important; border-radius: 12px !important; border: 2px solid #5eead4 !important; box-shadow: 0 4px 20px rgba(0,0,0,0.5) !important; backdrop-filter: blur(10px) !important; min-width: 60px !important; pointer-events: auto !important; } .th-ui-container * { pointer-events: auto !important; } .th-btn { width: 50px !important; height: 50px !important; background: #5eead4 !important; border-radius: 50% !important; text-align: center !important; line-height: 50px !important; cursor: pointer !important; color: #000 !important; font-weight: bold !important; font-size: 16px !important; border: none !important; transition: all 0.2s !important; user-select: none !important; box-shadow: 0 2px 8px rgba(94, 234, 212, 0.3) !important; } .th-btn:hover { transform: scale(1.1) !important; background: #2dd4bf !important; box-shadow: 0 4px 12px rgba(94, 234, 212, 0.5) !important; } .th-btn:active { transform: scale(0.95) !important; } .th-main { background: #f472b6 !important; font-size: 18px !important; font-weight: bold !important; color: #fff !important; min-width: 50px !important; } .th-main:hover { background: #ec4899 !important; } .th-speed { position: fixed !important; inset: 0 !important; display: flex !important; align-items: center !important; justify-content: center !important; font-size: 72px !important; font-weight: bold !important; background: rgba(0,0,0,0.6) !important; color: #5eead4 !important; z-index: 99999999 !important; pointer-events: none !important; text-shadow: 0 0 30px rgba(94, 234, 212, 0.5) !important; font-family: Arial, sans-serif !important; } .th-hide { display: none !important; } .th-label { color: #5eead4 !important; font-size: 10px !important; text-align: center !important; font-family: monospace !important; opacity: 0.6 !important; margin-top: 4px !important; letter-spacing: 1px !important; } .th-row { display: flex !important; gap: 8px !important; justify-content: center !important; } .th-btn-small { width: 40px !important; height: 40px !important; line-height: 40px !important; font-size: 14px !important; background: #34d399 !important; } .th-btn-small:hover { background: #10b981 !important; } .th-btn-danger { background: #f87171 !important; } .th-btn-danger:hover { background: #ef4444 !important; } `; document.head.appendChild(style); // 创建容器 - 放在右下角 const container = document.createElement('div'); container.className = 'th-ui-container'; container.id = 'th-ui-container'; container.innerHTML = `
x${speed.toFixed(1)}
×2
+2
-2
÷2
重置
⚡ 加速器
`; document.body.appendChild(container); // 速度显示(中间大号提示) const speedDisplayEl = document.createElement('div'); speedDisplayEl.className = 'th-speed th-hide'; speedDisplayEl.id = 'th-speed-display'; speedDisplayEl.textContent = `x${speed.toFixed(1)}`; document.body.appendChild(speedDisplayEl); // 保存引用 mainButton = document.getElementById('th-main-btn'); speedDisplay = document.getElementById('th-speed-display'); // 绑定事件 document.getElementById('th-main-btn').addEventListener('click', function(e) { e.stopPropagation(); const val = prompt("请输入倍速 (0.1 - 16):", speed); if (val === null) return; const num = parseFloat(val); if (!isNaN(num) && num > 0 && num <= 16) { setVideoSpeed(num); } else { alert('请输入 0.1 到 16 之间的数字'); } }); document.getElementById('th-up1').addEventListener('click', function(e) { e.stopPropagation(); setVideoSpeed(Math.min(16, speed + 2)); }); document.getElementById('th-down1').addEventListener('click', function(e) { e.stopPropagation(); setVideoSpeed(Math.max(0.1, speed - 2)); }); document.getElementById('th-up2').addEventListener('click', function(e) { e.stopPropagation(); setVideoSpeed(Math.min(16, speed * 2)); }); document.getElementById('th-down2').addEventListener('click', function(e) { e.stopPropagation(); setVideoSpeed(Math.max(0.1, speed / 2)); }); document.getElementById('th-reset').addEventListener('click', function(e) { e.stopPropagation(); setVideoSpeed(1.0); }); // 拖动功能 let isDragging = false; let startX, startY, startLeft, startBottom; container.addEventListener('mousedown', function(e) { if (e.target.closest('.th-btn')) return; isDragging = true; const rect = container.getBoundingClientRect(); startX = e.clientX; startY = e.clientY; startLeft = rect.left; startBottom = window.innerHeight - rect.bottom; container.style.cursor = 'grabbing'; e.preventDefault(); }); document.addEventListener('mousemove', function(e) { if (!isDragging) return; const dx = e.clientX - startX; const dy = e.clientY - startY; container.style.left = (startLeft + dx) + 'px'; container.style.bottom = (startBottom - dy) + 'px'; container.style.right = 'auto'; }); document.addEventListener('mouseup', function() { isDragging = false; container.style.cursor = 'default'; }); console.log('[TimerHooker] ✅ UI已创建(右下角)'); } // ========================================= // 键盘快捷键 // ========================================= document.addEventListener('keydown', function(e) { // Ctrl+Shift+↑ 增加倍速 if (e.ctrlKey && e.shiftKey && e.key === 'ArrowUp') { e.preventDefault(); setVideoSpeed(Math.min(16, speed + 1)); } // Ctrl+Shift+↓ 减少倍速 else if (e.ctrlKey && e.shiftKey && e.key === 'ArrowDown') { e.preventDefault(); setVideoSpeed(Math.max(0.1, speed - 1)); } // Ctrl+Shift+R 重置 else if (e.ctrlKey && e.shiftKey && e.key === 'r') { e.preventDefault(); setVideoSpeed(1.0); } // Ctrl+Shift+= 翻倍 else if (e.ctrlKey && e.shiftKey && (e.key === '=' || e.key === '+')) { e.preventDefault(); setVideoSpeed(Math.min(16, speed * 2)); } // Ctrl+Shift+- 减半 else if (e.ctrlKey && e.shiftKey && e.key === '-') { e.preventDefault(); setVideoSpeed(Math.max(0.1, speed / 2)); } }); // ========================================= // 启动 // ========================================= hidePlaybackRate(); // 页面加载完成后创建UI if (document.readyState === 'complete') { setTimeout(createUI, 500); } else { window.addEventListener('load', function() { setTimeout(createUI, 500); }); } // 定期检查并重新应用速度 setInterval(() => { document.querySelectorAll('video').forEach(function(video) { if (video._realPlaybackRate !== speed) { try { Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'playbackRate') .set.call(video, speed); video._realPlaybackRate = speed; } catch(e) {} } }); }, 3000); console.log('[TimerHooker] ✅ 防检测版启动成功'); console.log('[TimerHooker] 📌 使用说明:'); console.log(' - 界面在右下角,可拖动'); console.log(' - 点击 x1.0 输入自定义倍速'); console.log(' - 快捷键: Ctrl+Shift+↑/↓ 调整倍速'); console.log(' - 快捷键: Ctrl+Shift+= 翻倍, Ctrl+Shift+- 减半'); })();