// ==UserScript== // @name 网页加速器 // @namespace http://tampermonkey.net/ // @version 1.0.0 // @description 自定义倍速加速任意网页 // @author yhu // @match *://*/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; let speed = 1.0; const button = document.createElement('div'); button.style.position = 'fixed'; button.style.bottom = '20px'; button.style.right = '20px'; button.style.width = '50px'; button.style.height = '50px'; button.style.borderRadius = '50%'; button.style.backgroundColor = '#2196F3'; button.style.color = 'white'; button.style.textAlign = 'center'; button.style.lineHeight = '50px'; button.style.fontSize = '16px'; button.style.fontWeight = 'bold'; button.style.cursor = 'pointer'; button.style.zIndex = '999999'; button.style.boxShadow = '0 2px 10px rgba(0,0,0,0.3)'; button.style.userSelect = 'none'; button.textContent = '1.0x'; document.body.appendChild(button); button.addEventListener('click', function() { const input = prompt('请输入播放速度(例如:1.5、2.0、0.5):', speed); if (input === null) return; const newSpeed = parseFloat(input); if (isNaN(newSpeed) || newSpeed <= 0) { alert('请输入有效的正数!'); return; } speed = newSpeed; button.textContent = speed.toFixed(1) + 'x'; applySpeed(speed); }); function applySpeed(speed) { document.querySelectorAll('video, audio').forEach(element => { element.playbackRate = speed; }); } const observer = new MutationObserver(function() { applySpeed(speed); }); observer.observe(document.body, { childList: true, subtree: true }); setInterval(function() { applySpeed(speed); }, 2000); applySpeed(speed); })();