Skip to content

mbogdan0/youtube-transcript

Repository files navigation

YouTube Copy Transcript

Chrome MV3 No Dependencies Localized

A focused Chrome extension for copying YouTube subtitles as clean, timestamped plain text. Open a video, choose the subtitle track, copy the transcript, and paste it anywhere.

YouTube Copy Transcript preview

Video title

(0:00) First aggregated paragraph from several caption fragments.
(0:48) Next paragraph with a readable timestamp.

Highlights

  • Copies YouTube transcripts from a compact popup.
  • Supports manual and auto-generated caption tracks.
  • Preserves useful timestamps while grouping tiny caption fragments into readable paragraphs.
  • Cleans caption markup, HTML entities, repeated rolling captions, and excess whitespace.
  • Picks the subtitle track closest to the browser UI language when available.
  • Uses Chrome i18n for a localized popup interface.
  • Ships with a dependency-free build pipeline for Chrome Web Store ZIPs.
  • Requests only the activeTab permission and no persistent host permissions.

Install For Development

  1. Open chrome://extensions.
  2. Enable Developer mode.
  3. Click Load unpacked.
  4. Select this project folder.
  5. Open a YouTube watch page and click the extension icon.

Usage

  1. Navigate to a YouTube video with subtitles.
  2. Open the extension popup.
  3. Select the subtitle language.
  4. Click Copy transcript.

The copied output starts with the video title, followed by timestamped transcript paragraphs.

Build

npm run verify
npm run build

The build script creates:

dist/youtube-copy-transcript-<version>.zip

The ZIP includes the manifest, popup, content scripts, icons, locale files, and README.

Release

npm run release -- 0.2.0

The release script:

  1. Updates manifest.json.
  2. Updates package.json.
  3. Builds the Chrome Web Store ZIP.
  4. Runs verification checks.

Verification

npm run verify

The verifier checks:

  • Manifest V3 shape.
  • Permission scope.
  • Referenced file existence.
  • JavaScript syntax.
  • Forbidden extension-code patterns.
  • Required locale files and message keys.
  • Version parity between package.json and manifest.json.

Architecture

File Purpose
manifest.json Chrome MV3 manifest, popup action, icons, permissions, and YouTube content scripts.
page-bridge.js Runs in the page's main world and reads the live YouTube player caption metadata.
transcript.js Fetches caption data, falls back when needed, cleans fragments, and aggregates paragraphs.
content.js Bridges popup messages to the transcript API exposed in the content script.
popup.html Popup markup and user-facing controls.
popup.css Popup styling.
popup.js Popup state, localization, track selection, and clipboard copy flow.
_locales/ Chrome i18n message files.
icons/ Extension icons.
scripts/build.js Dependency-free ZIP builder.
scripts/verify.js Pre-publish validation.
scripts/release.js Version bump, build, and verification workflow.

Transcript Strategy

The extension asks YouTube's live player for caption tracks, then tries multiple transcript sources:

  1. Caption track download in json3 format.
  2. Caption track download in XML format.
  3. XML retry with a harvested pot token when YouTube requires it.
  4. DOM transcript panel scraping as a final fallback.

Fragments are de-duplicated and merged into paragraphs using span and character thresholds, with soft breaks at sentence boundaries when possible.

Privacy

The extension is designed to work on the active YouTube tab only.

  • No analytics.
  • No external services.
  • No background server.
  • No persistent host permissions.
  • Caption downloads use credentials: "omit" where the browser allows it.

Downloading caption files does not report playback progress to YouTube, so copying a transcript does not mark a video as watched.

Localization

The popup follows the browser UI language through Chrome's _locales mechanism.

Supported locales:

en, es, pt_BR, fr, de, it, nl, pl, uk, tr, ar, hi,
id, vi, th, zh_CN, zh_TW, ja, ko, cs, ro, sv, da, ms

Project Requirements

  • Google Chrome or another Chromium browser with Manifest V3 support.
  • Node.js for build, release, and verification scripts.

No npm dependencies are required.

About

Chrome extension to copy YouTube subtitles as clean, timestamped plain text.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages