// ==UserScript== // @name 视频加速(防检测版) // @namespace http://tampermonkey.net/ // @version 1.2 // @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(); let uiCreated = false; // ========================================= // 防检测:隐藏加速特征 // ========================================= function hidePlaybackRate() { const originalDescriptor = Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'playbackRate'); if (originalDescriptor) { Object.defineProperty(HTMLMediaElement.prototype, 'playbackRate', { get: function() { return 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) {} }); updateUISpeed(); console.log('[TimerHooker] 当前倍速:', speed); } // ========================================= // UI 界面(所有网页都显示) // ========================================= let mainButton = null; let speedDisplay = null; let container = null; function updateUISpeed() { if (mainButton) { mainButton.textContent = `${speed.toFixed(1)}x`; } if (speedDisplay) { speedDisplay.textContent = `${speed.toFixed(1)}x`; speedDisplay.classList.remove('th-hide'); setTimeout(() => speedDisplay.classList.add('th-hide'), 400); } } function createUI() { // 如果已经存在,不重复创建 if (document.getElementById('th-container')) { return; } // 样式 const style = document.createElement('style'); style.id = 'th-style'; style.textContent = ` .th-container { position: fixed !important; right: 16px !important; bottom: 80px !important; z-index: 9999999 !important; display: flex !important; flex-direction: column !important; gap: 4px !important; align-items: center !important; opacity: 0.5 !important; transition: opacity 0.3s !important; pointer-events: none !important; font-family: Arial, sans-serif !important; } .th-container:hover { opacity: 0.9 !important; } .th-container * { pointer-events: auto !important; } .th-main { width: 36px !important; height: 36px !important; border-radius: 50% !important; background: rgba(94, 234, 212, 0.85) !important; color: #000 !important; font-size: 12px !important; font-weight: bold !important; border: none !important; cursor: pointer !important; text-align: center !important; line-height: 36px !important; transition: all 0.2s !important; user-select: none !important; box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important; backdrop-filter: blur(4px) !important; font-family: Arial, sans-serif !important; } .th-main:hover { transform: scale(1.1) !important; background: rgba(94, 234, 212, 1) !important; box-shadow: 0 4px 16px rgba(94, 234, 212, 0.3) !important; } .th-main:active { transform: scale(0.9) !important; } .th-btn-group { display: flex !important; gap: 3px !important; flex-wrap: wrap !important; justify-content: center !important; max-width: 100px !important; } .th-btn-small { width: 28px !important; height: 28px !important; border-radius: 50% !important; background: rgba(52, 211, 153, 0.7) !important; color: #000 !important; font-size: 10px !important; font-weight: bold !important; border: none !important; cursor: pointer !important; text-align: center !important; line-height: 28px !important; transition: all 0.2s !important; user-select: none !important; backdrop-filter: blur(4px) !important; font-family: Arial, sans-serif !important; } .th-btn-small:hover { transform: scale(1.15) !important; background: rgba(52, 211, 153, 0.95) !important; } .th-btn-small:active { transform: scale(0.85) !important; } .th-btn-reset { background: rgba(248, 113, 113, 0.7) !important; } .th-btn-reset:hover { background: rgba(248, 113, 113, 0.95) !important; } .th-speed { position: fixed !important; inset: 0 !important; display: flex !important; align-items: center !important; justify-content: center !important; font-size: 80px !important; font-weight: bold !important; background: rgba(0,0,0,0.3) !important; color: rgba(94, 234, 212, 0.9) !important; z-index: 99999999 !important; pointer-events: none !important; text-shadow: 0 0 40px rgba(94, 234, 212, 0.3) !important; font-family: Arial, sans-serif !important; backdrop-filter: blur(2px) !important; } .th-hide { display: none !important; } .th-label { color: rgba(255,255,255,0.4) !important; font-size: 8px !important; font-family: monospace !important; letter-spacing: 2px !important; margin-top: 2px !important; text-shadow: 0 0 4px rgba(0,0,0,0.5) !important; pointer-events: none !important; } `; document.head.appendChild(style); // 主容器 container = document.createElement('div'); container.className = 'th-container'; container.id = 'th-container'; container.innerHTML = `