YouTube Millisecond Timer

Показывает время воспроизведения видео с миллисекундами на YouTube

  1. // ==UserScript==
  2. // @name YouTube Millisecond Timer
  3. // @namespace https://youtube.com/
  4. // @version 1.0
  5. // @description Показывает время воспроизведения видео с миллисекундами на YouTube
  6. // @author christopher wayne
  7. // @match https://www.youtube.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. const waitForPlayer = setInterval(() => {
  16. const video = document.querySelector('video');
  17. const timeDisplay = document.querySelector('.ytp-time-current');
  18.  
  19. if (video && timeDisplay) {
  20. clearInterval(waitForPlayer);
  21. addMillisecondDisplay(video, timeDisplay);
  22. }
  23. }, 500);
  24.  
  25. function addMillisecondDisplay(video, originalDisplay) {
  26. const customDisplay = document.createElement('span');
  27. customDisplay.style.marginLeft = '10px';
  28. customDisplay.style.color = '#0ff';
  29. customDisplay.style.fontSize = '14px';
  30. customDisplay.style.fontFamily = 'monospace';
  31.  
  32. originalDisplay.parentNode.appendChild(customDisplay);
  33.  
  34. setInterval(() => {
  35. const time = video.currentTime;
  36. const minutes = Math.floor(time / 60);
  37. const seconds = Math.floor(time % 60);
  38. const milliseconds = Math.floor((time % 1) * 1000);
  39. const formatted = `${pad(minutes)}:${pad(seconds)}.${padMs(milliseconds)}`;
  40. customDisplay.textContent = formatted;
  41. }, 50);
  42. }
  43.  
  44. function pad(n) {
  45. return n.toString().padStart(2, '0');
  46. }
  47.  
  48. function padMs(ms) {
  49. return ms.toString().padStart(3, '0');
  50. }
  51. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址