moderator-toolbox-nxg-for-reddit / modules/modmatrix/dom
modules/modmatrix/dom¶
Functions¶
createModMatrixHandlers()¶
createModMatrixHandlers(
subredditUrl,subredditName):object
Defined in: extension/data/modules/modmatrix/dom.tsx:366
Creates event handlers for the “moderation log matrix” button, managing popup open/close state.
Parameters¶
subredditUrl¶
string | null
subredditName¶
string | null
Returns¶
object
An object with a handleButtonClick method to attach to the button’s click event.
createModMatrixSetup()¶
createModMatrixSetup():
object
Defined in: extension/data/modules/modmatrix/dom.tsx:268
Sets up the modLogControls UI location for the current page and returns subreddit metadata.
Old Reddit: queries the menuarea synchronously and provides the location immediately. Shreddit: tries to insert the controls anchor immediately; if the element is not yet present (shreddit renders asynchronously), spins up an internal MutationObserver that retries. The observer is managed by the returned cleanup - no lifecycle argument needed.
Call lifecycle.mount(setup.cleanup) in index.ts.
Returns¶
object
{subredditUrl, subredditName, cleanup}.
cleanup¶
cleanup: () =>
void
Returns¶
void
subredditName¶
subredditName:
string|null
subredditUrl¶
subredditUrl:
string|null
getSubredditName()¶
getSubredditName(
url):string|null
Defined in: extension/data/modules/modmatrix/dom.tsx:185
Extracts the subreddit name from a Reddit URL.
Parameters¶
url¶
string | null
Returns¶
string | null
The subreddit name (e.g. "example"), or null if the URL is null or does not match.
getSubredditUrl()¶
getSubredditUrl():
string|null
Defined in: extension/data/modules/modmatrix/dom.tsx:175
Reads the current subreddit URL from old Reddit’s page header.
Returns¶
string | null
The subreddit URL with a trailing slash, or null if not found.
insertShredditControlsAnchor()¶
insertShredditControlsAnchor():
HTMLSpanElement|null
Defined in: extension/data/modules/modmatrix/dom.tsx:192
Inserts a container <span> before the shreddit mod insights button and returns it, or null if not yet present.
Returns¶
HTMLSpanElement | null
showMatrixPopup()¶
showMatrixPopup(
subredditUrl,subredditName,onPopupClose?,initialActions?,initialModerators?): () =>void
Defined in: extension/data/modules/modmatrix/dom.tsx:214
Mounts the Mod Log Matrix popup and returns a cleanup function that unmounts it.
Parameters¶
subredditUrl¶
string | null
URL of the subreddit the matrix is for, or null to read from the page.
subredditName¶
string | null
Bare name of the subreddit, or null to read from the page.
onPopupClose?¶
() => void
Optional callback invoked when the popup is closed by the user.
initialActions?¶
Record<string, ActionInfo>
Pre-populated action types; falls back to reading from the page’s DOM.
initialModerators?¶
Record<string, Record<string, number>>
Pre-populated moderator map; falls back to reading from the page’s DOM.
Returns¶
A function that removes the popup from the DOM.
() => void