Plugins
Your own JavaScript, running safely around every message.
A plugin is JavaScript you write that runs whenever a message goes out or comes back. Use it to rewrite text, keep your own 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, where you can 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 takes longer than 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. They get the same context object, and 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.
Anything a plugin reaches goes through the API above, so it only ever sees what a handler is given. Still, only install code you trust: a plugin can rewrite what you send and what you read.