DEV Community

Cover image for YouTube: Make the Video Timer Always Visible
Andrew Elans
Andrew Elans

Posted on

YouTube: Make the Video Timer Always Visible

When listening to lectures on YouTube, I often type notes in a separate notebook. I usually want to reference the current timestamp alongside each note.

The problem is that YouTube only shows the current time when you hover over the video or toggle play/pause - then it quickly disappears. Switching windows, tapping play/pause, glancing at the time, and switching back gets old fast.

The timer lives in this element:

<span class="ytp-time-current">37:58</span>
Enter fullscreen mode Exit fullscreen mode

When the controls are hidden, the timer stops ticking. You can also grab the time in seconds from the video element directly:

document.querySelector('video').currentTime
Enter fullscreen mode Exit fullscreen mode

The Fix: Disable the Auto-Hide

YouTube's player controls are hidden by a function that publishes an autohideupdate event. Commenting out that call keeps the controls - and the timer - permanently visible.

Steps

  1. Open DevTools and find the Search panel in the bottom drawer (or press Ctrl+Shift+F).

  2. Search for autohideupdate. You'll get four hits, all in a file called base.js. At the time of writing, the URL looks like this:

    www.youtube.com/s/player/89e685a2/player_ias.vflset/en_GB/base.js
    

    The hash (89e685a2) will change with each player release.

  3. Select the result containing ...H!==U&&Q.publish("autohideupdate",U). This takes you to the relevant line in base.js.

  4. Click the Pretty Print button ({ }) to make the minified code readable.

  5. Right-click in the source pane, select Override Content, and choose a local folder for overrides.

  6. Comment out the auto-hide publish call:

    Dd = function(Q, U, q) {
        Q.GC();
        var H = J2(Q);
        q ? (Q.C |= U,
        U & 1 && Q.u2.start(),
        U & 2 && Q.ZE.start(),
        U & 2048 && Q.AG.start()) : (Q.C &= ~U,
        U & 1 && Q.u2.stop(),
        U & 2 && Q.ZE.stop(),
        U & 2048 && Q.AG.stop(),
        U & 512 && Q.hG.stop());
        Q.C & 512 && !(Q.C & 128) && g.Z6(Q.hG, Q.XZ);
        U = J2(Q);
        // H !== U && Q.publish("autohideupdate", U)
        // disabled: keeps controls always visible
    }
    
  7. Save the file, then right-click the page and choose Empty Cache and Hard Reload (DevTools must be open).

The timer is now permanently visible.

Note: DevTools must remain open for local overrides to take effect.

Top comments (0)