How to Copy Udemy Video Transcripts with JavaScript?

Watching 20-minute video lectures can be slow.

Sometimes I prefer reading the text directly. Copying the lecture transcript into Claude, Codex, or ChatGPT makes learning much faster.

Once the transcript is in the chat, you can ask for explanations in plain English. You can ask for ASCII architecture diagrams. You can also generate targeted code examples.

The problem is Udemy.

Udemy has a transcript panel. But it does not offer a download button.

If you try to highlight and copy the text manually, you only get a few lines. Udemy unloads off-screen lines to save memory. You only see what is currently on screen.

Here is a short JavaScript snippet to solve that.

How to Run It in the Browser?

You do not need to install browser extensions. You only need Chrome DevTools.

Follow these steps:

  1. Open the Udemy lecture in your browser.
  2. Click Transcript below the video to open the side panel.
  3. Pause the video.
  4. Press F12 (or Ctrl + Shift + J on Windows) to open Developer Tools.
  5. Switch to the Console tab.
  6. Paste the script below and press Enter.

The script will scroll through the panel. Once it finishes, it copies the full transcript to your clipboard.

The JavaScript Snippet

Paste this code directly into your browser console:

(async () => {
  const panel = document.querySelector(
    '[data-purpose="transcript-panel"]'
  );

  if (!panel) {
    console.error("Open the Udemy Transcript panel first.");
    return;
  }

  const sleep = ms => new Promise(r => setTimeout(r, ms));
  const seen = new Set();
  const lines = [];

  const collect = () => {
    const cues = panel.querySelectorAll(
      '[data-purpose="transcript-cue"]'
    );
    const elements = cues.length
      ? cues
      : panel.querySelectorAll('[data-purpose="cue-text"]');

    for (const el of elements) {
      const text = (
        el.querySelector('[data-purpose="cue-text"]')?.innerText ||
        el.innerText
      ).trim();

      if (text && !seen.has(text)) {
        seen.add(text);
        lines.push(text);
      }
    }
  };

  const scroller = [panel, ...panel.querySelectorAll('*')]
    .filter(el => el.scrollHeight > el.clientHeight + 20)
    .sort((a, b) =>
      (b.scrollHeight - b.clientHeight) -
      (a.scrollHeight - a.clientHeight)
    )[0];

  if (scroller) {
    scroller.scrollTop = 0;
    await sleep(300);
  }

  for (let i = 0; i < 200; i++) {
    collect();
    if (!scroller) break;

    const before = scroller.scrollTop;
    scroller.scrollTop += Math.max(
      100, scroller.clientHeight * 0.7
    );

    await sleep(100);
    if (scroller.scrollTop === before) break;
  }

  collect();

  if (!lines.length) {
    console.error("No transcript text found.");
    return;
  }

  const transcript = lines.join("\n");
  copy(transcript);

  console.log(`Copied ${lines.length} transcript lines!`);
})();

Once copied, paste the text into your AI assistant and start asking questions.

How to Turn This Into a Chrome Extension?

Opening DevTools for every video can get repetitive.

If you want a one-click button, you can ask an AI agent to build a Chrome extension. Tools like Claude, Codex, or Antigravity can turn this snippet into a manifest v3 extension in minutes.

Just paste the script into the prompt. Ask it to trigger the script on a button click in your browser toolbar.

Want my posts to show up more often on Google?

One click and Google will surface this site in your Top Stories.

Add as preferred source
Suraj Katwal
Written by

Suraj Katwal

Digital marketer, data enthusiast, and developer based in Melbourne, originally from Nepal. I build web platforms, Flutter apps, and digital marketing campaigns. On the data side, I work with SQL and Python while growing into dbt and data pipeline tools.