moderator-toolbox-nxg-for-reddit / modules/profile/components/ProfileOverlay.helpers
modules/profile/components/ProfileOverlay.helpers¶
Functions¶
applyProfileEntryFilters()¶
applyProfileEntryFilters(
container,filters):number
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:90
Applies visibility filters to all profile entries inside a container by toggling CSS classes.
Parameters¶
container¶
Element
The sitetable element containing rendered profile entries.
filters¶
Filter options controlling which entries are shown.
Returns¶
number
The number of entries that remain visible after filtering.
applyRepostHighlights()¶
applyRepostHighlights(
container,byFullname,groups,enabled,activeGroup,showOnlyReposts):void
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:536
Applies repost border styling, count badges, and optional group-isolation filtering to rendered profile entries. Idempotent: each call first clears prior repost markup, so it is safe to re-run after new entries load or when the active group changes.
Parameters¶
container¶
Element
The sitetable element containing rendered profile entries.
byFullname¶
Map<string, RepostInfo>
Per-entry repost annotations from computeRepostGroups.
groups¶
Map<string, Set<string>>
Full group membership from computeRepostGroups.
enabled¶
boolean
When false, repost markup is cleared and nothing is applied.
activeGroup¶
string | null
When set, only entries in this group’s membership stay visible.
showOnlyReposts¶
boolean
When true, entries that are not reposts are hidden.
Returns¶
void
cacheListingPage()¶
cacheListingPage(
store,listing,sort,items,after):ProfileEntry[]
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:292
Parameters¶
store¶
listing¶
sort¶
string
items¶
after¶
string | false
Returns¶
compileProfileSearch()¶
compileProfileSearch(
options):CompiledProfileSearch
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:120
Compiles raw search options into RegExp patterns ready for matching.
Parameters¶
options¶
The user-supplied search options to compile.
Returns¶
Compiled patterns, or an object with an error string if a regex is invalid.
computeRepostGroups()¶
computeRepostGroups(
items):RepostData
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:447
Detects reposts within a single user’s history by grouping entries that share a normalized link or text signature. An entry is a repost if it shares any signature with at least one other entry.
Parameters¶
items¶
Raw Reddit API children (t1 comments and/or t3 submissions).
Returns¶
Per-entry annotations and complete group membership.
dedupByFullname()¶
dedupByFullname(
items,seen):ProfileEntry[]
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:281
Filters out items whose Reddit fullname (item.data.name) has already been seen, adding each
kept item’s name to seen so duplicates within items are removed too. Items without a
fullname are always kept and never recorded.
Parameters¶
items¶
Candidate listing items.
seen¶
Set<string>
Set of already-seen fullnames; mutated in place as items are kept.
Returns¶
The items not previously seen.
entryBelongsToListing()¶
entryBelongsToListing(
entry,listing):boolean
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:242
Parameters¶
entry¶
listing¶
Returns¶
boolean
fetchEntireListing()¶
fetchEntireListing(
fetchPage,user,listing,sort,store,onProgress?,shouldCancel?):Promise<ProfileEntry[]>
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:335
Eagerly fetches every remaining page of a user’s listing into the cache. Resumes from wherever the cache currently sits, so already-browsed pages are not re-fetched.
Parameters¶
fetchPage¶
Function that fetches one listing page (pass getUserListingPage).
user¶
string
The Reddit username whose listing is fetched.
listing¶
The listing to fetch (typically overview for full-history repost detection).
sort¶
string
The sort order to fetch under.
store¶
The shared cache store to populate.
onProgress?¶
(pageCount, itemCount) => void
Optional callback invoked after each page with the running page and item counts.
shouldCancel?¶
() => boolean
Optional predicate; when it returns true the loop stops early.
Returns¶
Promise<ProfileEntry[]>
All cached items for the (listing, sort) pair once fetching completes.
getCacheKey()¶
getCacheKey(
listing,sort):string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:238
Parameters¶
listing¶
sort¶
string
Returns¶
string
getOrCreatePageCache()¶
getOrCreatePageCache(
store,listing,sort):ProfilePageCache
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:254
Returns the cache bucket for a (listing, sort) pair, creating an empty one if absent.
Parameters¶
store¶
The shared cache store keyed by "listing:sort".
listing¶
The listing tab the cache belongs to.
sort¶
string
The sort order the cache belongs to.
Returns¶
getProfileThings()¶
getProfileThings(
container):Element[]
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:72
Returns all rendered profile listing entries within a container.
Parameters¶
container¶
Element | Document
The DOM element or document to search within.
Returns¶
Element[]
getUserThumbnailUrl()¶
getUserThumbnailUrl(
aboutData):string|null
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:223
Parameters¶
aboutData¶
created_utc¶
number
has_verified_email?¶
boolean
icon_img?¶
string
id¶
string
is_employee?¶
boolean
is_suspended?¶
boolean
link_karma¶
number
name¶
string
snoovatar_img?¶
string
subreddit?¶
{ icon_img?: string; public_description?: string; title?: string; } | null
The user’s profile subreddit (u/<name>), present for non-suspended accounts.
Returns¶
string | null
normalizeProfileSubreddit()¶
normalizeProfileSubreddit(
subreddit):string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:80
Strips the r/ prefix (if any) and lowercases a subreddit name for consistent comparison.
Parameters¶
subreddit¶
string
Raw subreddit string from user input or API data.
Returns¶
string
normalizeRepostText()¶
normalizeRepostText(
text):string|null
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:414
Normalizes free text (a title, selftext, or comment body) into a stable signature.
Lowercases and strips every non-alphanumeric character so formatting-only differences
collapse together. Returns null when the stripped result is too short to be meaningful.
Parameters¶
text¶
string
The raw text to normalize.
Returns¶
string | null
normalizeRepostUrl()¶
normalizeRepostUrl(
rawUrl):string|null
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:376
Normalizes an external link into a stable signature for repost matching.
Lowercases the host, strips a leading www., drops common tracking query params,
and trims trailing slashes. Returns null for non-HTTP(S) or unparseable URLs.
Parameters¶
rawUrl¶
string
The raw url field from a submission.
Returns¶
string | null
profileListingEntryMatches()¶
profileListingEntryMatches(
entry,patterns):boolean
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:149
Returns whether a Reddit API listing entry matches a compiled profile search.
Parameters¶
entry¶
A raw Reddit API child object (t1 comment or t3 submission).
patterns¶
Omit<CompiledProfileSearch, "error">
The compiled subreddit and content patterns to test against.
Returns¶
boolean
false when no patterns are provided; otherwise true only if all active patterns match.
Interfaces¶
CompiledProfileSearch¶
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:59
Compiled (regex-ready) form of a profile search, produced by compileProfileSearch.
Properties¶
contentPattern¶
contentPattern:
RegExp|null
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:63
Compiled content filter, or null if no content was specified.
error?¶
optionalerror?:string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:65
Present when the user-supplied regex string is invalid.
subredditPattern¶
subredditPattern:
RegExp|null
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:61
Compiled subreddit filter, or null if no subreddit was specified.
ProfileEntry¶
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:30
A Reddit listing entry shown in the profile overlay.
Extends¶
Properties¶
data¶
data:
ProfileItemData
Defined in: extension/data/api/resources/things.ts:16
Inherited from¶
highlight?¶
optionalhighlight?:string|RegExp
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:32
Set transiently while rendering a search result so the renderer highlights matches; never from the API.
kind¶
kind:
string
Defined in: extension/data/api/resources/things.ts:15
Inherited from¶
ProfileEntryFilters¶
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:39
Visibility filters applied to profile listing entries in the overlay.
Properties¶
filterModThings¶
filterModThings:
boolean
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:41
When true, hide entries from subreddits the current user does not moderate.
hideModActions¶
hideModActions:
boolean
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:43
When true, hide entries where the author was distinguished as a moderator.
moderatedSubreddits¶
moderatedSubreddits:
string[]
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:45
Lowercase-normalized list of subreddits the current user moderates.
ProfileItemData¶
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:14
The data payload of a Reddit user-content listing entry (t1 comment or t3 submission).
Profile entries are real comments/submissions, so this carries the base fields the shared
renderer requires (CommentData / SubmissionData) alongside the plain-text
fields the profile search/repost logic matches against.
Indexable¶
[
key:string]:unknown
Properties¶
body?¶
optionalbody?:string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:23
created_utc¶
created_utc:
number
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:18
is_self?¶
optionalis_self?:boolean
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:25
name¶
name:
string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:16
Reddit fullname (e.g. t3_abc123); used for dedup and repost grouping.
permalink¶
permalink:
string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:20
selftext?¶
optionalselftext?:string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:22
subreddit¶
subreddit:
string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:17
title?¶
optionaltitle?:string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:21
url?¶
optionalurl?:string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:24
ProfilePageCache¶
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:195
Cached listing data for a single (listing, sort) combination.
Properties¶
after¶
after:
string|false
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:199
Reddit API cursor for the next unfetched page, or false when none.
exhausted¶
exhausted:
boolean
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:201
true when the API has no more pages to fetch.
items¶
items:
ProfileEntry[]
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:197
All items fetched so far, deduplicated by fullname.
pageCount¶
pageCount:
number
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:203
How many API pages have been fetched into this cache entry.
ProfileSearchOptions¶
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:49
Raw (uncompiled) search options entered by the user in the profile overlay toolbar.
Properties¶
content¶
content:
string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:53
Text or pattern to match against post/comment body.
regex¶
regex:
boolean
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:55
Whether the subreddit and content fields should be treated as regular expressions.
subreddit¶
subreddit:
string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:51
Subreddit name or pattern to filter by.
RepostData¶
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:433
Result of computeRepostGroups: per-entry annotations plus full group membership.
Properties¶
byFullname¶
byFullname:
Map<string,RepostInfo>
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:435
Maps an entry fullname to its repost annotation (only entries that are reposts appear).
groups¶
groups:
Map<string,Set<string>>
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:437
Maps a signature key to the set of member fullnames (every group with >=2 members).
RepostInfo¶
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:421
Per-entry repost annotation produced by computeRepostGroups.
Properties¶
count¶
count:
number
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:423
Size of the primary (largest matching) duplicate group this entry belongs to.
crossSub¶
crossSub:
boolean
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:425
True when any of the entry’s duplicate groups spans more than one subreddit.
groupKey¶
groupKey:
string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:429
Signature key of the primary group - the target a badge click isolates.
matchType¶
matchType:
"text"|"link"
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:427
Whether the primary group matched on link or on text, used for the badge tooltip.
TabState¶
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:172
Runtime state for a single listing tab (overview, submitted, or comments).
Properties¶
after¶
after:
string|false
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:175
Pagination cursor for the next Reddit API page, or false when exhausted.
error?¶
optionalerror?:string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:191
Non-null when an error occurred during the last load or search.
items¶
items:
ProfileEntry[]
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:176
loaded¶
loaded:
boolean
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:178
Whether the tab has completed its initial data load.
searchActive¶
searchActive:
boolean
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:180
Whether a search is currently active (affecting what is displayed).
searchContent¶
searchContent:
string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:182
searchPageCount¶
searchPageCount:
number
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:187
Number of API pages fetched so far during the current search.
searchRegex¶
searchRegex:
boolean
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:183
searchResultCount¶
searchResultCount:
number
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:189
Number of matching entries found so far during the current search.
searchRunning¶
searchRunning:
boolean
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:185
Whether a search fetch loop is currently running.
searchSubreddit¶
searchSubreddit:
string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:181
sort¶
sort:
string
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:173
Type Aliases¶
ListingPageFetcher¶
ListingPageFetcher = (
user,listing,query) =>Promise<ProfileListingPage>
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:317
Fetches a single page of a user’s listing. Matches the signature of
getUserListingPage; injected into fetchEntireListing so this module stays
free of extension-only imports (and thus unit-testable).
Parameters¶
user¶
string
listing¶
string
query¶
Record<string, string>
Returns¶
Promise<ProfileListingPage>
ProfileCacheStore¶
ProfileCacheStore =
Record<string,ProfilePageCache>
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:207
Map from "listing:sort" cache keys to their cached page data.
ProfileListing¶
ProfileListing =
"overview"|"submitted"|"comments"
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:170
The three listing tabs available in the profile overlay.
ProfileListingPage¶
ProfileListingPage =
RedditListing<ProfileEntry>
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:36
One page of profile listing entries (overview/submitted/comments) as returned by the Reddit API.
Variables¶
defaultTabState¶
constdefaultTabState:TabState
Defined in: extension/data/modules/profile/components/ProfileOverlay.helpers.ts:209
comment_karma¶
number