Skip to content

Latest commit

 

History

History
30 lines (16 loc) · 1.88 KB

File metadata and controls

30 lines (16 loc) · 1.88 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Overview

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.

Architecture

The entire project is a single file: summarize-yt.user.js.

The script runs on two domains and has two logical sections:

  1. YouTube part (youtube.com): Waits for the ytd-menu-renderer element to appear, then injects two native-looking YouTube buttons into the video action menu. Each button stores a prompt string (containing the video URL) via GM_setValue and opens gemini.google.com in a new tab.

  2. Gemini part (gemini.google.com): On page load, reads the stored prompt via GM_getValue. If a payload exists, it waits for the Gemini chat input and send button, injects the text using document.execCommand('insertText'), and clicks send after a short delay. Clears the stored payload afterward.

Deployment

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.

Required Userscript Grants

  • GM_setValue / GM_getValue / GM_deleteValue — cross-tab storage to pass the prompt from YouTube to Gemini
  • GM_openInTab — opens Gemini in a new active tab

Known Constraints

  • No innerHTML on YouTube pages: YouTube enforces a Trusted Types Content Security Policy that blocks all direct innerHTML assignments. All DOM construction in the YouTube part must use document.createElement / appendChild / setAttribute.