// ==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 = `
`; document.body.appendChild(container); // 大号速度提示 const speedDisplayEl = document.createElement('div'); speedDisplayEl.className = 'th-speed th-hide'; speedDisplayEl.id = 'th-speed-display'; speedDisplayEl.textContent = `${speed.toFixed(1)}x`; 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-up2').addEventListener('click', function(e) { e.stopPropagation(); setVideoSpeed(Math.min(16, speed * 2)); }); document.getElementById('th-up1').addEventListener('click', function(e) { e.stopPropagation(); setVideoSpeed(Math.min(16, speed + 1)); }); document.getElementById('th-down1').addEventListener('click', function(e) { e.stopPropagation(); setVideoSpeed(Math.max(0.1, speed - 1)); }); document.getElementById('th-reset').addEventListener('click', function(e) { e.stopPropagation(); setVideoSpeed(1.0); }); // 拖动功能 let isDragging = false; let startX, startY, startRight, startBottom; container.addEventListener('mousedown', function(e) { if (e.target.closest('button')) return; isDragging = true; const rect = container.getBoundingClientRect(); startX = e.clientX; startY = e.clientY; startRight = window.innerWidth - rect.right; startBottom = window.innerHeight - rect.bottom; container.style.cursor = 'grabbing'; container.style.opacity = '0.9'; e.preventDefault(); }); document.addEventListener('mousemove', function(e) { if (!isDragging) return; const dx = e.clientX - startX; const dy = e.clientY - startY; container.style.right = (startRight - dx) + 'px'; container.style.bottom = (startBottom - dy) + 'px'; }); document.addEventListener('mouseup', function() { isDragging = false; container.style.cursor = 'default'; container.style.opacity = ''; }); uiCreated = true; console.log('[TimerHooker] ✅ UI已创建(所有网页可见)'); } // ========================================= // 确保UI在所有网页都显示 // ========================================= // 1. 页面加载时创建 function initUI() { if (!document.body) { setTimeout(initUI, 100); return; } createUI(); } // 2. 监听页面变化(SPA应用切换页面时重新创建) function watchForPageChanges() { // 监听 body 变化 const observer = new MutationObserver(function(mutations) { // 检查UI是否还存在 if (!document.getElementById('th-container')) { createUI(); } }); // 监听整个文档的变化 observer.observe(document.documentElement, { childList: true, subtree: true }); // 监听 popstate(路由变化) window.addEventListener('popstate', function() { setTimeout(function() { if (!document.getElementById('th-container')) { createUI(); } }, 500); }); // 监听 hash 变化 window.addEventListener('hashchange', function() { setTimeout(function() { if (!document.getElementById('th-container')) { createUI(); } }, 500); }); // 监听 DOMContentLoaded(页面刷新) document.addEventListener('DOMContentLoaded', function() { setTimeout(function() { if (!document.getElementById('th-container')) { createUI(); } }, 500); }); } // ========================================= // 键盘快捷键 // ========================================= document.addEventListener('keydown', function(e) { if (e.ctrlKey && e.shiftKey && e.key === 'ArrowUp') { e.preventDefault(); setVideoSpeed(Math.min(16, speed + 1)); } else if (e.ctrlKey && e.shiftKey && e.key === 'ArrowDown') { e.preventDefault(); setVideoSpeed(Math.max(0.1, speed - 1)); } else if (e.ctrlKey && e.shiftKey && e.key === 'r') { e.preventDefault(); setVideoSpeed(1.0); } else if (e.ctrlKey && e.shiftKey && (e.key === '=' || e.key === '+')) { e.preventDefault(); setVideoSpeed(Math.min(16, speed * 2)); } else if (e.ctrlKey && e.shiftKey && e.key === '-') { e.preventDefault(); setVideoSpeed(Math.max(0.1, speed / 2)); } }); // ========================================= // 启动 // ========================================= hidePlaybackRate(); // 立即尝试创建UI if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function() { initUI(); watchForPageChanges(); }); } else { initUI(); watchForPageChanges(); } // 额外保险:每隔5秒检查一次UI是否存在 setInterval(function() { if (!document.getElementById('th-container') && document.body) { createUI(); } }, 5000); // 视频速度保持 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] ✅ 防检测版启动成功(所有网页显示UI)'); console.log('[TimerHooker] 📌 快捷键: Ctrl+Shift+↑/↓ 调速度'); })();