🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

youtube 视频右上角显示播放速度

视频右上角显示当前的播放速度,仅对于播放速度不等于1时有效

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         youtube 视频右上角显示播放速度
// @namespace    http://tampermonkey.net/
// @version      0.0.1
// @description  视频右上角显示当前的播放速度,仅对于播放速度不等于1时有效
// @author       meteora
// @match        https://www.youtube.com/*
// @match http://www.youtube.com/*
// @match http://youtube.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// @license MIT
// ==/UserScript==

(()=>{
    setTimeout(() => {
			// 找出视频播放器容器
			const videoDom = document.querySelector("video")
			const videoWrapperContainer = document.getElementById(
				"full-bleed-container"
			)
			videoWrapperContainer.style.position = "relative"
			// 将视频播放器的播放速度反映到屏幕右上角显示
			function removePlayRateInfo() {
				const oldDom = document.getElementById("play-rate-show-info")
				if (oldDom) {
					oldDom.remove()
				}
			}
			function setPlayRateInfo(playRate) {
				// 移除之前插入的元素
				removePlayRateInfo()
				const domText = `<div style="color: white; font-size: 20px; position: absolute; z-index: 999; right: 20px; top: 20px;" id="play-rate-show-info">${playRate}</div>`
				// 将元素作为子节点插入到 videoWrapperContainer 中
				videoWrapperContainer.insertAdjacentHTML("beforeend", domText)
			}
			// 查询视频播放器的播放速度
			let playRate = videoDom.playbackRate
			if (playRate !== 1) {
				setPlayRateInfo(playRate)
			}
			
			videoDom.addEventListener("ratechange", function () {
				playRate = videoDom.playbackRate
				if (playRate !== 1) {
					setPlayRateInfo(playRate)
				} else {
					removePlayRateInfo()
				}
			})
		}, 3000)
})()