YouTube Video Duration Checker

Shows the duration of YouTube videos on mobile browsers.

安装此脚本
作者推荐的脚本

你可能也喜欢 Youtube - Resume

安装此脚本
  1. // ==UserScript==
  2. // @name YouTube Video Duration Checker
  3. // @namespace https://greasyfork.org/en/users/670188-hacker09?sort=daily_installs
  4. // @version 2
  5. // @description Shows the duration of YouTube videos on mobile browsers.
  6. // @author hacker09
  7. // @match https://*.youtube.com/embed/*
  8. // @icon https://www.youtube.com/s/desktop/03f86491/img/favicon.ico
  9. // @run-at document-end
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. document.querySelector(".notranslate").style.display = 'unset'; //Display the time
  16. document.querySelector('.video-stream').addEventListener('timeupdate', function() { //When the YT video is playing
  17. var currentSecs = Math.floor(document.querySelector('.video-stream').currentTime % 60); //Create a variable to hold the current secs
  18. var totalSecs = Math.floor(document.querySelector('.video-stream').duration % 60); //Create a variable to hold the total mins
  19. document.querySelector(".ytp-time-current").innerText = `${Math.floor(document.querySelector('.video-stream').currentTime / 60)}:${currentSecs < 10 ? '0' + currentSecs : currentSecs}`;
  20. document.querySelector(".ytp-time-duration").innerText = `${Math.floor(document.querySelector('.video-stream').duration / 60)}:${(/^\d$/.test(totalSecs)) ? '0' + totalSecs : totalSecs}`;
  21. }); //Update the content of the time display element
  22. })();