moderator-toolbox-nxg-for-reddit / modules/betterbuttons/features/distinguishToggle

modules/betterbuttons/features/distinguishToggle

Functions

createDistinguishToggleHandlers()

createDistinguishToggleHandlers(): object

Defined in: extension/data/modules/betterbuttons/features/distinguishToggle.tsx:95

Creates handlers for the distinguish-toggle feature.

Returns

addSticky (inject sticky links), distinguishClicked (auto-confirm distinguish clicks), and cleanup (dispose the factory’s timer and unmount every injected sticky link) to pass to lifecycle.mount in index.ts.

addSticky

addSticky: () => void

Returns

void

cleanup

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

Run registered cleanup functions in reverse registration order.

Returns

Promise<void>

distinguishClicked

distinguishClicked: (element, event) => void

Skips Reddit’s confirmation step: clicking the distinguish toggle opens a “yes / no” menu, so this confirms it immediately by clicking the first option.

Parameters
element

Element

event

Event

Returns

void

Variables

distinguishFormSelector

const distinguishFormSelector: “form[action$=”/post/distinguish”]” = 'form[action$="/post/distinguish"]'

Defined in: extension/data/modules/betterbuttons/features/distinguishToggle.tsx:34

Matches Reddit’s distinguish form by the tail of its action. Reddit renders this as an absolute URL (https://www.reddit.com/post/distinguish), so an exact [action="/post/distinguish"] match silently finds nothing; the suffix match works for both that and a relative action.