Execute an XHR request in the user's logged-in Gemini page via Chrome AppleScript to call a preconfigured Gem (8c99566ee291) to transcribe a YouTube video. The browser automatically carries HttpOnly cookies, so authentication does not need to be managed separately.
Script Directory
Determine the directory where SKILL.md is located to find the script:
SKILL_DIR="$(cd "$(dirname "$0")" && pwd)"
| Script | Purpose | Key Parameters |
|---|---|---|
scripts/transcribe.ts |
Transcribe YouTube video | --thinking, -o |
Execution method: npx -y bun $SKILL_DIR/scripts/transcribe.ts [options] <youtube-url>
Prerequisites
- macOS: Depends on AppleScript, macOS only
- Chrome is logged in to Gemini: You must be logged in to
gemini.google.com - Allow AppleScript JavaScript: Chrome → View → Developer → Allow JavaScript from Apple Events
If the user has not enabled item 3, the script will report an error and prompt with the operating steps.
Usage
# 基本转写(默认使用 think 级别)
npx -y bun $SKILL_DIR/scripts/transcribe.ts <youtube-url>
# 指定思考级别
npx -y bun $SKILL_DIR/scripts/transcribe.ts --thinking pro <youtube-url>
# 保存到文件
npx -y bun $SKILL_DIR/scripts/transcribe.ts -o transcript.md <youtube-url>
Parameter Description
| Parameter | Description | Default Value |
|---|---|---|
<youtube-url> |
YouTube video link (required) | - |
--thinking <level> |
Thinking level (see table below) | think |
-o, --output <path> |
Output file path | stdout |
Thinking Level
| Level | Model | Description |
|---|---|---|
fast |
Gemini Flash | Fastest, fewer details |
think |
Gemini Flash Thinking | Default, balances speed and quality |
pro |
Gemini Pro | Most detailed, slower |
How It Works
- Use AppleScript to find the already open
gemini.google.comtab in Chrome - Extract from the page source
SNlM0eaccess token - Construct an API request containing the Gem ID and YouTube URL
- Send the request via synchronous XHR (the browser automatically carries HttpOnly cookies)
- Parse the streaming response and extract the generated transcript
- Output to stdout or save to the specified file
Output Handling
- No
-o: The transcript is output to stdout (logs are output to stderr) - With
-o: Write to the specified file and inform the user of the file path
Error Handling
| Error | Cause | Handling |
|---|---|---|
| AppleScript JavaScript not enabled | Chrome setting not enabled | Prompt: View → Developer → Allow JavaScript from Apple Events |
| no_token | Token extraction failed | Refresh the gemini.google.com page and retry |
| status_4xx/5xx | API request failed | Check login status and retry |
| missing value | No response | Confirm that Chrome is logged in to gemini.google.com |
| parse_failed | Response parsing failed | The video may be unavailable or the Gem cannot process it |