User:Jack who built the house/Convenient Discussions
Convenient Discussions (CD) is a JavaScript tool that enhances MediaWiki talk pages, redesigning threads, adding more comment and section actions, new comment navigation, real-time updates, autocomplete, and dozens of other features to make wiki discussions smooth and efficient.
CD has been developed since 2017 by Jack who built the house. It is enriched by contributions and feedback from the global Wikimedia community and integrates solutions and ideas from the Wikimedia Foundation's engineering and design teams.
Features
[edit]

Predating the DiscussionTools (DT) project, CD offers a wide range of features beyond DT functionality:
- Discussion threads are redesigned, making the thread structure clear
Author and date appear at the top of each comment (opt-out)- You can edit and delete comments, move, archive, and unarchive topics, create subsections, and vote in polls
- Comments are highlighted by type: new or updated, your own, jumped-to, linked group, deleted
- New comments can be navigated using the navigation panel or the table of contents
- No more reading talk pages through diffs
- The page checks for updates in real time:
- A live counter shows the number of new comments
- The table of contents and individual threads show which items have new activity and from whom
- Simple comment edits by other users are rendered on the spot, with a diff available
- Desktop notifications are available while the page is open
- Timestamps are shown in your local time in one of several formats, including relative time
- Long, deeply nested discussions are handled well:
- Threads collapse automatically or on demand, making it easier to scan and navigate
- You can navigate between comments using child–parent links, clicking the thread line with the middle button, or even thread sliding
- When replying to the opening comment of a topic, the reply form can be under it or at the end of the section
- No need to scroll back and forth to reply or check details
- {{Outdent}} templates are respected and inserted in a clever way so as not to break or confuse the hierarchy of replies
- Complex multiline markup like quotes and tables doesn't break (as long as it is possible in MediaWiki)
- Beyond
@mentions, there is autocomplete for[[#comment links]],[[wikilinks]],{{templates}}, and<tags>- On Wikimedia wikis, wikilinks autocomplete works across interwiki prefixes (see image) and will even let you autocomplete a page section on a distant wiki
- Pasted links are converted to wikilinks:
http://fr.wiktionary.org/wiki/mot#Françaison Commons becomes[[wikt:fr:mot#Français]] `...`and```lang ...```is converted into code markup, mimicking Markdown
Among other things, CD lets you:
- comment in several places at once, without closing other forms;
- quote comments with their formatting preserved;
- use custom text snippets for anything you type frequently;
- upload screenshots to Commons with ease: paste → pick the source → upload;
- copy links in several formats;
- sort a topic's contributors by name, comment count, or date;
- jump straight to a comment from the watchlist, history, contributions, and elsewhere via a "(comment)" link.
CD is highly customizable per-user and per-wiki, works across wikis, 43 languages, skins, themes, and browsers, supports RTL scripts and anonymous editing.
Limitations
[edit]- Doesn't support VisualEditor
- Doesn't work in the mobile version (but works on mobile with the desktop view)
Installation
[edit]The script's main file is at User:Jack who built the house/convenientDiscussions.js. To install the script for all Wikimedia wikis, add this to your global.js on Meta:
mw.loader.load('https://commons.wikimedia.org/w/index.php?title=User:Jack_who_built_the_house/convenientDiscussions.js&action=raw&ctype=text/javascript');
To install the script on a specific wiki where it's not a gadget, add the same code to your common.js. If the wiki has the script available as a gadget, it makes sense to enable the gadget even if you have the script installed globally—the script will load faster on that wiki.
Every wiki has its own peculiarities that the script can address in the configuration file. Those are individual for each wiki and created by volunteers. If you know JavaScript and your wiki doesn't have one, see § Configuring for a wiki. Having a configuration file for the wiki will also speed up the execution of the script.
Compatibility
[edit]
Convenient Discussions shows timestamps in local time by default. However, you can use another user script for this purpose. To make Convenient Discussions compatible with the script displaying time in the local time zone (w:User:Gary/comments in local time.js or w:User:Mxn/CommentsInLocalTime), call the latter like this:
mw.hook( 'convenientDiscussions.commentsReady' ).add( function () {
// Import the script here
} );
Note that this will not load the script if Convenient Discussions doesn't load. To make the script also load for pages Convenient Discussions won't load on, call it like this:
if (
mw.config.get( 'wgNamespaceNumber' ) % 2 !== 1 &&
!mw.config.get( 'wgExtraSignatureNamespaces' ).includes( mw.config.get( 'wgNamespaceNumber' ) )
) {
// Import the script here
}
For Gary's script specifically, an additional line of code is needed to disable its feature of not loading twice:
mw.hook( 'convenientDiscussions.commentsReady' ).add( function () {
window.commentsInLocalTimeWasRun = false;
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Gary/comments in local time.js&action=raw&ctype=text/javascript' ); // [[w:en:User:Mxn/CommentsInLocalTime]]
}
Be sure to disable the "Comments in Local Time" gadget in your preferences if it is present in your wiki (e.g. the English Wikipedia).
Usage
[edit]
You can adjust the script according to your preferences in the settings dialog. It is available at the click of the gear icon
which can be found in the "CD" section of the watchlist and under any comment form.
Comment types
[edit]Navigation panel
[edit]FAQ
[edit]- The script doesn't work on a page where it should work or vice versa. How to fix it?
- The script uses a number of factors to determine whether it should process a certain page, such as the presence of the "Add topic" tab and the
wgExtraSignatureNamespacesconfig value. The simplest way to make it process/not process a page is to click "Run Convenient Discussions on this page once" in the page footer. But that will work only for one time. You should contact the user maintaining the configuration file on your wiki or create your own configuration file according to the instructions below. In that file, regular expressions to match page names should be added to/removed from thepageWhitelist/pageBlacklistvalues. A worse way to deal with it is to add an element withclass="cd-talkPage"orclass="cd-notTalkPage"to the source code of the page. In that case, the page will still be classified incorrectly on log pages (the watchlist, history pages, etc.).
- What does "(-)" after the comment text in an edit summary mean?
- It means that the whole text of the comment is displayed in the edit summary, and there is no more text in the comment other than that is displayed, so no point to open the page if you only want to see the contents of this edit. It's a notation that was used on some old Internet forums.
- The comment menu (Reply/Edit/Thank/...) overlaps a user link, and I can't click it.
- Make a long click/tap or right click on the block; it will disappear.
- How to set settings for one wiki, not for all wikis?
- Use
var cdLocalSettingName = value;in your common.js on that wiki. You can get the names of the settings here (the first letter should be in upper case, for exampleautopreview→cdLocalAutopreview).
- I would like to have
:inserted after a user mention like in the {{Ping}} template. - Hold Alt while choosing the name you want to mention. You can also press the mention icon while holding Alt — if you're replying to a comment, a mention of the target comment's author with
:will appear at the beginning of your comment.
- In spacious mode, the script doesn't remove usernames in signatures formatted like this:
Username ([[User:Username|user page]]). - There is no reliable algorithm for this. You may ask the user with such a signature to wrap their whole signature in
<span>...</span>— then it will be removed altogether.
Data
[edit]Here's what the script stores, why, how, and how to delete the data. Note that you can delete all the data associated with the script in one click, by opening the script settings and pressing the button "Delete all script data" on the "Data deletion" tab. Note that while the settings (except for a few) are global, visits and watched sections are stored individually for each wiki, so you'll have to remove them separately.
Using the "Edit watched sections list" dialog accessible from the watchlist, ornew mw.Api().saveOption('userjs-convenientDiscussions-watchedSections', null);
| What | Why | How | How to delete[1] |
|---|---|---|---|
| Settings | To allow tuning the script according to the user's preferences. | On the Wikimedia servers as a user option named userjs-convenientDiscussions-settings.
|
Global settings: new mw.Api().postWithEditToken({
action: 'globalpreferences',
optionname: 'userjs-convenientDiscussions-settings',
});
Local settings: new mw.Api().saveOption('userjs-convenientDiscussions-localSettings', null);
|
| Last talk page visits | To detect new comments on talk pages. | In compressed form, on the Wikimedia servers as a user option named userjs-convenientDiscussions-visits.[2]
|
new mw.Api().saveOption('userjs-convenientDiscussions-visits', null);
|
| Unsent comment forms' content | To restore comment drafts after page reloads, browser crashes, accidental jumps to a different page, etc. | For no longer than 60 days, in the browser's local storage. | localStorage.removeItem('convenientDiscussions-commentForms');
|
| Edits thanked via CD | To reflect in the interface that a comment has already been thanked for. | For no longer than 60 days, in the browser's local storage. | localStorage.removeItem('convenientDiscussions-thanks');
|
| Seen comment changes | When a comment is updated, its new version is sometimes rendered immediately. If the user has seen the update, this fact is saved in the memory, so that there is no notification the next time the user sees it. | For no longer than 60 days, in the browser's local storage. | localStorage.removeItem('convenientDiscussions-seenRenderedChanges');
|
- ^ To execute the code in the "How to delete" column, open the browser's developer tools (done by pressing F12 in most browsers), switch to the "Console" tab, paste the code into the input and press ↵ Enter.
- ^ In Russian Wikipedia, for historical reasons, the option names use
cdinstead ofconvenientDiscussions, anduserjs-cd-watchedTopicsis used for the watched sections option.
Note that other scripts that you use on wiki pages, as well as side-wide scripts, have access to this data too.
Feedback
[edit]It's best to post bug reports and proposals on Phabricator under the "convenient-discussions" tag. If you don't have an account there and don't want to create one, post to the talk page.
Configuring for a wiki
[edit]
The scheme of loading the script on a wiki is the following: There is the main script file on Commons and a configuration file on the wiki (if somebody has created it). The configuration file can be a gadget or a user script (a gadget will load faster).
- The configuration file requests the main script file if it is not loaded yet.
- Conversely, if the main file is loaded first, it requests the configuration file if the URL of the configuration file is specified in it.
So, there is no difference which file is loaded first.
To configure the script for a wiki, you may use the configuration generator as described below and then supplement it with configuration values you want. If you want the configuration file to be loaded when users load the script from Commons, you should contact the repository owner. If it proves safe, he will add the URL of the configuration to config/urls.json (you can make a pull request too).
To generate a configuration, run the generator script in your browser's console on any page of the wiki you want the configuration for. You can do it by executing
mw.loader.load('https://commons.wikimedia.org/w/index.php?title=User:Jack_who_built_the_house/convenientDiscussions-generateBasicConfig.js&action=raw&ctype=text/javascript');
in the console. The result will contain a configuration object with values that can be automatically retrieved (system messages, some site info, template names) wrapped in the universal wrapping code. You then should create a configuration file with that content.
The meaningful part of the configuration is contained in the convenientDiscussions.config object. Its possible properties can be found in the source code. There is also a generated documentation, but it is for an old version (v7).
It is recommended to keep only those properties that differ from the default ones.
You can also add any additional instuctions (for example hooks) you need below the object.
Examples
[edit]- w:en:User:Jack who built the house/convenientDiscussions.js (source in the repository)
- w:ru:MediaWiki:Gadget-convenientDiscussions.js (source in the repository)
Note: For complex properties like archivingConfig it may be useful to ask an LLM to generate its value for your wiki while using a mature configuration like w-en or w-ru as an example. You will need to provide the default configuration to the LLM along with all necessary context.
Example plugin
[edit]This plugin adds a "Resolve" item to the section menu. This item adds a {{Section resolved}} template to the end of the section:
mw.hook('convenientDiscussions.moreMenuSelectCreated').add((section) => {
if (section.isTopic() && section.isActionable()) {
section.actions.moreMenuSelect.getMenu().addItems(
new OO.ui.MenuOptionWidget({
data: 'resolve',
label: 'Resolve',
icon: 'check',
})
)
section.actions.moreMenuSelect.getMenu().on('choose', (option) => {
if (option.getData() === 'resolve') {
section.addSubsection({
comment: '{{Section resolved |1= ~~~~ }}',
omitSignature: true,
submit: true,
})
}
})
}
})
How do I turn off the "Reply" buttons?
[edit]To prevent the "Reply" buttons and the rest of the comment layout from showing up in certain templates used on talk pages (e.g. in the "Moved discussion" template after the mover's signature), add the mw-notalk class to those templates.
To prevent the "Reply" buttons from showing up in closed discussions, add the mw-archivedtalk class to the template.
Debugging using Node.js and Git
[edit]If you want to debug your configuration more closely in the browser's development tools and you're familiar with Node.js and Git and have them installed, clone the script's repository, run npm install while in the script's directory to install the dependencies, create a .js file in the config folder named using pattern project_code[-language_code].js (for example, w-en.js, wikt-de.js, mw.js), and put the following code into it:
export default {
// List of properties
};
// Any additional code, e.g. hooks
Then you will need to add the code as described above. After the configuration is ready, you will need to build an actual configuration file that you will put in your wiki. Do it by running npm run configs. The resulting file will be named dist/convenientDiscussions-config/filename.
Test your configuration file by running npm run single -- --project=project_code --lang=language_code (use -- -- --project in PowerShell). A file named convenientDiscussions.single.project_code[-language_code].js will be created (and updated on code changes) in the dist folder. Start the development server using npm run dev, then load the build to the wiki using mw.loader.load('http://localhost:9000/dist/filename').
It will be best if you make a pull request to include your configuration in the CD repository. This way, if something in the script environment changes that affects your configuration file (the format of a property changes, for instance, or a default value, that your value is based on, is updated), other people including the maintainer of the script would be able to notice it and inform you and/or make changes themselves.
Development
[edit]- GitHub repository stores code. GitHub Actions builds and deploys the resulting files to wikis.
- Phabricator tag is used to coordinate efforts. (Post bug reports and proposals there, not at GitHub.)
- Translatewiki has localization strings. Please suggest improvements to the English source through a pull request to en.json.
- Toolforge has automatically generated code documentation for older versions.
- Starting from v8.0.0, the project relies on TypeScript-flavored JSDoc which makes the project type-safe but doesn't let autogenerate documentation.
Your contributions are welcome! You can either improve the script itself or write plugins for it. Some notes:
- The global object of the script is
convenientDiscussions(the modules use thecdalias). convenientDiscussions.s()is an analog ofmw.msg()for the script's language strings.convenientDiscussions.sParse()is an analog ofmw.message(...).parse(). Please make sure all strings that have their raw HTML inserted into the page useconvenientDiscussions.sParse()to prevent introducing XSS vulnerabilities. (All code from untrusted sources is sanitized at earlier stages, but a double check won't hurt.)- The "events" in the left panel of the documentation correspond to the names used by
mw.hook. For example, to attach a handler to thecommentFormCreatedevent, you need the codemw.hook('convenientDiscussions.commentFormCreated').add(handler);. - To see message names instead of messages themselves on a page, add the uselang=qqx parameter to the end of the URL (just like with MediaWiki).
- If you write a plugin and need some internal method to be available publicly via the global object, contact the script's maintainer (or just make a relevant pull request).
- To run unit tests, run
npm run test. Only several key modules are tested. Parser tests are documented in tests/parser-tests.md. - To run E2E tests, run
npm run test:browser. There is limited documentation for them in thee2edirectory.
Building
[edit]Use:
npm run devto serve the script from http://localhost:9000/src/loader/startup.js and automatically rebuild on updates. Wiki configuration and translation will still be loaded from web.npm run single -- --project=project_code --lang=language_code(use-- -- --projectin PowerShell) to serve the script as a single file. Useful to debug configuration and translation.npm run buildto build the main file, source maps, project configuration files, translation files, and license file. Use--stagingto build the files with the.stagingpostfix.npm run configsto generate wiki configuration files. Use--stagingto generate the files with the.stagingpostfix.npm run deployto deploy the built files (including wiki configurations) to wikis as configured inconfig.js. Use--stagingto deploy the staging versions.

