Members
(constant) DISPLAY_BOTTOM
(constant) DISPLAY_CENTER
(constant) FEEDBACK_NEGATIVE
(constant) FEEDBACK_NEUTRAL
(constant) FEEDBACK_POSITIVE
(constant) RandomFeedback
- Description:
A random text message for long loading tasks, determined at page load.
- Source:
A random text message for long loading tasks, determined at page load.
(constant) RandomQuote
- Description:
A random quote for the about page, determined at page load.
- Source:
A random quote for the about page, determined at page load.
TBsettingsObject
- Description:
An object mapping setting keys to their currently loaded values.
- Source:
An object mapping setting keys to their currently loaded values.
(constant) actionButton
Generates HTML for an action button.
(constant) baseDomain
- Description:
The base domain to use for links to content on Reddit. If we are on new modmail we use www.reddit.com; wnywhere else we use whatever is the current domain.
- Source:
The base domain to use for links to content on Reddit. If we are on new modmail we use www.reddit.com; wnywhere else we use whatever is the current domain.
(constant) browserName
The name of the current browser.
(constant) buildSha :string|null
Type:
- string | null
(constant) buildType :'stable'|'beta'|'dev'
Type:
- 'stable' | 'beta' | 'dev'
(constant) button
Generates HTML for a general button.
(constant) defaultNoteLabelValueToLabelType
- Description:
Mapping of possible values of the
defaultNoteLabelValue
setting to actual label type strings used by the API (or in the case of "none",undefined
)
- Source:
Mapping of possible values of the defaultNoteLabelValue
setting to actual
label type strings used by the API (or in the case of "none", undefined
)
(constant) delay
- Description:
Returns a promise that resolves after the given time.
- Source:
Returns a promise that resolves after the given time.
(constant) domain :string
- Description:
The current subdomain (NOT full domain).
- Source:
The current subdomain (NOT full domain).
Type:
- string
(constant) getAnonymizedSettings
- Description:
Generates an anonymized version of the settings object, with some sensitive settings omitted and other settings represented differently.
- Source:
Generates an anonymized version of the settings object, with some sensitive settings omitted and other settings represented differently.
(constant) getSettings
- Description:
Promises a copy of the current settings object, containing all setting keys and their values.
- Source:
Promises a copy of the current settings object, containing all setting keys and their values.
(constant) initialLoadPromise
- Description:
A promise which will fulfill once the current settings are fetched from extension storage. Once this promise fulfills, it's safe to assume
TBsettingsObject
contains our settings. Settings reads are delayed until then - either by awaiting this promise, or by waiting for theTBStorageLoaded
window event, which is emitted at the same time.
- Source:
A promise which will fulfill once the current settings are fetched from
extension storage. Once this promise fulfills, it's safe to assume
TBsettingsObject
contains our settings. Settings reads are delayed until
then - either by awaiting this promise, or by waiting for the
TBStorageLoaded
window event, which is emitted at the same time.
(constant) isNewModmail
(constant) isOldReddit
(constant) labelColors :object
- Description:
An object mapping modnote labels to display colors. All colors are from the default Toolbox usernote type colors, except the HELPFUL_USER label which doesn't have an analogue in Toolbox usernotes.
- Source:
An object mapping modnote labels to display colors. All colors are from the default Toolbox usernote type colors, except the HELPFUL_USER label which doesn't have an analogue in Toolbox usernotes.
Type:
- object
(constant) labelNames :object
- Description:
An object mapping modnote lavels to human-friendly display names.
- Source:
An object mapping modnote lavels to human-friendly display names.
Type:
- object
(constant) listenerAliases :Object.<string, Array.<string>>
- Description:
Event listener aliases. Allows you to listen for
author
and getpostAuthor
andcommentAuthor
events, for example.
- Source:
Event listener aliases. Allows you to listen for author
and get postAuthor
and commentAuthor
events,
for example.
Type:
- Object.<string, Array.<string>>
(constant) literalRegExp
- Description:
Generates a regular expression that will match only a given string.
- Source:
Generates a regular expression that will match only a given string.
messageHandlers :Map.<string, function()>
- Description:
A map storing handlers for the various toolbox-defined message types
- Source:
A map storing handlers for the various toolbox-defined message types
Type:
- Map.<string, function()>
(constant) modbarExists :Promise.<void>
- Description:
A promise which resolves when the modbar is added to the page.
- Source:
A promise which resolves when the modbar is added to the page.
Type:
- Promise.<void>
(constant) parser
- Description:
Provides an initialized SnuOwnd parser.
- Source:
Provides an initialized SnuOwnd parser.
(constant) removeQuotes
- Description:
Removes ASCII single and double quotes from a string.
- Source:
Removes ASCII single and double quotes from a string.
(constant) settings :Array.<string>
- Description:
A list of all currently loaded settings keys.
- Source:
A list of all currently loaded settings keys.
Type:
- Array.<string>
(constant) shortVersion
- Description:
Numeric representation of basic version information; compare major/minor/patch/build instead when possible
- Source:
- Deprecated:
- Yes
Numeric representation of basic version information; compare major/minor/patch/build instead when possible
Example
60113
(constant) standardColors
Map of commonly used color names to CSS color values.
(constant) submissionFullnamesCache :Record.<string, Promise.<string>>
- Description:
In-page cache of comment fullnames to the fullnames of their submissions. Values of this object are promises which resolve to fullnames, rather than bare strings - we keep the promises around after they're resolved, and always deal with this cache asynchronously.
- Source:
In-page cache of comment fullnames to the fullnames of their submissions. Values of this object are promises which resolve to fullnames, rather than bare strings - we keep the promises around after they're resolved, and always deal with this cache asynchronously.
Type:
- Record.<string, Promise.<string>>
(constant) toolboxVersion
- Description:
Concise version string which includes all possibly relevant information.
- Source:
Concise version string which includes all possibly relevant information.
Examples
'6.1.13.0 stable 5546015'
'7.0.0.2 beta 893745b'
(constant) toolboxVersionName
- Description:
User-friendly version string; stable releases exclude build and commit
- Source:
User-friendly version string; stable releases exclude build and commit
Examples
'6.1.13 "Delaying Donkey"'
'7.0.0 "Rewriting Rattlesnake" (build 2 from 893745b)'
(constant) typeNames :object
- Description:
An object mapping modnote types to human-friendly display names.
- Source:
An object mapping modnote types to human-friendly display names.
Type:
- object
Methods
ModNotesBadge(data) → {jQuery}
- Description:
Creates a mod note badge for the given information.
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | Data associated with the badge Properties
|
Returns:
The created badge
- Type
- jQuery
ModNotesPager()
- Description:
Returns a pager for mod notes on the user in the subreddit matching the filter.
- Source:
ModNotesPopup(data) → {jQuery}
- Description:
Creates a mod note popup for the given information.
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | Data associated with the popup Properties
|
Returns:
The created popup
- Type
- jQuery
NoteTableRow()
- Description:
A row of the notes table displaying details about the given note.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
props.note |
object | A note object |
addModSubsToSidebar(user, $sidebar)
- Description:
Adds the user's moderated subs to the given sidebar element.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
user |
string | reddit username |
$sidebar |
jqueryObject | jquery sidebar element to which the subreddits need to be added |
addToSiteTable(data, $siteTable, after, callback) → {callback}
- Description:
Adds items to the toolbox profile overlay siteTable element
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
array | array of reddit things to be added in reddit API format |
$siteTable |
jqueryObject | jquery object representing the siteTable |
after |
string | reddit thing ID representing the start of the next page. If present will add a "load more" at the end of the siteTable |
callback |
callback | callback function |
Returns:
returned when done
- Type
- callback
addTrophiesToSidebar(user, $sidebar)
- Description:
Adds the user's trophies to the given sidebar element.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
user |
string | reddit username |
$sidebar |
jqueryObject | jquery sidebar element to which the trophies need to be added |
alert(options) → {Promise.<boolean>}
- Description:
Opens the toolbox "nag" alert everyone loves so much. USE SPARINGLY.
- Source:
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | The options for the alert Properties
|
Returns:
Resolves when the alert is closed. Value
will be true
if the alert was clicked, false
if the close button
was clicked or if it was closed for another reason.
- Type
- Promise.<boolean>
checkForActions(subreddit, fullName) → {false|object}
- Description:
Checks modLogCache for actions on the given fullName and subreddit.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
subreddit |
string | The subreddit the fullName thing belongs to. |
fullName |
string | Thing (post/comment) fullName |
Returns:
Either false or an object with actions
- Type
- false | object
cleanSubredditName(dirtySub) → {string}
- Description:
Because there are a ton of ways how subreddits are written down and sometimes we just want the name.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
dirtySub |
string | dirty dirty sub. |
Returns:
shiny sub!
- Type
- string
clearCache() → {Promise.<void>}
- Description:
Clears all cache keys.
- Source:
Returns:
- Type
- Promise.<void>
colorNameToHex(color) → {string}
- Description:
Will compare the input color to a list of known color names and return the HEX value
- Source:
Parameters:
Name | Type | Description |
---|---|---|
color |
string | input color |
Returns:
if a match is found the HEX color, otherwise the input string.
- Type
- string
contextTrigger(triggerId, options)
- Description:
Add or remove a menu element to the context aware menu. Makes the menu shows if it was empty before adding, hides menu if it is empty after removing.
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
triggerId |
string | This will be part of the id given to the element. |
||||||||||||||||||
options |
object |
Properties
|
createDeferredProcessQueue(bulkProcess, delayTimeopt, queueLimitopt)
- Description:
Creates a processing queue that allows items to be added one at a time, and defers processing of those items until a specified delay between item additions happens, or a maximum length is reached. Returns an insert function to add items to the queue. Additionally, each invocation of the insert function returns a promise that can be awaited on to receive the processed result of the specific item added.
Creating the queue requires giving it a processing function, which must take an input array of items, and return a promise that resolves to an array of corresponding results.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
bulkProcess |
||||
delayTime |
number |
<optional> |
100
|
This many milliseconds must pass without an item being queued before the queue is flushed |
queueLimit |
number |
<optional> |
Infinity
|
When the queue reaches this size, it is
flushed immediately without waiting for the |
Returns:
daysToMilliseconds(days) → {integer}
- Description:
Convert days to milliseconds
- Source:
Parameters:
Name | Type | Description |
---|---|---|
days |
integer | days |
Returns:
Milliseconds
- Type
- integer
debounce(func, debounceTime) → {function}
- Description:
Debounces a given function based on a given timeout.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
func |
function | input function |
debounceTime |
number | the amount of time used to wait in ms. |
Returns:
the executed function
- Type
- function
debugInformation() → {DebugObject}
- Description:
Puts important debug information in a object so we can easily include it in /r/toolbox posts and comments when people need support.
- Source:
Returns:
Object with debug information
- Type
- DebugObject
displayNotes()
escapeHTML(html) → {string}
- Description:
Escape html entities
- Source:
Parameters:
Name | Type | Description |
---|---|---|
html |
string | input html |
Returns:
HTML string with escaped entities
- Type
- string
(async) fetchModSubs(afteropt) → {Promise.<Array.<object>>}
- Description:
Gets a list of all subreddits the current user moderates from the API.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
after |
string |
<optional> |
Pagination parameter used for recursion |
Returns:
- Type
- Promise.<Array.<object>>
(async) fetchNewsNotes(sub) → {Promise.<Array.<object>>}
- Description:
Fetches notes for the given subreddit (from /r/sub/w/tbnotes).
- Source:
Parameters:
Name | Type | Description |
---|---|---|
sub |
string | The name of the subreddit to fetch notes from |
Returns:
- Type
- Promise.<Array.<object>>
figureOutMulti($tbQueueUrl, type) → {string}
- Description:
Figures out what listing path to use and adds the multireddit representation to the input field on the respective tab.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
$tbQueueUrl |
jqueryObject | input element which will hold the multireddit representation |
type |
string | the listing type |
Returns:
the listing path to be used in overlays
- Type
- string
filterModdable(hide)
- Description:
Will hide or reveal items in the profile overlay that can't be modded.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
hide |
boolean | determines if items should be shown or hidden. |
getActions(subreddit, fullName, callback)
- Description:
Checks for mod actions on the given fullName thing and subreddit through a caching mechanism.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
subreddit |
string | the subreddit for which the modlog needs to be fetched |
fullName |
string | thing (post/comment) fullName |
callback |
getActionsCallback | callback that handles further modlog interactions |
(async, generator) getAllModNotes(subreddit, user, filter) → {AsyncGenerator.<any, void>}
- Description:
Creates a generator which lazily fetches all mod notes for a user in a subreddit that match the given filter.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
subreddit |
string | The name of the subreddit |
user |
string | The name of the user |
filter |
string | Criteria for filtering notes |
Returns:
- Type
- AsyncGenerator.<any, void>
getCache(module, setting, defaultValopt) → {Promise.<any>}
- Description:
Gets a value in the cache.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
module |
string | The module that owns the cache key |
|
setting |
string | The name of the cache key |
|
defaultVal |
any |
<optional> |
The value returned if there is no cached value |
Returns:
- Type
- Promise.<any>
(async) getContextURL(note) → {Promise.<(string|null)>}
- Description:
Gets a link to the context item of a note.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
note |
object | A mod note object |
Returns:
Resolves to a URL that points to the note's
context item, or null
if there is none
- Type
- Promise.<(string|null)>
getLastVersion() → {Promise.<number>}
- Description:
Gets the version of Toolbox that was used last time the Toolbox content script was started. Used to tell if the extension was just updated.
- Source:
Returns:
- Type
- Promise.<number>
getLatestModNote(subreddit, user) → {Promise}
- Description:
Fetches the most recent mod note on the given user in the given subreddit.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
subreddit |
string | The name of the subreddit |
user |
string | The name of the user |
Returns:
Resolves to a note object or null
, or rejects an error
- Type
- Promise
getModSubs(data) → {Promise.<array>}
- Description:
Returns a Promise that returns the subreddits a user mods as an array with just the names or array with details per subreddit. First tries to read their values from cache, and falls back to fetching the list of moderated subs from the API.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
boolean | If true will return detailed subreddit data. |
Returns:
array with subreddit names or subreddit objects with details.
- Type
- Promise.<array>
getModlog(subreddit, callback)
- Description:
Fetches the modlog for a subreddit and updates modlogCache.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
subreddit |
string | the subreddit for which the modlog needs to be fetched |
callback |
getModlogCallback | callback that handles further modlog interactions |
getRandomNumber(maxInt) → {integer}
- Description:
Give a random number
- Source:
Parameters:
Name | Type | Description |
---|---|---|
maxInt |
integer | Max integer |
Returns:
random number
- Type
- integer
getSetting(module, setting, defaultVal) → {any}
- Description:
Returns the value of a setting.
- Source:
- Deprecated:
- Use `getSettingAsync` instead
Parameters:
Name | Type | Description |
---|---|---|
module |
string | The ID of the module the setting belongs to |
setting |
string | The name of the setting |
defaultVal |
any | The value returned if the setting is not set |
Returns:
- Type
- any
getSettingAsync(module, setting, defaultVal) → {Promise.<any>}
- Description:
Returns the value of a setting.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
module |
string | The ID of the module the setting belongs to |
setting |
string | The name of the setting |
defaultVal |
any | The value returned if the setting is not set |
Returns:
- Type
- Promise.<any>
getSubmissionFullname(commentFullname) → {Promise.<string>}
- Description:
Gets the fullname of a comment's corresponding submission.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
commentFullname |
string | Fullname of a comment |
Returns:
Fullname of the comment's submission
- Type
- Promise.<string>
(async) getSubredditColors(subreddit) → {Promise}
- Description:
Gets the usernote types to use for the given subreddit.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
subreddit |
string | The subreddit to fetch colors for |
Returns:
Resolves with the usernote types as an object
- Type
- Promise
getTime() → {integer}
- Description:
Give the nummeric value in milliseconds of the current date and time.
- Source:
Returns:
time value in milliseconds
- Type
- integer
getToolboxDevs() → {Promise.<Array.<string>>}
- Description:
Fetches the list of Toolbox developers from the /r/toolbox mod list. May return a cached list or a static fallback if the API request fails.
- Source:
Returns:
- Type
- Promise.<Array.<string>>
handleMessage(request, sender) → {Promise.<any>|void}
- Description:
Handles a message
- Source:
Parameters:
Name | Type | Description |
---|---|---|
request |
object | The data sent to the background page |
sender |
runtime.MessageSender | The sender of the message |
Returns:
- Type
- Promise.<any> | void
handleTBThings(entries, observer)
- Description:
Handles toolbox generated
thing
items as they become visible in the viewport.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
entries |
Array.<IntersectionObserverEntry> | |
observer |
IntersectionObserver |
handleThing(entries, observer)
- Description:
Handles
thing
items as they become visible in the viewport.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
entries |
Array.<IntersectionObserverEntry> | |
observer |
IntersectionObserver |
hideModActionsThings(hide)
- Description:
Will hide or reveal mod actions in the toolbox profile overlay.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
hide |
boolean | determines if actions should be shown or hidden. |
htmlDecode(value) → {string}
- Description:
Gets the text content of an HTML string.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The HTML to read |
Returns:
- Type
- string
htmlEncode(value) → {string}
- Description:
Escapes text for HTML.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The text to escape |
Returns:
- Type
- string
humaniseDays(days) → {string}
- Description:
Converts a given amount of days in a "humanized version" of weeks, months and years.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
days |
integer |
Returns:
x year x months x weeks x day
- Type
- string
(async) init()
- Description:
Initiate the module
- Source:
isConfigValidVersion(config, subreddit) → {booleean}
- Description:
Checks if a given subreddit config version is valid with this version of toolbox
- Source:
Parameters:
Name | Type | Description |
---|---|---|
config |
object | |
subreddit |
string |
Returns:
valid
- Type
- booleean
isEquivalent(a, b) → {boolean}
- Description:
Checks whether two objects are deeply equivalent by recursively comparing their property values. Does not check reference equality.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
a |
any | |
b |
any |
Returns:
- Type
- boolean
isModSub(subreddit) → {Promise.<boolean>}
- Description:
Returns a Promise that returns if the logged in user is a mod of a given subreddit.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
subreddit |
string | Subreddit to check. |
Returns:
- Type
- Promise.<boolean>
link(l) → {string}
- Description:
Takes an absolute path for a link and prepends the www.reddit.com domain if we're in new modmail (mod.reddit.com). Makes absolute path links work everywhere.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
l |
string | The link path, starting with "/" |
Returns:
- Type
- string
makeCommentThread(jsonInput, commentOptions) → {object}
Parameters:
Name | Type | Description |
---|---|---|
jsonInput |
object | reddit API comments object. |
commentOptions |
object | object denoting what needs to included. Object can contain 'parentLink', 'contextLink' and 'fullCommentsLink' as boolean. |
Returns:
jquery object with the build comment thread.
- Type
- object
makeQueueOverlay(type, options)
- Description:
Creates the queue overlay or adds data to it if it is already open.
- Source:
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
type |
string | listing type |
|||||||||
options |
object |
Properties
|
makeSingleComment(comment, commentOptions) → {object}
Parameters:
Name | Type | Description |
---|---|---|
comment |
object | reddit API comment object. |
commentOptions |
object | object denoting what needs to be included. Object can contain 'parentLink', 'contextLink' and 'fullCommentsLink' as boolean. |
Returns:
jquery object with the build comment.
- Type
- object
makeSubmissionEntry(submission, submissionOptions) → {object}
- Description:
Will build a submission entry given a reddit API submission object.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
submission |
object | reddit API submission object. |
submissionOptions |
object | object denoting what needs to be included. |
Returns:
jquery object with the build submission.
- Type
- object
makeUserSidebar(user, $overlay)
- Description:
Creates a user sidebar element for the given overlay
- Source:
Parameters:
Name | Type | Description |
---|---|---|
user |
string | reddit username |
$overlay |
jqueryObject | jquery overlay element to which the sidebar needs to be added |
millisecondsToDays(milliseconds) → {integer}
- Description:
Convert milliseconds to days
- Source:
Parameters:
Name | Type | Description |
---|---|---|
milliseconds |
integer | milliseconds |
Returns:
Days
- Type
- integer
minutesToMilliseconds(mins) → {integer}
- Description:
Convert minutes to milliseconds
- Source:
Parameters:
Name | Type | Description |
---|---|---|
mins |
integer | Minutes |
Returns:
Milliseconds
- Type
- integer
moveArrayItem(array, old_index, new_index) → {array}
- Description:
Moves an item in an array from one index to another https://github.com/brownieboy/array.prototype.move/blob/master/src/array-prototype-move.js
- Source:
Parameters:
Name | Type | Description |
---|---|---|
array |
array | input array |
old_index |
integer | |
new_index |
integer |
Returns:
New array with moved items
- Type
- array
newModmailSidebar()
- Description:
Makes sure to fire a jsAPI
TBuserHovercard
event for new modmail sidebar instances.
- Source:
niceDateDiff(origdate, newdate) → {string}
- Description:
Returns the difference between days in nice format like "1 year"
- Source:
Parameters:
Name | Type | Description |
---|---|---|
origdate |
Date | |
newdate |
Date |
Returns:
Formatted date difference
- Type
- string
notification(title, body, path, markreadidnullable)
- Description:
Shows a notification, uses native browser notifications if the user allows it or falls back on html notifications.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
title |
string | Notification title |
|
body |
string | Body text |
|
path |
string | Absolute path to be opend when clicking the notification |
|
markreadid |
string |
<nullable> |
The ID of a conversation to mark as read when the notification is clicked |
overlay(options)
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
pager(options, contentFunction) → {jQuery}
- Description:
Creates a jQuery element that dynamically displays paginated content.
- Source:
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | Options for the pager Properties
|
|||||||||
contentFunction |
TBui~pagerCallback | A function which generates content for a given page |
Returns:
- Type
- jQuery
pagerForItems(options, items, perPage, displayItem, controlPosition, wrapperopt) → {jQuery}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options |
object | |||
items |
Array.<any> | The items to display in the pager |
||
perPage |
number | The number of items to display on each page |
||
displayItem |
TBui~pagerForItemsCallback | A function that generates content for each individual item in the dataset |
||
controlPosition |
string | Where to display the pager's controls, either 'top' or 'bottom' |
||
wrapper |
string |
<optional> |
'<div>'
|
Used to provide custom wrapper markup for each page of items |
Returns:
- Type
- jQuery
parseComments(object, postID, subreddit) → {Promise}
- Description:
Will given a reddit API comment object go through the chain and put all comments
- Source:
Parameters:
Name | Type | Description |
---|---|---|
object |
object | Comment chain object |
postID |
string | Post id the comments belong to |
subreddit |
string | Subreddit the comment chain belongs to. |
Returns:
- Type
- Promise
popup(options) → {jQuery}
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | Options for the popup Properties
|
Returns:
- Type
- jQuery
progressivePager(options) → {JQuery}
- Description:
Creates a jQuery element that displays paginated content provided by a generator or other iterable, possibly asynchronous. Lazy loading is supported.
- Source:
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | Options for the pager Properties
|
|||||||||||||||||||||||||
|
Returns:
- Type
- JQuery
purify(input) → {string}
- Description:
Uses DOMPurify to sanitize untrusted HTML strings.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
input |
string |
Returns:
- Type
- string
purifyObject(input)
- Description:
Recursively sanitize an object's string values as untrusted HTML. String values that can be interpreted as JSON objects are parsed, sanitized, and re-stringified.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
input |
any |
regExpEscape(query) → {string}
- Description:
Escapes a string so it is suitable to be inserted in to a regex match
- Source:
Parameters:
Name | Type | Description |
---|---|---|
query |
string | reddit username |
Returns:
string escaped for regex use
- Type
- string
relativeTime(date) → {jQuery}
- Description:
Creates a
<time>
element which displays the given date as a relative time via$.timeago()
.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
date |
Date | Date and time to display |
Returns:
- Type
- jQuery
reloadIframe($reloadListing, $tbQueueUrl, $iframe, type)
- Description:
Reload the iframe belonging to a queue listing based on latest data.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
$reloadListing |
jqueryObject | reload button on the listing tab. |
$tbQueueUrl |
jqueryObject | input element which will hold the multireddit representation |
$iframe |
jqueryObject | iframe element to be reloaded |
type |
string | listing type |
reloadToolbox()
remove(array, item) → {Boolean}
- Description:
Remove an item from an Array.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | |
item |
* |
Returns:
- Type
- Boolean
removeLastDirectoryPartOf(url) → {string}
- Description:
Strips the last directory part of an url. Example: /this/is/url/with/part/ becomes /this/is/url/with/
- Source:
Parameters:
Name | Type | Description |
---|---|---|
url |
string | reddit API comment object. |
Returns:
url without the last directory part
- Type
- string
replaceAll(find, replace, str) → {string}
- Description:
Replace all instances of a certaing thing for another thing.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
find |
string | what to find |
replace |
string | what to replace |
str |
string | where to do it all with |
Returns:
shiny new string with replaced stuff
- Type
- string
replaceTokens(info, content) → {string}
- Description:
Replaces {tokens} for the respective value in given content
- Source:
Parameters:
Name | Type | Description |
---|---|---|
info |
object | object with token name keys and token content values. |
content |
string | dirty dirty sub. |
Returns:
token replaced text!
- Type
- string
saneSort(arr)
- Description:
Because normal .sort() is case sensitive.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
arr |
array | input array |
saneSortAs(arr)
- Description:
Because normal .sort() is case sensitive and we also want to sort ascending from time to time.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
arr |
array | input array |
(async) saveSettingsToBrowser() → {Promise.<void>}
- Description:
Commits the current settings to extension storage.
- Source:
Returns:
- Type
- Promise.<void>
searchProfile(user, type, sortMethod, $siteTable, options, after, match, pageCount, callback) → {callback}
- Description:
Searches a user profile for the given subreddit and/or string
- Source:
Parameters:
Name | Type | Description |
---|---|---|
user |
string | reddit username |
type |
string | the listing type that is to be searched |
sortMethod |
string | the listing type that is to be searched |
$siteTable |
jqueryObject | jquery siteTable element to which the search results need to be added |
options |
object | search options |
after |
string | reddit thing id indicating the next page |
match |
boolean | indicates if there are previous |
pageCount |
integer | what page we are on |
callback |
callback | callback function |
Returns:
returns true when results have been found, false when none are found
- Type
- callback
setCache(module, setting, inputValue) → {Promise.<any>}
- Description:
Sets a value in the cache.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
module |
string | The ID of the module that owns the cache key |
setting |
string | The name of the cache key |
inputValue |
any | The new value of the cache key |
Returns:
Promises the new value of the cache key
- Type
- Promise.<any>
setSetting(module, setting, value, syncSettingsopt) → {any}
- Description:
Sets a setting to a new value.
- Source:
- Deprecated:
- Use `setSettingAsync` instead
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
module |
string | The ID of the module the setting belongs to |
||
setting |
string | The name of the setting |
||
value |
any | The new value of the setting |
||
syncSettings |
boolean |
<optional> |
true
|
If false, settings will not be committed to storage after performing this action |
Returns:
The new value of the setting
- Type
- any
setSettingAsync(module, setting, value, syncSettingsopt) → {Promise.<any>}
- Description:
Sets a setting to a new value.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
module |
string | The ID of the module the setting belongs to |
||
setting |
string | The name of the setting |
||
value |
any | The new value of the setting |
||
syncSettings |
boolean |
<optional> |
true
|
If false, settings will not be committed to storage after performing this action |
Returns:
The new value of the setting
- Type
- Promise.<any>
settingsToObject(callback)
- Description:
Calls back with a copy of the current settings object, containing all setting keys and their values.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
callback |
showNote(note)
- Description:
Displays an alert for the given note if its platform information matches and the note hasn't been seen yet.
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
note |
object |
Properties
|
sortBy(arr, prop)
- Description:
Sorts an array of objects by property value of specific properties.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
arr |
array | input array |
prop |
string | property name |
stringToColor(str)
- Description:
Generates a color corresponding to a given string (used to assign colors to subreddits for post borders in shared queues)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
str |
string | The string to generate a color for |
tbRedditEvent($elements)
- Description:
Will send out events similar to the reddit jsAPI events for the elements given. Only support 'comment' for now and will only send the commentAuthor event.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
$elements |
object | jquery object containing the elements for which jsAPI events need to be send. |
textFeedback(feedbackText, feedbackKind, displayDurationopt, displayLocationopt)
- Description:
Displays a feedback message on the screen which disappears after a time. Only one such message can be shown at a time, and calling this method will overwrite any message currently being shown.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
feedbackText |
string | Message to display |
|
feedbackKind |
TextFeedbackKind | Nature of the message (positive, neutral, negative) to affect the color of the message window |
|
displayDuration |
number |
<optional> |
How long the message should be displayed
before being hidden, in milliseconds. Defaults to 3000. Pass |
displayLocation |
TextFeedbackLocation |
<optional> |
The location on the screen where the message should be shown - center screen is the default, but long-lived messages can be moved to the bottom instead |
timeConverterRead(UNIX_timestamp) → {string}
- Description:
convert unix epoch timestamps to readable format dd-mm-yyyy hh:mm:ss UTC
- Source:
Parameters:
Name | Type | Description |
---|---|---|
UNIX_timestamp |
integer |
Returns:
Formatted date in dd-mm-yyyy hh:mm:ss UTC
- Type
- string
title_to_url(title) → {string}
- Description:
convert titles to a format usable in urls from r2.lib.utils import title_to_url
- Source:
Parameters:
Name | Type | Description |
---|---|---|
title |
string |
Returns:
Formatted title
- Type
- string
unescapeHTML(html) → {string}
- Description:
Unescape html entities
- Source:
Parameters:
Name | Type | Description |
---|---|---|
html |
string | input html |
Returns:
HTML string with unescaped entities
- Type
- string
unescapeJSON(info, content) → {string}
- Description:
reddit HTML encodes all of their JSON responses, we need to HTMLdecode them before parsing.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
info |
object | object with token name keys and token content values. |
content |
string | dirty dirty sub. |
Returns:
token replaced text!
- Type
- string
verifiedSettingsSave(callback)
- Description:
Saves current settings, then verifies that they've been saved accurately. If the save was successful, tells the background page to update the settings state of other tabs. Calls back with whether or not the save was successful.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
callback |
watchForURLChanges()
- Description:
Begins emitting TBNewPage and TBHashParam events with metadata whenever the background page detects that this tab's URL has changed.
- Source:
wrapWithLastValue(iterable) → {AsyncGenerator.<{item: T, last: boolean}, void>}
- Description:
Wraps each of an iterable's values with an object that indicates which item is the last one in the sequence by always reading one item ahead in the iterator to check for
{done: true}
before yielding the current item.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
iterable |
MaybeAsyncIterable.<T> |
Returns:
- Type
- AsyncGenerator.<{item: T, last: boolean}, void>
zlibDeflate(object) → {string}
- Description:
Deflates some data into a base64-encoded zlib-compressed data string.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
object |
any | The data to compress |
Returns:
- Type
- string
zlibInflate(string) → {any}
- Description:
Inflates a base64-encoded zlib-compressed data string into data.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
string |
string | The compressed string |
Returns:
- Type
- any
Type Definitions
DebugObject
Properties:
Name | Type | Description |
---|---|---|
toolboxVersion |
string | The toolbox version |
browser |
string | Browser used (Firefox, Chrome, etc) |
browserVersion |
string | The version of the browser |
platformInformation |
string | Other platform information |
debugMode |
boolean | toolbox debugMode enabled |
compactMode |
boolean | toolbox compactmode enabled |
advancedSettings |
boolean | toolbox advanced settings enabled |
cookiesEnabled |
boolean | Browser cookies enabled |
Type:
- Object
SettingDefinition
- Description:
An object representing a single setting. Additional properties may be used for settings of different
type
s.
- Source:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
string | The setting ID, used to get and set the setting's value |
||
description |
string | A human-readable description |
||
default |
any | The default value of the setting, or a function (possibly async) that returns a default value |
||
storageKey |
string |
<optional> |
The storage key associated with the setting |
|
beta |
boolean |
<optional> |
false
|
If true, the setting will only show up when beta mode is enabled |
debug |
boolean |
<optional> |
false
|
If true, the setting will only show up when debug mode is enabled |
advanced |
boolean |
<optional> |
false
|
If true, the setting will only show up when advanced mode is enabled |
hidden |
boolean |
<optional> |
false
|
If true, the setting will not be configurable or visible to users (can be used for module-specific persistent storage) |
An object representing a single setting. Additional properties may be used
for settings of different type
s.
getActionsCallback(result)
- Description:
Callback for further handling the modlog.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
result |
Boolean | Object | Either false or an object with actions |
getModlogCallback()
- Description:
Callback for further handling the modlog.
- Source: