Floating editor with ChatGPT prompt execution
A Tampermonkey userscript that adds a floating, resizable text editor overlay to ChatGPT with built-in prompt automation and code review.
/p (contextual prompt) and /r (raw prompt) commands to interact with ChatGPT directly from the editorChatGPT Floating Scratchpad.js into the editor/r write a fizzbuzz boilerplate in C# and press Alt+I — the line is replaced with generated code/p fill the functionClick the "E" launcher button at the bottom-left of the ChatGPT page. The floating editor window will appear.
| Button | Action |
|---|---|
| — (Minimize) | Collapses the editor to just its title bar. Click again to restore. |
| □ (Maximize) | Expands the editor to fill the entire screen with a two-column layout. Click again to restore. |
| × (Close) | Hides the editor. Click the "E" launcher to reopen. |
You can also drag the title bar to reposition the window, and drag the bottom-right corner to resize it.
When maximized, the editor splits into two side-by-side textareas:
/p — Contextual Prompt CommandThe /p command sends a prompt to ChatGPT with full editor context and replaces the command line with the response.
How to use:
/p followed by your prompt:
/p write a function that adds two numbers
What happens:
/p line marked/p ... line is replaced with the response, preserving indentationExample — building code inline:
public class Calculator {
/p write a method that divides two numbers with error handling
}
ChatGPT sees the full class context and generates a method that fits naturally.
/r — Raw Prompt CommandThe /r command sends a prompt to ChatGPT without any context or instructions — just the raw text.
How to use:
/r followed by your prompt:
/r What is the capital of France?
What happens:
/r is sent to ChatGPT as-is — no editor context, no system instructions/r ... line is replaced with ChatGPT's full responseUse /r when you want a general-purpose question answered without the editor content influencing the response.
Alt+I triggers the action for the current line under the cursor.
Behavior:
/p line — contextual prompt sent to ChatGPT, line replaced with response/r line — raw prompt sent to ChatGPT, line replaced with responseTip: You can also click the Command button in the title bar instead of using the keyboard shortcut.
Alt+C sends the entire editor content to ChatGPT for a code review. Issues are displayed in a dialog and marked directly in the editor with ⭐.
How to use:
What happens:
1>, 2>, etc.) so ChatGPT can pinpoint issuesMarker behavior:
Correct: ✅ Yes
Solves the problem: ❌ No
Summary:
Implements FizzBuzz but misses the edge case for n=0
Issues:
1. No handling for n <= 0
Suggestions:
1. Add input validation for non-positive numbers
If ChatGPT doesn't return valid JSON, the raw response is shown as a fallback.
Two action buttons sit beside the "Editor" label in the title bar:
| Button | Action |
|---|---|
| Command | Executes the current line — same as Alt+I |
| Check | Runs code check — same as Alt+C |
These work even after clicking away from the textarea — the editor remembers which textarea was last focused.
/p Write a C# class for a binary search tree with insert and search methods
Press Alt+I — the /p line is replaced with a full BST implementation.
Then press Alt+C to review the generated code. Any issues appear as ⭐ markers in the code and a summary dialog.
Fix the issues, then add more prompts inline:
/p add a delete method that handles all three cases
ChatGPT sees the full class context and generates a method that fits.
| Shortcut | Context | Action |
|---|---|---|
| Alt+I | Editor focused | Execute current line (/p contextual prompt, /r raw prompt, or alert) |
| Alt+C | Editor focused | Send editor content for code review with ⭐ markers |
| Tab | Editor focused | Insert 4 spaces |
| Shift+Tab | Editor focused | Remove up to 4 leading spaces from the current line |
| Enter | Editor focused | New line with auto-indent matching the current line |
The script injects a floating editor UI into ChatGPT's page. When you trigger a command:
All editor state (content, position, size, window mode) is persisted in localStorage.
document-idle via TampermonkeylocalStorage (tm_editor_content for text, tm_editor_window_state for window state)querySelector on #prompt-textarea and [data-testid="send-button"]<textarea> elements with automatic line redistribution based on viewport heightchatgpt.comContributions are welcome! Feel free to open issues or submit pull requests.
This project is open source. See the repository for license details.