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

modules/comment/dom

Functions

applyHighlight()

applyHighlight(target, subreddit, highlighted): Promise<void>

Defined in: extension/data/modules/comment/dom.tsx:44

Checks whether subreddit is moderated by the current user and, if so, highlights all keyword matches within the comment markdown elements nearest to target.

Parameters

target

Element

Element from which to search upward for comment content containers.

subreddit

string

Subreddit name to check for mod status.

highlighted

string[]

Keywords to highlight.

Returns

Promise<void>


createContextPopupHandlers()

createContextPopupHandlers(): object

Defined in: extension/data/modules/comment/dom.tsx:190

Creates handlers for context-popup button injection on comment action rows.

Old Reddit: registers a thingFlatListActions renderer, limited to mod/user/permalink pages. The slot is provided per-comment by oldreddit/dom.ts; no TBNewThings wiring is needed.

Shreddit: registers a thingActions renderer, limited to user-profile pages (the popup is only useful where comments appear out of thread context).

Returns

object

{cleanup} to be wired by index.ts.

cleanup

cleanup: () => void

Returns

void


createFlatViewHandlers()

createFlatViewHandlers(openContextInPopup): object

Defined in: extension/data/modules/comment/dom.tsx:131

Creates handlers that manage the flat-view context menu item and open the flat-view overlay.

Parameters

openContextInPopup

boolean

Whether clicking a context link should open a popup instead of navigating.

Returns

object

Handlers for page navigation events and the flat-view button click.

handleFlatViewClick()

handleFlatViewClick(_target, _event): void

Parameters
_target

Element

_event

Event

Returns

void

handleNewPage()

handleNewPage(event): void

Parameters
event

CustomEvent<TBPageContext>

Returns

void


createHighlightHandlers()

createHighlightHandlers(highlighted): object

Defined in: extension/data/modules/comment/dom.tsx:87

Creates handlers that highlight a list of keywords in comment text on mod-subreddits. Registers a thingDetails renderer so highlighting fires per-comment on both platforms.

Parameters

highlighted

string[]

The list of keyword strings to highlight.

Returns

Handlers for expando clicks and page navigation, plus a cleanup function. Call lifecycle.mount(handlers.cleanup) in index.ts.

cleanup

cleanup: () => Promise<void> = lifecycle.cleanup

Run registered cleanup functions in reverse registration order.

Returns

Promise<void>

handleExpando()

handleExpando(element): Promise<void>

Parameters
element

Element

Returns

Promise<void>

handleNewPage()

handleNewPage(event): Promise<void>

Parameters
event

CustomEvent<TBPageContext>

Returns

Promise<void>


createUserPageCommentControls()

createUserPageCommentControls(): (() => void) | null

Defined in: extension/data/modules/comment/dom.tsx:71

Provides the commentThreadControls UI location on the page menuarea for user-page comment threads. Performs the DOM query and DOM manipulation; call lifecycle.mount(cleanup) in index.ts.

Returns

(() => void) | null

A cleanup function, or null if the menuarea element was not found.


openCommentContextPopup()

openCommentContextPopup(commentID, permalink, event): void

Defined in: extension/data/modules/comment/dom.tsx:156

Fetches comment context from the Reddit API and displays it in a ContextPopup.

Parameters

commentID

string

The fullname of the comment to highlight in the popup.

event

MouseEvent

The mouse event that triggered the popup, used to position it.

Returns

void