Skip to content

Instantly share code, notes, and snippets.

@humphd
Created July 24, 2023 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save humphd/2168e398b6ba83d3fe579f63f429ef13 to your computer and use it in GitHub Desktop.
Save humphd/2168e398b6ba83d3fe579f63f429ef13 to your computer and use it in GitHub Desktop.
CharCraft JS Runtime function
export const name = "runJS";
export const description = "Runs arbitrary JavaScript code in a browser context (no node.js)";
export const parameters = {
type: "object",
properties: {
"code": {
type: "string",
description: "JavaScript code to run in browser",
}
}
};
export default async function (data) {
const { code } = data;
let result;
try {
result = eval(code);
} catch (error) {
result = error.toString();
}
return result.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment