您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Displays the video's remaining time during playback
当前为
// ==UserScript== // @name YouTube - Time Remaining Counter // @description Displays the video's remaining time during playback // @author wormboy // @namespace patchmonkey // @version 1.4.5 // @include https://www.youtube.com/* // @require https://gf.qytechs.cn/scripts/368388-throttle-debounce/code/throttle-debounce.js?version=599402 // @noframes // @run-at document-idle // ==/UserScript== const container = document.createElement('div') container.id = 'progressContainer' container.style.cssText = 'text-align:right;font-size:larger;color:#e91e63;margin-left:0.5em' function updateDisplay({ target: { duration, currentTime } }) { container.innerText = isNaN(duration) ? '' : HHMMSS(duration, currentTime) } function HHMMSS(length, time) { const currentTime = Math.round(time * 100) / 100 const duration = Math.round(length * 100) / 100 const sec_num = parseInt(duration - currentTime, 10) let hours = Math.floor(sec_num / 3600) let minutes = Math.floor((sec_num - (hours * 3600)) / 60) let seconds = sec_num - (hours * 3600) - (minutes * 60) if (hours < 10) hours = '0' + hours if (minutes < 10) minutes = '0' + minutes if (seconds < 10) seconds = '0' + seconds return `${hours}:${minutes}:${seconds}` } function waitForElement(selector) { return new Promise(resolve => { const el = document.body.querySelector(selector) if (el) { resolve(el) return } const observer = new MutationObserver(records => { for (const { addedNodes } of records) { for (const el of addedNodes) { if (el instanceof HTMLElement && el.matches(selector)) { observer.disconnect() resolve(el) return } } } }) observer.observe(document.body, { childList: true, subtree: true }) }) } function watchLiveButton(btn) { const check = () => { const visible = getComputedStyle(btn, null).display != 'none' container.style.display = visible ? 'none' : 'inline-block' return visible } const observer = new MutationObserver(records => { debounce(300, true, () => { for (const record of records) { if (record.attributeName != 'disabled') continue if (!check()) break } }) }) observer.observe(btn, { attributes: true }) check() } async function initialize() { const video = await waitForElement('#movie_player video') video.addEventListener('timeupdate', throttle(1000, updateDisplay)) const renderer = await waitForElement('yt-view-count-renderer') renderer.appendChild(container) watchLiveButton(await waitForElement('.ytp-time-display .ytp-button')) } if (window.location.pathname == '/watch') { initialize() } else { window.addEventListener('yt-navigate-finish', function() { window.removeEventListener('yt-navigate-finish', arguments.callee) initialize() }) }
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址