All plugin JavaScript runs in the MAIN world via chrome.scripting.executeScript. An api object is injected into the IIFE scope.
- Type:
string - Unique plugin identifier (e.g.,
"p_1a2b3c4d")
- Type:
number - Current version number. Increments on each plugin save.
- Type:
string - The page URL at the time the plugin was injected.
- Type:
Record<string, unknown> - Plugin settings object. For catalog plugins, populated from the user's settings choices.
- Type:
AbortSignal - Fires when the plugin is cleaned up (removed, updated, or page unload). Use with
fetch()or custom logic:
fetch('/api/data', { signal: api.signal }).then(...)- Type:
(fn: () => void) => void - Register a function to run when the plugin is cleaned up.
- Type:
(fn: () => void, ms: number) => number - Like
setIntervalbut auto-cleared on cleanup.
- Type:
(fn: () => void, ms: number) => number - Like
setTimeoutbut auto-cleared on cleanup.
- Type:
(target: EventTarget, event: string, handler: Function, opts?: object) => void - Like
target.addEventListenerbut auto-removed on cleanup. Error-safe handler wrapper.
- Type:
(selector: string, opts?: { timeoutMs?: number }) => Promise<Element | null> - Polls every 100ms for an element. Default timeout: 4000ms.
- Type:
(css: string) => void - Persists runtime-generated CSS to chrome.storage for early injection on next page load. Does NOT bump plugin version (avoids triggering full re-apply).
- Type:
(key: string) => unknown | null - Read a value from per-plugin localStorage.
- Type:
(key: string, value: unknown) => void - Store a JSON-serializable value.
- Type:
(key: string) => void - Delete a key.
- Type:
() => string[] - List all keys for this plugin.
- Type:
() => void - Remove all stored data for this plugin.
- Type:
(url: string, opts?: { method?: string, headers?: Record<string, string>, body?: string }) => Promise<{ status: number, headers: Record<string, string>, text(): Promise<string>, json(): Promise<unknown> }> - Cross-origin fetch via background service worker proxy. Bypasses CORS restrictions.
- 30 second timeout.
- Type:
(url: string) => Promise<void> - Load an external script tag. Returns a Promise that resolves when loaded. Script is auto-removed on cleanup.
- Type:
(...args: unknown[]) => void - Logs to console with
[domo vN]prefix.