Plugins
Your own JavaScript, running around every message.
A plugin is JavaScript that runs when a message goes out or comes back. Use it to rewrite text, keep counters, or inject notes into the prompt.
Plugins are global: once enabled, one runs in every chat. Manage them under Plugins in the chat menu. Paste code or import a .js file.
Register a handler for one of four moments:
input request output display
A handler receives the text and returns the replacement. Return nothing to leave it untouched.
uno.registerHandler("output", (text) => {
return text.replace(/\bcolour\b/g, "color");
});Handlers run in order and never block a reply. One that throws or exceeds five seconds is skipped, and the original text goes through.
Inside a handler the uno object reads and writes the conversation. Every call returns a promise.
const name = await uno.getName();
const last = await uno.getUserLastMessage();
await uno.setChatVar("mood", "curious");
const mood = await uno.getChatVar("mood");The full set covers chat messages, character and persona fields, chat variables, lorebook entries, macro expansion, token counts, and a rate-limited https request.
Scripts written for JanitorAI run as they are, with the same context object. Whatever they leave in character.personality and character.scenario becomes that turn's prompt.
if (context.chat.last_message.toLowerCase().indexOf("storm") !== -1) {
context.character.scenario += "\nA storm is rolling in.";
}Their rules apply too: state resets every turn, so write anything worth keeping back into the scenario each time.
Plugins run in a sandboxed frame with no access to your chats, files, cookies or login. They cannot read the page or make their own network requests.
Everything a plugin reaches goes through the API above. Still, only install code you trust: a plugin can rewrite what you send and read.