moderator-toolbox-nxg-for-reddit / modules/modmail/dom

modules/modmail/dom

Functions

createModmailHandlers()

createModmailHandlers(__namedParameters): ModmailHandlers

Defined in: extension/data/modules/modmail/dom.ts:229

Creates DOM handlers for the Modmail module, configured according to the given settings.

Uses vanilla DOM manipulation throughout because the features require operating inside Reddit’s own shadow DOM, which React cannot reach.

Parameters

__namedParameters

ModmailSettings

Returns

ModmailHandlers

Handlers for scanning new DOM nodes and cleaning up all toolbox additions.


formatRecentModmailTimestamp()

formatRecentModmailTimestamp(date, now?): string | null

Defined in: extension/data/modules/modmail/dom.ts:58

Formats a date as a short human-readable timestamp if the message is less than 24 hours old.

Parameters

date

Date

The date to format.

now?

Date = ...

The reference point for “now”; defaults to the current time.

Returns

string | null

A formatted string like “Jun 4, 3:05 PM”, or null if the date is invalid or older than 24 hours.

Interfaces

ModmailHandlers

Defined in: extension/data/modules/modmail/dom.ts:15

Lifecycle callbacks returned by createModmailHandlers.

Properties

cleanup

cleanup: () => void

Defined in: extension/data/modules/modmail/dom.ts:17

Removes all toolbox DOM additions injected by this module instance.

Returns

void

handleMutations

handleMutations: (mutations) => void

Defined in: extension/data/modules/modmail/dom.ts:21

Processes a batch of MutationRecords, scanning any newly added elements.

Parameters
mutations

MutationRecord[]

Returns

void

scan

scan: (root) => void

Defined in: extension/data/modules/modmail/dom.ts:19

Scans root and applies all enabled modmail enhancements to any matching elements found within it.

Parameters
root

Element

Returns

void