您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
通过按钮调整网页上视频和歌曲的播放速度,默认速度为0.8,并显示当前速度
// ==UserScript== // @name 视频和歌曲播放速度控制 // @namespace http://tampermonkey.net/ // @version 1.1.2 // @description 通过按钮调整网页上视频和歌曲的播放速度,默认速度为0.8,并显示当前速度 // @author 你的名字 // @match *://*/* // @grant none // ==/UserScript== (function() { 'use strict'; // 默认播放速度 let defaultSpeed = 0.8; // 速度步长 let speedStep = 0.1; // 创建控制按钮 function createControlButton(text, onClick, top) { let button = document.createElement('button'); button.textContent = text; button.style.position = 'fixed'; button.style.right = '10px'; button.style.top = top + 'px'; button.style.zIndex = '1000'; button.style.fontSize = '20px'; button.style.padding = '10px'; button.onclick = onClick; return button; } // 当前速度 let currentSpeed = defaultSpeed; // 显示当前速度按钮 let speedDisplayButton = createControlButton(`速度: ${currentSpeed.toFixed(1)}`, function() {}, 150); document.body.appendChild(speedDisplayButton); // 设置播放速度 function setPlaybackSpeed(speed) { currentSpeed = Math.max(0.1, speed); // 最低速度为0.1 let mediaElements = document.querySelectorAll('video, audio'); mediaElements.forEach(function(media) { media.playbackRate = currentSpeed; }); speedDisplayButton.textContent = `速度: ${currentSpeed.toFixed(1)}`; } // 增加速度按钮 let increaseButton = createControlButton('+', function() { setPlaybackSpeed(currentSpeed + speedStep); }, 50); document.body.appendChild(increaseButton); // 减少速度按钮 let decreaseButton = createControlButton('-', function() { setPlaybackSpeed(currentSpeed - speedStep); }, 100); document.body.appendChild(decreaseButton); // 重置速度按钮 let resetButton = createControlButton('重置', function() { setPlaybackSpeed(defaultSpeed); }, 200); document.body.appendChild(resetButton); // 初始化播放速度 function initPlaybackSpeed() { setPlaybackSpeed(defaultSpeed); } // 等待页面加载完成后初始化 window.addEventListener('load', initPlaybackSpeed); })();