How to write a userscript with AI
18 October 2026 · 4 min read
Quick answer
You can ask a chat assistant to write a userscript and paste it into a manager like Tampermonkey, but the assistant can't see the page, so it guesses at how the page is built and the script often finds nothing. Building the script from the page itself, where the AI can read its structure, works far more often.
What a userscript is
A userscript is a small JavaScript program that runs on websites you choose, after the page loads. It can add a button, hide a panel, reformat a table, fill a form or export data. Userscripts have been around for more than twenty years, run by managers such as Greasemonkey, Violentmonkey and Tampermonkey. What's new is that you no longer have to write them yourself.
How a userscript is put together
Every userscript starts with a header, a block of comments that tells the manager what the script is and where to run it:
// ==UserScript==
// @name Copy title as Markdown
// @match https://example.com/*
// @grant none
// ==/UserScript==
@nameis the label you'll see in the manager.@matchsays which pages the script runs on. The star matches anything, so the line above means every page on example.com.@grantlists special abilities the script needs from the manager, such as storing values or making requests to other sites.nonemeans it needs none of them.
Below the header is ordinary JavaScript that works with the page: finding the main heading, creating a button, and copying text when the button is clicked.
The manual way: a chat assistant and a manager
The common way to get a userscript written by AI:
- Install a userscript manager, such as Tampermonkey, from the Chrome Web Store.
- Ask ChatGPT, Claude or Gemini for a userscript that does what you want on the site.
- Create a new script in the manager, paste the code in, and save.
- Reload the site and see whether it works.
For simple scripts it often does. The trouble starts with step 4. The assistant has never seen the page. It has to guess what the heading, the list or the button you mean is called in the page's code, and modern sites use generated names that no one could guess. The script runs, finds nothing, and does nothing, with no error you can see. You then copy pieces of the page's code back into the chat, explain what went wrong, paste the new version, and try again. Several rounds are normal.
Chrome also asks for one more step now. Since its extension changes, userscript managers need Allow user scripts turned on for them in chrome://extensions, under the extension's Details, before scripts run.
Make it permanent with a tool
The fix is to let the AI see the page. ScriptPanda is a Chrome extension that writes userscripts from a plain description while you're on the page. When you send a request, it sends your words, the page's address and a trimmed outline of the page's structure, not a screenshot and not the full page, so it can find the real heading, list or button. It then writes the script, installs it on the page and runs it, so you see straight away whether it does what you asked.
Paste the request at the end of this guide on any article page and you'll get a Copy title button next to the heading. If something isn't right, say what's wrong and ScriptPanda changes the script. If you know JavaScript, you can open any tool's code in its editor and change it yourself.
ScriptPanda needs Chrome 138 or later and, like other managers, Allow user scripts turned on for it.
Limits
A userscript runs inside the page, in your browser, while the page is open. It can't run in the background, on a schedule, or while Chrome is closed, and it works one site at a time. ScriptPanda builds one tool per page and doesn't import or run existing Tampermonkey scripts, so it isn't a replacement manager for scripts you already have. If the site changes its layout, a script can stop finding what it needs. Open ScriptPanda on the page, say what broke, and ask it to fix the tool.
Do it with ScriptPanda
Build it in one request
Write a userscript for this page that adds a Copy title button next to the main heading, which copies the page title and URL as a Markdown link.
- 1Add ScriptPanda to Chrome.
- 2Open the side panel on the site you want to change.
- 3Paste the request and send it. ScriptPanda builds the tool into the page.