// ==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 = `