# YouTube Transcript Extraction Patterns

Common DOM selectors and JavaScript snippets for extracting transcripts from the YouTube player interface.

## DOM Selectors

| Element | Selector | Description |
| :--- | :--- | :--- |
| Transcript Segment | `.ytp-transcript-segment-text` | The text content of an individual transcript line. |
| Transcript Container | `.ytp-transcript-panel-container` | The main container for the transcript panel. |
| Subtitles/CC Button | `button[aria-label*="Subtitles"]` | The button to toggle captions. |

## JavaScript Snippets

### Extract All Transcript Text
Run this in `browser_console` once the transcript panel is visible:

```javascript
(function() {
  const segments = document.querySelectorAll('.ytp-transcript-segment-text');
  if (segments.length === 0) return "No transcript segments found. Make sure the transcript panel is open.";
  let transcript = "";
  segments.forEach(s => {
    transcript += s.innerText + " ";
  });
  return transcript;
})()
```

### Check if Transcript Panel is Open
```javascript
document.querySelector('.ytp-transcript-panel-container') !== null
```
