If you use ChatGPT heavily—for research, coding, writing, or reviewing papers—you’ve probably noticed two things:
- ChatGPT often suggests useful follow-up actions like “Summarize this paper” or “Critique this answer”
- You still have to manually copy, paste, and submit those prompts
That friction adds up. This post explains how I built a Chrome extension that turns ChatGPT into a one-click prompt launcher.
What the Extension Does
1. Clickable Assistant Suggestions
Any bullet-point suggestion generated by ChatGPT becomes clickable. One click:
- Inserts the text into the input box
- Automatically submits the prompt
No typing. No copy-paste.
2. Advanced Prompt Menu Inside ChatGPT
The extension adds a floating menu with expert-level actions:
- 📄 Summarize a paper (structured, reviewer-style, methods-focused)
- 🧠 Critique reasoning or list assumptions
- ⚙️ Explain or debug code
- ✍️ Rewrite text for clarity or reviewers
Each item is fully clickable and auto-submits.
Why This Is Non-Trivial
Automating ChatGPT is harder than it looks:
- Inline scripts are blocked by Content Security Policy (CSP)
- React ignores synthetic keyboard events
- ChatGPT no longer uses a <textarea>
- Content scripts cannot directly control page JavaScript
This extension solves all of these problems properly.
Architecture Overview
content.js → UI, DOM detection, click handling
page-script.js → Trusted page-context execution
postMessage → Secure communication bridge
The content script handles the UI. The page script runs inside ChatGPT’s own context, allowing safe interaction with React-controlled inputs.
Manifest (Chrome Extension Setup)
{
"manifest_version": 3,
"name": "ChatGPT Clickable Prompts & Advanced Menu",
"version": "1.0",
"content_scripts": [
{
"matches": ["https://chatgpt.com/*"],
"js": ["content.js"],
"run_at": "document_idle"
}
],
"web_accessible_resources": [
{
"resources": ["page-script.js"],
"matches": ["https://chatgpt.com/*"]
}
]
}
The web_accessible_resources entry is critical—it allows CSP-safe script injection.
Injecting a Trusted Page Script
function injectPageScript() {
const s = document.createElement("script");
s.src = chrome.runtime.getURL("page-script.js");
document.documentElement.appendChild(s);
}
This avoids inline scripts, which ChatGPT blocks.
Handling ChatGPT’s Input Box
ChatGPT now uses a contenteditable div, not a textarea:
div[contenteditable="true"][role="textbox"]
To insert text in a way React accepts:
document.execCommand("insertText", false, text);
box.dispatchEvent(new InputEvent("input", { bubbles: true }));
Auto-Submitting the Prompt
setTimeout(() => {
const sendBtn =
document.querySelector('button[data-testid="send-button"]') ||
document.querySelector('button[type="submit"]');
if (sendBtn && !sendBtn.disabled) {
sendBtn.click();
}
}, 120);
The delay allows React to enable the Send button.
Bridging Content Script and Page Script
Because the two scripts live in different execution contexts, communication uses window.postMessage.
// content.js
window.postMessage(
{ type: "RUN_CHATGPT_PROMPT", text },
"*"
);
// page-script.js
window.addEventListener("message", event => {
if (event.data?.type === "RUN_CHATGPT_PROMPT") {
setTextAndSubmit(event.data.text);
}
});
Making Assistant Bullets Clickable
document.querySelectorAll("article li").forEach(li => {
li.style.cursor = "pointer";
li.style.textDecoration = "underline";
li.onclick = () => {
window.postMessage(
{ type: "RUN_CHATGPT_PROMPT", text: li.innerText },
"*"
);
};
});
A MutationObserver keeps this working as new messages appear.
Advanced Prompt Menu
The extension defines a reusable prompt library:
{
title: "Paper actions",
items: [
"Summarize this paper",
"Map claims to evidence",
"Identify limitations"
]
}
Each item appears as a clickable menu option inside ChatGPT.
Why This Is Powerful
- Turns prompts into UI elements
- Makes advanced usage the default
- Eliminates repetitive typing
- Scales across research, coding, and writing
Instead of remembering “good prompts,” you embed them directly into the interface.
Possible Extensions
- Ctrl-click to insert without submitting
- Prompt variables like {TOPIC}
- Prompt chaining (summarize → critique → experiments)
- Prompt history and favorites
Final Thoughts
ChatGPT is already powerful, but most users access only a small fraction of its capabilities. By embedding expert prompts directly into the UI, this extension removes friction and enables serious workflows.
Once you get used to one-click prompts, it’s hard to go back.
No comments:
Post a Comment