moderator-toolbox-nxg-for-reddit / dom/shreddit/commentActionRow

dom/shreddit/commentActionRow

Functions

clickNativeVoteButton()

clickNativeVoteButton(comment, direction): boolean

Defined in: extension/data/dom/shreddit/commentActionRow.ts:87

Casts a vote by clicking the comment’s native up/down vote button (Reddit’s own vote path, which works regardless of the OAuth token’s scopes - unlike the REST /api/vote endpoint, which the Shreddit web token isn’t authorized for). The vote control is a <shreddit-vote-animations> whose arrow <button>s live in its shadow root; we look in both the action row’s light DOM and its shadow for the host. Best-effort selectors - isolated here for an easy fix if Shreddit changes.

Parameters

comment

Element

A shreddit-comment element.

direction

"up" | "down"

'up' to click upvote, 'down' to click downvote (both toggle, like Reddit).

Returns

boolean

true when a native vote button was found and clicked.


getCommentActionRow()

getCommentActionRow(comment): Element | null

Defined in: extension/data/dom/shreddit/commentActionRow.ts:32

Returns a comment’s OWN <shreddit-comment-action-row> (not a nested reply’s), matched by the action row’s comment-id to the comment’s thingid. Returns null when the row isn’t present yet (Shreddit lazy-renders comment rows).

Parameters

comment

Element

A shreddit-comment element.

Returns

Element | null


getNativeReplyButton()

getNativeReplyButton(actionRow): HTMLElement | null

Defined in: extension/data/dom/shreddit/commentActionRow.ts:69

Finds a comment’s native Reply control (a light-DOM child slotted into comment-reply). Returns the innermost clickable <button> when present, else the slotted host. Best-effort selectors.

Parameters

actionRow

Element | null

A shreddit-comment-action-row, or null.

Returns

HTMLElement | null


isNativeRowExpanded()

isNativeRowExpanded(comment): boolean

Defined in: extension/data/dom/shreddit/commentActionRow.ts:116

Whether a comment’s native action row is currently expanded.

Parameters

comment

Element

A shreddit-comment element.

Returns

boolean


parseScoreAttr()

parseScoreAttr(el): number | null

Defined in: extension/data/dom/shreddit/commentActionRow.ts:46

Reads a score attribute off an element and parses it to a number, returning null when the attribute is absent, empty, or non-numeric (Reddit hides the score by omitting/blanking the attribute).

Parameters

el

Element | null

The element carrying a score attribute, or null.

Returns

number | null


readVoteState()

readVoteState(actionRow): CommentVoteInfo

Defined in: extension/data/dom/shreddit/commentActionRow.ts:56

Reads the current score + vote direction off a comment action row.

Parameters

actionRow

Element | null

A shreddit-comment-action-row, or null (returns a neutral, score-hidden info).

Returns

CommentVoteInfo


setNativeRowExpanded()

setNativeRowExpanded(comment, on): void

Defined in: extension/data/dom/shreddit/commentActionRow.ts:108

Shows or hides a comment’s native action row inline (the CSS collapse rule keys off NATIVE_ROW_EXPANDED_CLASS).

Parameters

comment

Element

A shreddit-comment element.

on

boolean

true to reveal the native row, false to collapse it.

Returns

void

Interfaces

CommentVoteInfo

Defined in: extension/data/dom/shreddit/commentActionRow.ts:19

A comment’s current vote state and score (score is null when Reddit hides it).

Properties

score

score: number | null

Defined in: extension/data/dom/shreddit/commentActionRow.ts:21

Current score, or null when the comment’s score is hidden.

state

Defined in: extension/data/dom/shreddit/commentActionRow.ts:23

Which arrow (if any) the current user has active.

Type Aliases

NativeVoteState

NativeVoteState = "UP" | "DOWN" | "NONE"

Defined in: extension/data/dom/shreddit/commentActionRow.ts:16

Native vote state, as stamped on the action row’s vote-state attribute.

Variables

NATIVE_ROW_EXPANDED_CLASS

const NATIVE_ROW_EXPANDED_CLASS: "toolbox-native-row-expanded" = 'toolbox-native-row-expanded'

Defined in: extension/data/dom/shreddit/commentActionRow.ts:13

CSS hook the Expand toggle flips on a shreddit-comment to reveal its collapsed native row.