← All examples

JavaScript Developer & QA youtube.com

YouTube: log video technical info

Prints the resolution, duration, speed and metadata of the currently playing video to the console.

Code to copy

// Log technical details of the current video to the console
const v = document.querySelector('video.html5-main-video');
const p = document.querySelector('.html5-video-player');
if (v) {
  console.group('YouTube video info');
  console.log('resolution :', v.videoWidth + 'x' + v.videoHeight);
  console.log('duration   :', v.duration.toFixed(1) + 's');
  console.log('current    :', v.currentTime.toFixed(1) + 's');
  console.log('rate       :', v.playbackRate + 'x');
  if (p && p.getVideoData) console.log('videoData  :', p.getVideoData());
  console.groupEnd();
} else {
  console.warn('No video element found on this page.');
}

How to use this example

  1. Copy the code with the button above.
  2. Install JustZix (2 minutes) and open the extension on the target page.
  3. Add a new rule matching that page.
  4. Paste the code into the rule's JavaScript panel and save — it runs on every page visit.

Rate this example

No ratings yet — be the first.

Does this example work?

Snippets are useless without somewhere to paste them.

JustZix takes 2 minutes to install and runs your code on every matching page. No account, no payment.

Download free See use cases