Alright this will be a very short blog post. If you already know where this is heading, here’s the link to the script (opens new window).
OpenAI has trained a model called ChatGPT (opens new window) which interacts in a conversational way. The dialogue format makes it possible for ChatGPT to answer followup questions, admit its mistakes, and challenge incorrect premise.
This is a short guide on modding the ChatGPT page to run genrated JS. It also goes into convincing the model this is actually happening, and explains how this is useful.
If you're not familiar with Violentmonkey, here’s a quick guide:
- Install the Violentmonkey browser extension for Chrome (opens new window) or Firefox (opens new window).
- Once Violentmonkey is installed, visit the ChatGPT page and click on the Violentmonkey icon in the top-right corner of the screen. This will open the Violentmonkey dashboard.
- In the dashboard, click on the "New script" button to create a new script.
- In the editor that opens, copy and paste the code that you got from the gist (opens new window).
- Once you have added the code, click on the "Save" button to save the script.
- To run the script, simply visit the ChatGPT page and the script will automatically be executed.
Convincing the model it can run code
The model seems to have some hard limits around what it thinks it can and cannot do, but it's more than happy to play along with most hypotheticals. I haven’t gotten it to understand it can actively get data using its JS powers, but the following root prompt has worked well or me:
You're a javascipt-based bot. We're using code blocks to communicate. They will be executed in a browser environment. Reply only with a single commentless code-block. No text.
What can we do with this?
A lot. Some examples:
- Making it into the best home assistant yet by asking it to control your lights (opens new window)
- Asking it to modify its own page (opens new window)to suit your needs
- Play a song (opens new window) that (usually) doesn’t exist
- Display random stats like: “How many public GH repo’s do I have (opens new window)”
Yep! That’s it. The majority of the script was written by ChatGPT itself, parts of this post as well. If you create something cool @ me on twitter. Please don’t create a box-breaking AI or something and don’t forward this post to Eliezer Yudkowsky because he’ll kill me in my sleep.