defaultConfig

Members

(static) addTopicButtonSelectors :Array.<string>

Source:
Default Value:
  • []

Selectors of buttons (to be precise, <a> elements to function as buttons) that are used to add topics. It's preferable to add the cd-addTopicButton class to these buttons instead of using this value.

Type:
  • Array.<string>

(static) archivePaths :Array.<(module:defaultConfig~ArchivePathEntry|RegExp)>

Source:
Default Value:
  • []

Collection of archive paths, (sometimes) with correspondent source pages paths. It is used in multiple purposes:

  • to identify pages that will be considered inactive, i.e. no replies can be left on them;
  • to suggest to search in the archive if the section/comment by a given fragment is not found on the page;
  • to make diff/thank links work on archive pages.

Each of the array elements can be an object with defined structure (see module:defaultConfig~ArchivePathEntry for details) or a regexp. In the latter case, if a page name matches the regexp, it will be considered an archive page, and the name of the source page for that page will be obtained by removing everything that starts with the pattern in the page name (i.e., the actually used regexp will end with .*).

The entries are applied in the order of their presence in the array. So, if a page name fits two patterns, the one closer to the beginning of the array is used.

Type:
Example
[
  {
    source: 'Wikipedia:Village pump/Geography',
    archive: 'Wikipedia:Village pump/Geography/Archives/',
  },
  {
    source: 'Wikipedia:Village pump/$1',
    archive: 'Wikipedia:Village pump/Archive/$1/',
    replacements: [/[^/]+/],
  },
  /\/Archive/,
]

(static) badCommentBeginnings :Array.<RegExp>

Source:
Default Value:
  • []

Regexps for strings that should be cut out of comment beginnings (not considered parts of comments) when editing comments. This is in addition to convenientDiscussions.g.badCommentBeginnings, file markup and "clear" templates (see module:defaultConfig.clearTemplates). They begin with ^ and usually end with *\n+ or *\n+(?=[*:#]). They should match a newline character at the end for the script to work properly.

Type:
  • Array.<RegExp>
Example
[
  /^<!--[^]*?--> *\n+/,
  // ...But comments are cut out of comment beginnings by default, so you don't need to specify
  // it.
]

(static) bytesToDeemComment :number

Source:
Default Value:
  • 50

Lower limit of the number of bytes to be added to the page to deem an edit a new comment. Used to determine whether to create a comment link on pages that list revisions (watchlist, history, etc.).

Type:
  • number

(static) clearTemplates :Array.<string>

Source:

Names of the templates that are analogs of https://en.wikipedia.org/wiki/Template:Clear.

Type:
  • Array.<string>

(static) closedDiscussionClasses :Array.<string>

Source:
Default Value:
  • []

Classes of elements that are wrapped around closed discussions.

Type:
  • Array.<string>

(static) closedDiscussionTemplates :Array.<Array.<string>>

Source:
Default Value:
  • [ [], [], ]

Names of the closed discussion templates. They can be single templates like https://en.wikipedia.org/wiki/Template:Closed or pair templates like https://ru.wikipedia.org/wiki/Template:Закрыто / https://ru.wikipedia.org/wiki/Template:Конец_закрытой_секции. Include the closing part of the pair templates in the second array, and the rest of the templates in the first array. These templates are ignored when searching for a place to insert a comment in the wikitext.

Type:
  • Array.<Array.<string>>

(static) commentAntipatterns :Array.<RegExp>

Source:
Default Value:
  • []

All lines containing these patterns will be ignored when searching for comments in the wikitext.

Type:
  • Array.<RegExp>

(static) customCommentFormModules :Array.<module:defaultConfig~Module>

Source:
Default Value:
  • []

Load these modules on comment form creation. See module:defaultConfig~Module for the object structure. If checkFunc is set, the module will be loaded if the condition is met.

See also the commentFormCustomModulesReady hook which allows to specify actions after the modules listed in this value are loaded.

Type:

(static) customTalkNamespaces :Array.<number>

Source:
Default Value:
  • mw.config.get('wgExtraSignatureNamespaces')

Numbers of talk namespaces other than odd namespaces. If not set, the value of mw.config.get('wgExtraSignatureNamespaces') will be used. For example: [4] for Project.

Warning: This value is overriden by module:defaultConfig.pageWhitelist: customTalkNamespaces is used only if pageWhitelist is [] or null.

Note that this value is used in the script as a "soft" value. I.e., the script can decide (based on the presence of the "Add section" button, existence of comments on the page and possibly other factors) that the page is not a talk page after all. Use module:defaultConfig.pageWhitelist to indicate pages where the script should work in any circumstances. (For example, you can specify the entire namespace, e.g., /^Wikipedia:/).

Type:
  • Array.<number>

(static) defaultIndentationChar :string

Source:
Default Value:
  • ':'

Character that should directly precede the comment text. Normally, ':' or '*'. In votings, '#' is used automatically.

Type:
  • string

(static) defaultInsertButtons :Array.<(string|Array)>

Source:
Default Value:
  • []

Default collection of insert buttons displayed under the comment input in comment forms.

Type:
  • Array.<(string|Array)>

(static) defaultSignaturePrefix :string

Source:

Signature prefix (the text added before the signature) used by default, including a space at the beginning if it is needed.

Type:
  • string

(static) dontConfirmEmptyCommentPages :Array.<RegExp>

Source:
Default Value:
  • []

Regular expression matching the names of the pages where an sending empty comment shouldn't be confirmed (e.g., voting pages).

Type:
  • Array.<RegExp>

(static) excludeFromHeadlineClasses :Array.<string>

Source:
Default Value:
  • []

Classes of elements that should be ignored when extracting headline text. For example, elements added by gadgets.

Type:
  • Array.<string>

(static, nullable) genderNeutralUserNamespaceAlias :string

Source:

If the user namespace uses different aliases based on gender, but it has an alias that is gender-neutral, specify it here.

Type:
  • string
Examples
// Russian Wikipedia
'У'
// Possible option
'User'

(static) hookToFireWithAuthorWrappers :string

Source:
Default Value:
  • 'wikipage.content'

Name of the hook to fire with author link wrappers after reformatting comments. Used to run scripts such as "Mark administrators" and "Mark blocked users" for those links.

It's advisable to create a distinct hook for parsing userlinks, such as 'global.userlinks'. Using the 'wikipage.content' hook could theoretically disrupt code that needs to process the whole page content if it runs later than CD. But typically CD runs relatively late.

Type:
  • string

(static) idleFragments :Array.<RegExp>

Source:
Default Value:
  • []

Regexps for fragments that shouldn't trigger the "Section not found" notification.

Type:
  • Array.<RegExp>

(static) indentationCharMode :'mimic'|'unify'

Source:

Should a new comment at the first level (:) repeat the previous comment's indentation style ('mimic' mode), or should the script use the default indentation character in module:defaultConfig.defaultIndentationChar in all cases ('unify' mode). Note that if the last comment of the section uses # as the first indentation character, the script will use it for the comment independent of this value.

Type:
  • 'mimic' | 'unify'

(static, nullable) indentationCharsPattern :string

Source:
Default Value:
  • '([:*#]+)( *)'

String to be put into a regular expression for matching indentation characters. The start of the pattern will match the beginning of a line (but ^ will be prepended automatically). The first group should contain indentation characters, the second - characters after them (usually spacing).

Type:
  • string

(static) keepInSectionEnding :Array.<RegExp>

Source:
Default Value:
  • [ /\n{2,}(?:<!--[^]*?-->\s*)+$/, /\n+(?:<!--[^]*?-->\s*)*<\/?(?:section|onlyinclude)(?: [\w ]+(?:=[^<>]+?)?)? *\/?>\s*(?:<!--[^]*?-->\s*)*$/i, /\n+<noinclude>([^]*?)<\/noinclude>\s*$/i, ]

Regexps for strings that should be kept in section endings when adding a reply or subsection (so that this reply or subsection is added before them, not after). Should begin with at least one \n and allow a newline character at the end (for example, by using \s*).

Type:
  • Array.<RegExp>

(static) longCommentThreshold :number

Source:
Default Value:
  • 10000

How many characters should a comment have to be considered long. Comments having more characters will need confirmation to be sent.

Type:
  • number

(static) mentionCharacter :string

Source:

Character used to trigger user mention (ping) autocomplete.

Type:
  • string

(static) mentionRequiresLeadingSpace :boolean

Source:

Should there be a leading space (or other punctuation) before the mention character to trigger autocomplete.

Type:
  • boolean

(static) messages :object

Source:
Default Value:
  • {}

Object with the names and texts of the messages required by the script as keys and values. Used to avoid making additional requests on every script run. Get these messages by running https://commons.wikimedia.org/wiki/User:Jack_who_built_the_house/convenientDiscussions-generateBasicConfig.js in your browser's console while the page of your wiki is open.

Type:
  • object

(static) noHighlightClasses :Array.<string>

Source:
Default Value:
  • []

Classes of elements that shouldn't be highlighted. It is preferable to add the cd-noHighlight class to these elements instead of using this value. Some elements are not highlighted by default (images, "move topic" marks, empty list elements).

Type:
  • Array.<string>

(static) noSignatureClasses :Array.<string>

Source:
Default Value:
  • []

Elements with classes listed here won't be considered legit comment timestamp containers. They can still be parts of comments (e.g. in "moved section" templates); for the way to prevent certain elements from becoming comment parts, see module:defaultConfig.rejectNode. This value can have a wikitext counterpart (though not necessarily), module:defaultConfig.noSignatureTemplates, for classes that are specified inside templates.

It is preferable to add the mw-notalk class to these elements instead of using this value.

When it comes to the wikitext, all lines containing these classes are ignored.

Type:
  • Array.<string>

(static) noSignatureTemplates :Array.<string>

Source:
Default Value:
  • []

Templates listed here (for example, "Moved discussion" templates) won't be considered legit comment timestamp containers. All lines containing these templates are ignored when searching for timestamps in the wikitext. This value can have a web page counterpart, module:defaultConfig.noSignatureClasses.

Type:
  • Array.<string>

(static) outdentClass :string

Source:

Name of the class that the outdent templates set to its container element.

Type:
  • string

(static) outdentTemplates :Array.<string>

Source:
Default Value:
  • []

Names of the templates that are analogs of https://en.wikipedia.org/wiki/Template:Outdent. The first string may be used when posting comments if this feature is implemented.

Type:
  • Array.<string>

(static) pageBlacklist :Array.<RegExp>

Source:
Default Value:
  • []

Pages where the script shouldn't run. The blacklist has priority over the whitelist.

Type:
  • Array.<RegExp>

(static) pagesWithoutArchives :Array.<RegExp>

Source:
Default Value:
  • []

Pages that can never have archives on a subpage (a subpage is a page with a subtitle after "/"). If the section specified in the URL fragment will not be found, an error message will suggest to search in the archives if the page name doesn't match one of these regexps.

Type:
  • Array.<RegExp>

(static) pageWhitelist :Array.<RegExp>

Source:
Default Value:
  • []

Pages where the script should run. If [], all pages in the namespaces listed in module:defaultConfig.customTalkNamespaces will pass.

If you add at least one value, module:defaultConfig.customTalkNamespaces will not be used. This means you will probably need to specify the namespaces listed in that value here as regexps, partly or entirely. For example, to specify the entire "Wikipedia" namespace in this value, add /^Wikipedia:/ to the array.

The blacklist has priority over the whitelist.

Type:
  • Array.<RegExp>

(static) pairQuoteTemplates :Array.<Array.<string>>

Source:
Default Value:
  • [ [], [], ]

There are quote template pairs where there is a beginning template and an ending template, like {{Quote begin}}{{Quote end}}. So, this is an array of two arrays of strings: the first one for beginning templates, the second one for ending templates.

Type:
  • Array.<Array.<string>>

(static) paragraphTemplates :Array.<string>

Source:
Default Value:
  • []

Names of the templates that are analogs of https://en.wikipedia.org/wiki/Template:Paragraph_break. The first string will be used when posting comments.

Type:
  • Array.<string>

(static) quoteFormatting :Array.<string>|module:defaultConfig~QuoteFormattingFunction

Source:
Default Value:
  • ["> ''", "''\n"]

Array of two strings to insert before and after the selection when quote function is activated (by the toolbar button or Ctrl+Alt+Q / Q). You may also specify a function that takes the following parameters: is the selected text multiline, author, date and DiscussionTools ID, and returns the said array.

If you add template markup, you should perhaps use 1= before the parameter content to allow the = character inside a quotation, for example ['{{tq|1=', '}}'].

If you specify a function, you might want to use different templates for single line and multiline quotations by checking the first argument.

Type:

(static) scriptCodeName :string

Source:
Default Value:
  • 'convenient-discussions'

Script code name. Used, for example, for the source parameter of the thank request: https://www.mediawiki.org/wiki/Extension:Thanks#API_documentation.

Type:
  • string
Source:
Default Value:
  • 'mw:c:Special:MyLanguage/User:JWBTH/CD'

Wikilink to the script's page. Used in the watchlist and, if there is no tag, in summary.

Type:
  • string

(static, nullable) signatureEndingRegexp :RegExp

Source:
Default Value:
  • null

Unchangable text (usually a user talk page link) at the end of Mediawiki:Signature (visible text, not wikitext). Used to detect comments where the user has forgotten the forth tilde. Don't set if this string is not unique enough (i.e. can be met at the end of regular comments.)

Should end with $.

Type:
  • RegExp
Example
/ \(talk\)$/

(static) signaturePrefixRegexp :RegExp

Source:
Default Value:
  • /(?:\s[-–−—―]+\xa0?[A-Z][A-Za-z-_]*)?(?:\s+>+)?(?:[·•\-‑–−—―─~⁓/→⇒\s\u200e\u200f\u2060]|&\w+;|&#\d+;)*(?:\s+\()?$/

Text that is removed from the end of the comment text and transferred to the beginning of the signature text when editing a comment.

End the regexp with $.

' is removed independently in the script so that normal markup at the end of comments doesn't get removed - like this:

''Reply in italics.'' [signature]

Here, '' is not a part of the signature.

(?:\s[-–−—―]+\xa0?[A-Z][A-Za-z-_]*)? is for cases like https://en.wikipedia.org/?diff=1033395227.

Type:
  • RegExp

(static) signatureScanLimit :number

Source:
Default Value:
  • 100

How many displayed (not wikitext) characters to go back from a timestamp looking for an author link.

Type:
  • number

(static) smallDivTemplates :Array.<string>

Source:
Default Value:
  • []

Name of the templates that are analogs of https://en.wikipedia.org/wiki/Template:Smalldiv. Used when the whole comment is wrapped in <small></small> (with some exceptions when that could break the layout).

Type:
  • Array.<string>

(static) spaceAfterIndentationChars :boolean

Source:
Default Value:
  • true

Whether to put a space between the indentation chars and the comment text.

Type:
  • boolean

(static) specialPageAliases :object

Source:
Default Value:
  • []

Localized aliases of several special pages. Get by running https://commons.wikimedia.org/wiki/User:Jack_who_built_the_house/convenientDiscussions-generateBasicConfig.js in your browser's console while the page of your wiki is open.

Each special page can have either an array of alias strings or an alias string.

Type:
  • object

(static) substAliases :Array.<string>

Source:
Default Value:
  • []

Localized aliases of the subst: magic word. Get by running https://commons.wikimedia.org/wiki/User:Jack_who_built_the_house/convenientDiscussions-generateBasicConfig.js in your browser's console while the page of your wiki is open.

Type:
  • Array.<string>

(static) summaryCommentTextLengthLimit :number

Source:
Default Value:
  • 50

Upper limit of the length of a comment to put its whole content in the edit summary.

Type:
  • number

(static, nullable) tagName :string

Source:
Default Value:
  • null

Convenient Discussions tag according to Special:Tags. Needs to be added manually. Set to null of there is no tag.

Type:
  • string

(static) textReactions :Array.<module:defaultConfig~Reaction>

Source:
Default Value:
  • []

Custom reactions.

Type:

(static) thumbAliases :Array.<string>

Source:
Default Value:
  • []

Localized aliases of the thumb magic word. Get by running https://commons.wikimedia.org/wiki/User:Jack_who_built_the_house/convenientDiscussions-generateBasicConfig.js in your browser's console while the page of your wiki is open.

Type:
  • Array.<string>

(static, nullable) timezone :string

Source:
Default Value:
  • null

Timezone. Get by running https://commons.wikimedia.org/wiki/User:Jack_who_built_the_house/convenientDiscussions-generateBasicConfig.js in your browser's console while the page of your wiki is open.

Type:
  • string

(static) undoTexts :Array.<string>

Source:
Default Value:
  • []

Strings present in edit summaries of undo/revert edits. Used to detect edits that shouldn't be considered comments on pages that list revisions (watchlist, contributions, history). Displayed text, not wikitext. Take from MediaWiki:Undo-summary, MediaWiki:Revertpage.

Type:
  • Array.<string>

(static) unsignedClass :string

Source:

Name of the class that the unsigned templates set to its container element.

Type:
  • string

(static) unsignedTemplates :Array.<string>

Source:
Default Value:
  • [ 'unsigned', 'unsignedIP', 'unsigned2', 'unsignedIP2', ]

Names of the templates that are analogs of https://en.wikipedia.org/wiki/Template:Unsigned, https://en.wikipedia.org/wiki/Template:Unsigned_IP. Please include aliases.

Type:
  • Array.<string>

(static, nullable) useGlobalPreferences :boolean

Source:
Default Value:
  • true

Whether to store some of the preferences globally. Requires the GlobalPreferences extension to be enabled.

Type:
  • boolean

(static, nullable) userNamespacesByGender :module:defaultConfig~UserNamespacesByGender

Source:

If the user namespace uses different aliases based on gender, include them here. Unfortunately, we can't get this using API, see https://phabricator.wikimedia.org/T204610.

Type:
Example
// If only the female form differs from the standard name
{
  female: 'Участница',
}

Methods

(static, nullable) afterAuthorLinkParse(authorLink, data) → {Element}

Source:
Default Value:
  • null

Function that runs when the "Reformat comments" setting is enabled after parsing the author link. May return (for example, an element). It accepts the author link (a link to the author's user page) as it was encountered on the page and the return value of module:defaultConfig.beforeAuthorLinkParse that could be called previously.

This function, together with module:defaultConfig.beforeAuthorLinkParse, can be used to optimize the script's performance with different kinds of "Mark administrators" gadget. See the example at https://commons.wikimedia.org/wiki/User:Jack_who_built_the_house/convenientDiscussions-commonsConfig.js.

Parameters:
Name Type Description
authorLink Element
data *
Returns:
Type
Element

(static, nullable) areNewTopicsOnTop(title, code) → (nullable) {boolean}

Source:
Default Value:
  • null

Function that returns true if new topics are placed on top of the page.

Parameters:
Name Type Description
title string
code string
Returns:
Type
boolean

(static, nullable) beforeAuthorLinkParse(authorLink) → {*}

Source:
Default Value:
  • null

Function that runs when the "Reformat comments" setting is enabled before parsing the author link. May return some data that will eventually supplied to the module:defaultConfig.afterAuthorLinkParse function (for example, an element). It accepts the author link (a link to the author's user page) as it was encountered on the page.

This function, together with module:defaultConfig.afterAuthorLinkParse, can be used to optimize the script's performance with different kinds of "Mark administrators" gadget. See the example at https://commons.wikimedia.org/wiki/User:Jack_who_built_the_house/convenientDiscussions-commonsConfig.js.

Parameters:
Name Type Description
authorLink Element
Returns:
Type
*

(static) getAnchorCode(id) → {string}

Source:
Default Value:
  • function (id) { return '<span id="' + id + '"></span>'; }

Code that creates an anchor on the page.

Parameters:
Name Type Description
id string
Returns:
Type
string

(static, nullable) getMoveSourcePageCode(targetPageWikilink, signature, timestampopt) → {string}

Source:
Default Value:
  • function (targetPageWikilink, signature, timestamp) { return ( convenientDiscussions.s('move-sourcepagecode', targetPageWikilink, signature, timestamp) + '\n' ); }

Function that returns the code to insert in the place of a section moved to another page. The string normally ends with \n. If null, the section is just removed from the page.

Parameters:
Name Type Attributes Description
targetPageWikilink string
signature string
timestamp string <optional>
Returns:
Type
string

(static, nullable) getMoveTargetPageCode(targetPageWikilink, signature) → {string|Array.<string>}

Source:
Default Value:
  • function (targetPageWikilink, signature) { return convenientDiscussions.s('move-targetpagecode', targetPageWikilink, signature) + '\n'; }

Function that returns the code to insert in the beginning of the section moved from another page or an array of two strings to insert in the beginning and ending of the section respectively. The strings normally end with \n. If null, no code will be added.

Parameters:
Name Type Description
targetPageWikilink string
signature string
Returns:
Type
string | Array.<string>

(static, nullable) postTransformCode(code, commentForm) → {string}

Source:
Default Value:
  • null

Function that makes custom alterations to the comment's source code after it is processed and before it is submitted. (An example would be adding a closer template to all the closures by a user with the closer flag which is a requirement in Russian Wikipedia.) See also module:defaultConfig.preTransformCode.

Parameters:
Name Type Description
code string
commentForm CommentForm
Returns:
Type
string

(static, nullable) preTransformCode(code, commentForm) → {string}

Source:
Default Value:
  • null

Function that makes custom alterations to the comment's source code before it is processed and submitted. See also module:defaultConfig.postTransformCode.

Parameters:
Name Type Description
code string
commentForm CommentForm
Returns:
Type
string

(static, nullable) rejectNode(node, context) → {boolean}

Source:
Default Value:
  • null

Function that returns true for nodes that are not parts of comments and should terminate the comment part collecting. These rules often need correspoding rules in module:defaultConfig.badCommentBeginnings.

The second parameter is a "context", i.e., a collection of classes, functions, elements, and names that help perform the tasks we need in the current context (window or worker). Examples are the document element and the name of the child elements property (the worker context uses childElements instead of children due to relying on the htmlparser2 module, therefore you should use element[context.childElementsProp] to access element children instead of element.children). Contexts are predefined in the script like this.

Parameters:
Name Type Description
node Node | external:Node
context Context
Returns:
Type
boolean

(static, nullable) transformSummary(summary) → {string}

Source:
Default Value:
  • null

Function that transforms the automatically generated summary text.

Parameters:
Name Type Description
summary string
Returns:
Type
string

Type Definitions

ArchivePathEntry

Source:
Properties:
Name Type Attributes Description
source string

Source path. Dynamic parts should be replaced with tokens such as $1, $2, etc. Regular expressions for these tokens, if any, should be defined in the replacements array.

archive string

Archive prefix. Should use the same tokens as in source.

replacements Array.<RegExp> <optional>

Array of replacements for $1, $2 tokens in source and archive. Note that the regexp should, if put into the archive pattern, capture only the part that is common for the source page and the archive pages. E.g., in "Wikipedia:Village pump/Archive/General/2020/07", it should capture "General", but not "General/2020/07". So, you shouldn't use /.+/ here and use, for example, /[^/]+/ instead.

Object that connects active (source) talk page names with their archive pages prefixes and vice versa: archive page names with their source page names.

Type:
  • object

Module

Source:
Properties:
Name Type Attributes Description
name string

Name of the module.

checkFunc function <optional>

Function that must return true for the module to be loaded (if it is present).

Type:
  • object

QuoteFormattingFunction() → {Array.<string>}

Source:
Properties:
Name Type Attributes Description
isMultiline string

Is the selected text multiline.

author string <optional>

Quote author.

timestamp string <optional>

Quote timestamp.

dtId string <optional>

Comment's DiscussionTools ID.

Function to use in the module:defaultConfig.quoteFormatting config value.

Returns:
Type
Array.<string>

Reaction

Source:
Properties:
Name Type Attributes Default Description
regexp RegExp

Regular expression to match.

message string

Message displayed to the user.

name string

Latin letters, digits, -.

type 'notice' | 'error' | 'warning' | 'success' <optional>
'notice'

One of OO.ui.MessageWidget's types.

checkFunc function <optional>

If this function returns false, no message is displayed.

Object specifying messages to be displayed when the user enters text that matches a regular expression.

Type:
  • object

UserNamespacesByGender

Source:
Properties:
Name Type Description
male string
female string
unknown string
Type:
  • object