Lifecycle and cleanup
Give every script a clear owner and a predictable stop path.
Contract 1.0.0 · JavaScript executor documentation
The scorpionScript helper
scorpionScript.signal; // AbortSignal
scorpionScript.onCleanup(() => { /* synchronous cleanup */ });
scorpionScript.own(detachedElement); // Track a detached DOM node
scorpionScript.stop(); // Stop this scriptRegister synchronous cleanup functions. Create and register a detached node before inserting it into the document. The helper refuses ownership of an existing page node. Timers, animation callbacks and listeners created through the supported browser APIs are tracked for the script.
A working DOM overlay example
const label = scorpionScript.own(document.createElement("div"));
label.textContent = "Scorpion script running";
label.style.cssText = "position:fixed;top:16px;left:16px;color:#28c2e5;z-index:10";
document.body.append(label);
let seconds = 0;
setInterval(() => {
label.textContent = `Scorpion · ${++seconds}s`;
}, 1000);
scorpionScript.onCleanup(() => console.log("Overlay released"));This example uses the browser DOM and the real lifecycle helper. It does not use the paid game SDK or simulate native game controls.
Cleanup boundaries
Callbacks that throw are reported and stop the owning script. Cleanup continues even when one cleanup callback fails. Asynchronous cleanup is unsupported. Avoid unmanaged global state and direct changes to existing game objects.
Storage and plugins
The editor library and drafts are stored locally by the extension. Community scripts cannot read extension credentials, private extension storage or the paid SDK. A public per-script persistent storage API, plugin registry and UI registration API are not available in this version. The lifecycle helper does not provide those capabilities.