您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add a custom control for changing YouTube video playback speed
当前为
// ==UserScript== // @name Playback Speed Control // @namespace https://github.com/yourusername/YouTubePlaybackSpeed // @version 1.2 // @description Add a custom control for changing YouTube video playback speed // @author Patrick // @match *://*.youtube.com/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Function to add a playback speed control to the YouTube player function addSpeedControl() { // Check if the control is already present if (document.querySelector('#custom-speed-control')) return; // Create the button for speed control const controlButton = document.createElement('button'); controlButton.id = 'custom-speed-control'; controlButton.textContent = 'Speed: 1x'; controlButton.style.position = 'absolute'; controlButton.style.bottom = '10px'; controlButton.style.right = '10px'; controlButton.style.backgroundColor = 'rgba(0,0,0,0.7)'; controlButton.style.color = '#fff'; controlButton.style.border = 'none'; controlButton.style.padding = '5px 10px'; controlButton.style.borderRadius = '3px'; controlButton.style.cursor = 'pointer'; controlButton.style.zIndex = '9999'; // Append the button to the player controls const controls = document.querySelector('.ytp-chrome-bottom'); if (controls) { controls.appendChild(controlButton); // Add event listener to change speed controlButton.addEventListener('click', () => { const video = document.querySelector('video'); if (!video) return; let currentSpeed = video.playbackRate; const speeds = [0.5, 1, 1.5, 2]; // Available speeds let nextSpeedIndex = (speeds.indexOf(currentSpeed) + 1) % speeds.length; let newSpeed = speeds[nextSpeedIndex]; video.playbackRate = newSpeed; }); } // Detect screen orientation changes window.addEventListener('orientationchange', () => { // Adjust playback speed here based on orientation (portrait or landscape) // You can customize this part according to your preference }); } // Call the function to add the speed control addSpeedControl(); })();