This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Tampermonkey/Greasemonkey userscript that adds "Summarize" and "Answer title" buttons to YouTube video pages. When clicked, a button stores a prompt in userscript storage and opens Gemini, which then automatically pastes and submits the prompt.
The entire project is a single file: summarize-yt.user.js.
The script runs on two domains and has two logical sections:
-
YouTube part (
youtube.com): Waits for theytd-menu-rendererelement to appear, then injects two native-looking YouTube buttons into the video action menu. Each button stores a prompt string (containing the video URL) viaGM_setValueand opensgemini.google.comin a new tab. -
Gemini part (
gemini.google.com): On page load, reads the stored prompt viaGM_getValue. If a payload exists, it waits for the Gemini chat input and send button, injects the text usingdocument.execCommand('insertText'), and clicks send after a short delay. Clears the stored payload afterward.
Install via a userscript manager (Tampermonkey, Violentmonkey, etc.) by opening summarize-yt.user.js directly. The @match directives in the script header control which pages it runs on. See README.md for end-user instructions.
GM_setValue/GM_getValue/GM_deleteValue— cross-tab storage to pass the prompt from YouTube to GeminiGM_openInTab— opens Gemini in a new active tab
- No
innerHTMLon YouTube pages: YouTube enforces a Trusted Types Content Security Policy that blocks all directinnerHTMLassignments. All DOM construction in the YouTube part must usedocument.createElement/appendChild/setAttribute.