How romanverdysh/tampermonkey-menu-chatgpt works
Project Type and Purpose
• This is an open-source Tampermonkey userscript (“Claude & ChatGPT.js”) that injects a custom prompt menu into the ChatGPT and Claude.ai web interfaces.
File Structure Analysis
• Top-level files:
• README.md – installation and usage instructions
• LICENSE
• chatGPT.js – module handling injection & API calls for ChatGPT’s web UI
• claudeAI.js – analogous module for Claude.ai’s web UI
• “Claude & ChatGPT.js” – the combined userscript (could be the concatenation or entry point)
• No backend services, build scripts, or databases—everything runs client-side in the browser via Tampermonkey.
Key Insights from README
• Two modes (ChatGPT vs. Claude.ai) unified into one script.
• UI elements: collapsible menu, scroll support, draggable window.
• Prompt functions live in a “ВСЕ СВОИ ФУНКЦИИ ВСТАВЛЯТЬ СЮДА” section.
• Utility functions for single/dual-input windows and prompt execution.
a. Main Components
– Browser (Chrome)
– Tampermonkey Extension
– Userscript (“Claude & ChatGPT.js”)
· UI Layer (menu panel, headers, buttons)
· Prompt Manager (functions defining templates: checkSenseArticle(), achesAndPainsCA(), semanticProximity(), etc.)
· Input Handler (customInputWindow())
· Executor (executeChatCommand())
· Integration Modules
• ChatGPT Module (DOM selectors & injection logic in chatGPT.js)
• Claude.ai Module (DOM selectors & injection logic in claudeAI.js)
– External Web Apps
· ChatGPT Web Interface → OpenAI backend
· Claude.ai Web Interface → Claude backend
b. Relationships & Data Flow
1. User opens ChatGPT or Claude.ai page in browser.
2. Tampermonkey loads the userscript.
3. Script injects a draggable, collapsible menu UI into the page DOM.
4. User clicks a custom-prompt button.
5. Input Handler (if needed) prompts for variables.
6. Prompt Manager constructs the template string.
7. Executor inserts the prompt into the chat input field and triggers “Send.”
8. Web app forwards the prompt to its backend service; response is rendered in the chat window.
c. Architectural Patterns & Principles
– Modular separation: UI layer vs. prompt definitions vs. injection logic
– Single responsibility: each prompt function only defines its template
– Extension-script integration: leverages Tampermonkey’s sandbox and GM_ APIs if used
– Event-driven: button clicks drive the entire workflow
d. Key Technologies & Libraries
– Tampermonkey userscript environment (GM_ APIs, @match metadata)
– Plain JavaScript for DOM manipulation
– ChatGPT/Claude web frontends (selectors may need updates if UI changes)