Skip to content

dnlskeen/yt-transcript-extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

📋 YouTube Transcript Extractor

Instant YouTube subtitle extraction for Safari — no login, no tracking, no BS.

A lightweight userscript that adds a floating button to YouTube for one-click transcript extraction. Works with Safari (via Userscripts) and any browser with userscript manager support (Tampermonkey, Violentmonkey, Greasemonkey).

License Version

✨ Features

  • Instant extraction — intercepts YouTube's internal subtitle loading, works in ~1 second regardless of video length
  • 🌍 Language switching — choose between all available subtitle tracks right in the modal
  • 📋 One-click copy — copy full transcript to clipboard (Safari-compatible via execCommand)
  • 💾 Download as TXT — save transcript as a text file
  • 🎨 Clean dark UI — modal with video title, line/char count, keyboard shortcuts
  • 🔒 Zero tracking — no accounts, no analytics, no data collection
  • 🆓 100% free & open source

🖥️ Demo

  1. Open any YouTube video with subtitles
  2. Click the red 📋 Copy Transcript button (bottom-right corner)
  3. Modal appears with full transcript text
  4. Copy, download, or switch language

📦 Installation

Safari (macOS / iOS)

  1. Install Userscripts from the App Store
  2. Set a directory for your scripts in the extension settings
  3. Download yt-transcript-extractor.user.js and place it in that directory
  4. Enable the extension in Safari → Settings → Extensions
  5. Open any YouTube video — the button appears automatically

Chrome / Firefox / Edge

  1. Install Tampermonkey or Violentmonkey
  2. Click Install Userscript or create a new script and paste the contents
  3. Open any YouTube video

🔧 How It Works

Most YouTube transcript tools try to fetch() the subtitle URL directly — but YouTube blocks these requests, returning empty responses (Content-Length: 0).

This script takes a different approach:

  1. Intercepts XMLHttpRequest — patches XHR.prototype.open/send to listen for YouTube's internal timedtext API calls
  2. Triggers subtitle reload — calls player.setOption('captions', 'reload', true) which forces the YouTube player to re-fetch subtitles through its own internal mechanism (which works because the player has the right cookies/headers)
  3. Captures the response — grabs the full JSON3 subtitle data from the intercepted XHR
  4. Parses and deduplicates — extracts text segments, removes consecutive duplicates, joins into clean text

This is why it works where direct API calls fail — we're reading the data that YouTube's own player successfully fetches, not making our own requests.

⌨️ Keyboard Shortcuts

Key Action
Esc Close modal

🌐 Browser Compatibility

Browser Userscript Manager Status
Safari (macOS) Userscripts ✅ Primary target
Safari (iOS) Userscripts ✅ Should work
Chrome Tampermonkey / Violentmonkey ✅ Works
Firefox Tampermonkey / Violentmonkey / Greasemonkey ✅ Works
Edge Tampermonkey ✅ Works

📝 Notes

  • Only works on videos that have subtitles (auto-generated or manual)
  • Prefers subtitles in this order: Russian → English → first available
  • YouTube SPA navigation is supported — button appears/disappears as you navigate

🤝 Contributing

Contributions are welcome! Feel free to open issues or submit PRs.

📄 License

MIT


Built with frustration and determination when no Safari extension could do this simple thing. 🦞

About

Userscript Instant YouTube transcript extraction for Safari

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors