Will given a reddit API comment object go through the chain and put all comments
Kind: inner method of CommentNuke
| Param | Type | Description |
|---|---|---|
| object | object |
Comment chain object |
| postID | string |
Post id the comments belong to |
| subreddit | string |
Subreddit the comment chain belongs to. |
| callback | function |
- QueueTools
- ~getModlog(subreddit, callback)
- ~checkForActions(subreddit, fullName) ⇒
false|object - ~getActions(subreddit, fullName, callback)
- ~getModlogCallback :
function - ~getActionsCallback :
function
Fetches the modlog for a subreddit and updates modlogCache.
Kind: inner method of QueueTools
| Param | Type | Description |
|---|---|---|
| subreddit | string |
the subreddit for which the modlog needs to be fetched |
| callback | getModlogCallback |
callback that handles further modlog interactions |
Checks modLogCache for actions on the given fullName and subreddit.
Kind: inner method of QueueTools
Returns: false | object -
Either false or an object with actions
| Param | Type | Description |
|---|---|---|
| subreddit | string |
The subreddit the fullName thing belongs to. |
| fullName | string |
Thing (post/comment) fullName |
Checks for mod actions on the given fullName thing and subreddit through a caching mechanism.
Kind: inner method of QueueTools
| Param | 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 |
Callback for further handling the modlog.
Kind: inner typedef of QueueTools
Callback for further handling the modlog.
Kind: inner typedef of QueueTools
| Param | Type | Description |
|---|---|---|
| result | Boolean | Object |
Either false or an object with actions |
Kind: global class
- TBListener
- new TBListener()
- instance
- .start()
- .stop()
- .on(Name, Callback)
- .clear(task) ⇒
Boolean
- inner
- ~listenerCallback :
function
- ~listenerCallback :
Create a new instance of TBListener. Nothing happens yet until TBListener.start() has been called
Starts the TBListener instance by registering an event listener for reddit events
A TBListenerLoaded event is fired when everything is ready.
Kind: instance method of TBListener
Unregisters this instance's event listener
Kind: instance method of TBListener
Register an event listener for a given event name for a callback.
Kind: instance method of TBListener
| Param | Type | Description |
|---|---|---|
| Name | string |
of event |
| Callback | listenerCallback |
Clears a scheduled 'read' or 'write' task.
Kind: instance method of TBListener
Returns: Boolean -
success
Access: public
| Param | Type |
|---|---|
| task | Object |
Callback for a reddit event.
The callback's this is event.target
Kind: inner typedef of TBListener
this: HTMLElement
| Param | Type |
|---|---|
| event | CustomEvent |
| responseMessage | string |
Kind: global namespace
- TBui :
object
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.
Kind: static method of TBui
| Param | Type | Description |
|---|---|---|
| triggerId | string |
This will be part of the id given to the element. |
| options | object |
|
| options.addTrigger | boolean |
Indicates of the menu item needs to be added or removed. |
| options.triggerText | string |
Text displayed in menu. Not needed when addTrigger is false. |
| options.triggerIcon | string |
The material icon that needs to be displayed before the menu item. Defaults to 'label' |
| options.title | string |
Title to be used in title attribute. If no title is given the triggerText will be used. |
| options.dataAttributes | object |
Any data attribute that might be needed. Object keys will be used as the attribute name and value as value. |
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.
Kind: static method of TBui
| Param | Type | Description |
|---|---|---|
| $elements | object |
jquery object containing the e |
| types | string |
comma seperated list of type of elements the events need to be send for. |
Will build a submission entry given a reddit API submission object.
Kind: static method of TBui
Returns: object -
jquery object with the build submission.
| Param | Type | Description |
|---|---|---|
| submission | object |
reddit API submission object. |
| submissionOptions | object |
object denoting what needs to be included. |
Will build a comment given a reddit API comment object.
Kind: static method of TBui
Returns: object -
jquery object with the build comment.
| Param | 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. |
Will build a comment given a reddit API comment object.
Kind: static method of TBui
Returns: object -
jquery object with the build comment thread.
| Param | 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. |
Kind: global namespace
- TBUtils :
object- .baseDomain :
string - .tempBaseDomain :
string - .apiOauthPOST
- .apiOauthGET
- .link(link) ⇒
string - .debugInformation() ⇒
debugObject - .getToolboxDevs() ⇒
array - .moveArrayItem(array, old_index, new_index) ⇒
array - .escapeHTML(html) ⇒
string - .unescapeHTML(html) ⇒
string - .getTime() ⇒
integer - .getRandomNumber(maxInt) ⇒
integer - .minutesToMilliseconds(mins) ⇒
integer - .daysToMilliseconds(days) ⇒
integer - .millisecondsToDays(milliseconds) ⇒
integer - .timeConverterISO(UNIX_timestamp) ⇒
string - .niceDateDiff(origdate, newdate) ⇒
string - .timeConverterRead(UNIX_timestamp) ⇒
string - .title_to_url(title) ⇒
string - .alert(message, callback, showClose) ⇒
callback - .notification(title, body, path, markreadid)
- .humaniseDays(days) ⇒
string - .stringFormat()
- .sortBy(arr, prop)
- .saneSort(arr)
- .saneSortAs(arr)
- .replaceAll(find, replace, str) ⇒
string - .colorNameToHex(color) ⇒
string - .removeLastDirectoryPartOf(url) ⇒
string - .isOdd(num) ⇒
boolean - .cleanSubredditName(dirtySub) ⇒
string - .sendRequest(options)
- .getJSON(endpoint, data)
- .post(endpoint, data)
- .getHead(endpoint, doneCallback) ⇒
callback - .apiOauthRequest(method, endpoint, data)
- .debugObject :
Object
- .baseDomain :
If we are on new modmail we use www.reddit.com for all other instances we use whatever is the current domain. Used because some browsers do not like relative urls in extensions
Kind: static property of TBUtils
Pretty much as the name suggests
Kind: static property of TBUtils
Todo
- Once the redesign is no longer alpha/beta switch all instances that use this.
Sends an authenticated POST request against the OAuth API.
Kind: static property of TBUtils
| Param | Type | Description |
|---|---|---|
| endpoint | string |
The endpoint to request |
| data | object |
Query parameters as an object |
Sends an authenticated GET request against the OAuth API.
Kind: static property of TBUtils
| Param | Type | Description |
|---|---|---|
| endpoint | string |
The endpoint to request |
| data | object |
Query parameters as an object |
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.
Kind: static method of TBUtils
| Param | Type | Description |
|---|---|---|
| link | string |
The link path, starting with "/" |
TBUtils.debugInformation() ⇒ debugObject
Puts important debug information in a object so we can easily include it in /r/toolbox posts and comments when people need support.
Kind: static method of TBUtils
Returns: debugObject -
Object with debug information
Fetches the toolbox dev from /r/toolbox or falls back to a predefined list.
Kind: static method of TBUtils
Returns: array -
List of toolbox devs
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
Kind: static method of TBUtils
Returns: array -
New array with moved items
| Param | Type | Description |
|---|---|---|
| array | array |
input array |
| old_index | integer |
|
| new_index | integer |
Escape html entities
Kind: static method of TBUtils
Returns: string -
HTML string with escaped entities
| Param | Type | Description |
|---|---|---|
| html | string |
input html |
Unescape html entities
Kind: static method of TBUtils
Returns: string -
HTML string with unescaped entities
| Param | Type | Description |
|---|---|---|
| html | string |
input html |
Give the nummeric value in milliseconds of the current date and time.
Kind: static method of TBUtils
Returns: integer -
time value in milliseconds
Give a random number
Kind: static method of TBUtils
Returns: integer -
random number
| Param | Type | Description |
|---|---|---|
| maxInt | integer |
Max integer |
Convert minutes to milliseconds
Kind: static method of TBUtils
Returns: integer -
Milliseconds
| Param | Type | Description |
|---|---|---|
| mins | integer |
Minutes |
Convert days to milliseconds
Kind: static method of TBUtils
Returns: integer -
Milliseconds
| Param | Type | Description |
|---|---|---|
| days | integer |
days |
Convert milliseconds to days
Kind: static method of TBUtils
Returns: integer -
Days
| Param | Type | Description |
|---|---|---|
| milliseconds | integer |
milliseconds |
convert unix epoch timestamps to ISO format
Kind: static method of TBUtils
Returns: string -
ISO formatted time
| Param | Type | Description |
|---|---|---|
| UNIX_timestamp | integer |
Unix timestamp |
Returns the difference between days in nice format like "1 year"
Kind: static method of TBUtils
Returns: string -
Formatted date difference
| Param | Type |
|---|---|
| origdate | Date |
| newdate | Date |
convert unix epoch timestamps to readable format dd-mm-yyyy hh:mm:ss UTC
Kind: static method of TBUtils
Returns: string -
Formatted date in dd-mm-yyyy hh:mm:ss UTC
| Param | Type |
|---|---|
| UNIX_timestamp | integer |
convert titles to a format usable in urls from r2.lib.utils import title_to_url
Kind: static method of TBUtils
Returns: string -
Formatted title
| Param | Type |
|---|---|
| title | string |
Opens the toolbox "nag" alert everyone loves so much. USE SPARINGLY
Kind: static method of TBUtils
Returns: callback -
callback with true or false in parameter which will be called when the alert is closed.
| Param | Type | Description |
|---|---|---|
| message | string |
|
| callback | callback |
callback function |
| showClose | boolean |
If true the alert can be dismissed by a clost button otherwise it needs to be clicked. |
Shows a notification, uses native browser notifications if the user allows it or falls back on html notifications.
Kind: static method of TBUtils
| Param | Type | Description |
|---|---|---|
| title | string |
Notification title |
| body | string |
Body text |
| path | string |
Absolute path to be opend when clicking the notification |
| markreadid | string |
The ID of a conversation to mark as read when the notification is clicked |
Converts a given amount of days in a "humanized version" of weeks, months and years.
Kind: static method of TBUtils
Returns: string -
x year x months x weeks x day
| Param | Type |
|---|---|
| days | integer |
Kind: static method of TBUtils
Todo
- properly describe what this does
Sorts an array of objects by property value of specific properties.
Kind: static method of TBUtils
| Param | Type | Description |
|---|---|---|
| arr | array |
input array |
| prop | string |
property name |
Because normal .sort() is case sensitive.
Kind: static method of TBUtils
| Param | Type | Description |
|---|---|---|
| arr | array |
input array |
Because normal .sort() is case sensitive and we also want to sort ascending from time to time.
Kind: static method of TBUtils
| Param | Type | Description |
|---|---|---|
| arr | array |
input array |
Replace all instances of a certaing thing for another thing.
Kind: static method of TBUtils
Returns: string -
shiny new string with replaced stuff
| Param | Type | Description |
|---|---|---|
| find | string |
what to find |
| replace | string |
what to replace |
| str | string |
where to do it all with |
Will compare the input color to a list of known color names and return the HEX value
Kind: static method of TBUtils
Returns: string -
if a match is found the HEX color, otherwise the input string.
| Param | Type | Description |
|---|---|---|
| color | string |
input color |
strips the last directory part of an url. Example: /this/is/url/with/part/ becomes /this/is/url/with/
Kind: static method of TBUtils
Returns: string -
url without the last directory part
| Param | Type | Description |
|---|---|---|
| url | string |
reddit API comment object. |
Will tell if a number is odd
Kind: static method of TBUtils
Returns: boolean -
true if number is odd false if even.
| Param | Type | Description |
|---|---|---|
| num | integer |
reddit API comment object. |
Because there are a ton of ways how subreddits are written down and sometimes we just want the name.
Kind: static method of TBUtils
Returns: string -
shiny sub!
| Param | Type | Description |
|---|---|---|
| dirtySub | string |
dirty dirty sub. |
Sends a generic HTTP request through the background page.
Kind: static method of TBUtils
| Param | Type | Description |
|---|---|---|
| options | object |
The options for the AJAX request |
| options.method | string |
The HTTP method to use for the request |
| options.endpoint | string |
The endpoint to request |
| options.data | object |
Query parameters as an object |
| options.oauth | boolean |
If true, the request will be sent on oauth.reddit.com, and the |
Performs a GET request and promises the body of the response, or the
full response object on error. Maintains an API similar to
$.getJSON() because that's what all these calls used before Chrome
forced us to make all requests in the background.
Kind: static method of TBUtils
| Param | Type | Description |
|---|---|---|
| endpoint | string |
The endpoint to request |
| data | object |
Query parameters as an object |
Performs a POST request and promises the body of the response, or the
full response object on error. Maintains an API similar to $.post.
Kind: static method of TBUtils
| Param | Type | Description |
|---|---|---|
| endpoint | string |
The endpoint to request |
| data | object |
The body of the request. |
Perform a HEAD request.
Kind: static method of TBUtils
Todo
- Implement with promises (consumers need to be updated)
- "get head" is a confusing name
| Param | Type | Description |
|---|---|---|
| endpoint | string |
The endpoint to request |
| doneCallback | callback |
Sends an authenticated request against the OAuth API from the background page.
Kind: static method of TBUtils
| Param | Type | Description |
|---|---|---|
| method | string |
An HTTP verb |
| endpoint | string |
The endpoint to request |
| data | object |
Query parameters as an object |
Kind: static typedef of TBUtils
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 |
| betaMode | boolean |
toolbox beta mode enabled |
| debugMode | boolean |
toolbox debugMode enabled |
| compactMode | boolean |
toolbox compactmode enabled |
| advancedSettings | boolean |
toolbox advanced settings enabled |
| cookiesEnabled | boolean |
Browser cookies enabled |