Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/toolbox-team/reddit-moderator-toolbox/llms.txt

Use this file to discover all available pages before exploring further.

Every discrete feature in Moderator Toolbox is implemented as a self-contained module. Each module lives in extension/data/modules/ as its own file, exports a Module instance as its default export, and declares its own settings. When Toolbox loads, tbmodule.jsx collects all registered modules, checks whether each one is enabled, and calls its initializer in parallel.

File layout

extension/data/
├── tbmodule.jsx          # Module registry and loader
├── tbapi.ts              # Reddit API helpers (TBApi)
├── tbhelpers.js          # General utility functions (TBHelpers)
├── tbui.js               # UI building utilities (TBui)
├── tblistener.js         # DOM event system (TBListener)
└── modules/
    ├── modbar.js         # Mod bar feature module
    ├── queuetools.js     # Queue tools feature module
    ├── usernotes.js      # User notes feature module
    └── ...               # One file per feature
The repo structure is currently in flux due to an ongoing React UI rewrite. The conventions described here remain the authoritative pattern for new modules, but not every existing file follows them exactly.

Creating a module

Import the Module class from tbmodule.jsx, construct an instance with your options and an initializer function, and export it as the default export.
import {Module} from '../tbmodule.jsx';

export default new Module(
    {
        name: 'My Feature',
        id: 'MyFeature',
        enabledByDefault: true,
        settings: [
            {
                id: 'showBadge',
                description: 'Show a badge on the mod bar',
                type: 'boolean',
                default: true,
            },
            {
                id: 'badgeColor',
                description: 'Badge color',
                type: 'text',
                default: '#ff4500',
                advanced: true,
            },
        ],
    },
    async function init () {
        const showBadge = await this.get('showBadge');
        if (showBadge) {
            // feature implementation
        }
    },
);

Module constructor options

The first argument to new Module() is an options object:
OptionTypeDefaultDescription
namestringHuman-readable name shown in the settings UI.
idstringname (whitespace stripped)Identifier used as a prefix for storage keys.
enabledByDefaultbooleanfalseIf true, the module is enabled on fresh installs.
alwaysEnabledbooleanfalseIf true, the module cannot be disabled by the user.
debugbooleanfalseIf true, the module only appears when Toolbox debug mode is on.
oldRedditbooleanfalseMarks the module as Old Reddit-only in the settings interface.
settingsSettingDefinition[][]Array of setting definitions (see below).
The second argument is the initializer function — an async function that runs when Toolbox loads and the module is enabled. Inside the initializer, this refers to the Module instance, so you can call this.get(id) to read settings.

Real-world example: Modbar

The following is taken directly from extension/data/modules/modbar.js:
import {Module} from '../tbmodule.jsx';

export default new Module({
    name: 'Modbar',
    id: 'Modbar',
    alwaysEnabled: true,
    settings: [
        {
            id: 'compactHide',
            description: 'Use compact mode for modbar',
            type: 'boolean',
            default: false,
            advanced: true,
        },
        {
            id: 'unmoderatedOn',
            description: 'Show icon for unmoderated',
            type: 'boolean',
            default: true,
        },
        {
            id: 'enableModSubs',
            description: 'Show Moderated Subreddits in the modbar',
            type: 'boolean',
            default: true,
        },
        {
            id: 'enableOldNewToggle',
            description: 'Include a button in the modbar to swap between old and new Reddit',
            type: 'boolean',
            default: true,
        },
        // ...
    ],
}, async function init () {
    // module initialization code
});

Setting types

Each object in the settings array is a SettingDefinition. The required fields are id, type, and default. Optional flags (advanced, debug, hidden) control visibility in the settings UI.

boolean

A checkbox. default should be true or false.

number

A numeric input. default should be a number.

text

A single-line text input.

textarea

A multi-line text area.

selector

A dropdown. Requires a values array of option strings.

array

An editable list of strings.

code

A CodeMirror-backed code editor, suitable for custom CSS or JS snippets.

How modules are loaded

tbmodule.jsx exports a TBModule registry object. Each module file registers itself when imported. On page load, TBModule.init() iterates all registered modules, skips any that are disabled or filtered out (debug mode, Old Reddit check), and calls module.init() on the rest — all in parallel via Promise.all.
// Simplified from tbmodule.jsx
await Promise.all(TBModule.modules.map(async module => {
    if (!await module.getEnabled()) return;
    await module.init();
}));

TBListener.start(); // DOM event listener starts after all modules initialize

Utility references

Toolbox provides several shared utilities you can import from the core files:

TBApi

Reddit API helpers — reading and writing wiki pages, fetching mod lists, and more. Imported from ../tbapi.ts.

TBHelpers

General-purpose utility functions such as time formatting, string manipulation, and subreddit parsing. Imported from ../tbhelpers.js.

TBui

UI building helpers for constructing Toolbox interface elements and dialogs. Imported from ../tbui.js.

TBListener

DOM event system for reacting to Reddit page mutations without polling. Imported from ../tblistener.js.
Before implementing a new utility function, check the JSDoc source documentation — there is a good chance what you need already exists in one of the core files.

Build docs developers (and LLMs) love