# API Reference
BetterCurseForge exposes a global runtime object on `window.BetterCurseForge` within the CurseForge Electron renderer process. This API allows themes, plugins, and developer scripts to inject styles, monkey-patch methods, manage settings, and listen to application events.
---
## TypeScript Definition
For TypeScript development and autocompletion:
```typescript
declare global {
interface Window {
BetterCurseForge: BetterCurseForgeAPI;
}
}
export interface BetterCurseForgeAPI {
/** Active BetterCurseForge runtime version */
readonly version: string;
/** Injects CSS dynamically into
. Returns an unmount callback. */
injectCSS(css: string): () => void;
/** Persistent settings storage */
settings: {
get(key?: string): Promise;
set(key: string, value: any): Promise;
};
/** Runtime method interception and monkey-patching */
patcher: {
before(obj: any, method: string, callback: (args: any[]) => void): () => void;
after(obj: any, method: string, callback: (args: any[], result: any) => any): () => void;
instead(obj: any, method: string, callback: (args: any[], original: Function) => any): () => void;
};
/** Event bus */
on(event: string, callback: (...args: any[]) => void): void;
off(event: string, callback: (...args: any[]) => void): void;
emit(event: string, ...args: any[]): void;
/** Internal subsystem managers */
themes: ThemeManager;
plugins: PluginManager;
ads: AdBlocker;
}
```
---
## Core API
### `BetterCurseForge.version`
- **Type**: `string`
- **Description**: The currently running BetterCurseForge runtime version.
```javascript
console.log(BetterCurseForge.version); // "1.0.0"
```
---
### `BetterCurseForge.injectCSS(css)`
Dynamically injects CSS rules into the document ``.
- **Parameters**:
- `css` *(string)*: Raw CSS string to inject.
- **Returns**: `() => void` — Function that removes the injected `