User:PleaseStand/Comment highlighter
Comment highlighter is a user script by PleaseStand that highlights your discussion page comments (or those of other users) while reading a discussion page (comments are not highlighted in edit mode). The script adds a tab or menu item (called "Unhighlight") to allow you to turn off the highlighting manually if necessary. For users of slow computers, it is also possible to disable highlighting by default (see "Configuration" below).
Installation
On the English Wikipedia
Add the following code to Special:MyPage/common.js or Special:MyPage/skin.js:
importScript("User:PleaseStand/highlight-comments.js");
Other wikis
If you are not on the English Wikipedia, you will need to use the following code instead.
// install [[Wikipedia:User:PleaseStand/Comment highlighter]] tool
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:PleaseStand/highlight-comments.js&action=raw&ctype=text/javascript' );
Advanced
Source code
The source code is available at User:PleaseStand/highlight-comments.js. Development takes place on User:PleaseStand/highlight-comments-dev.js.
Configuration
Define a custom highlighter function to change the highlight color or highlight additional users' comments. The highlighter function replaces the script's default settings. Here is a good starting point:
window.highlightCommentsSettings = {
highlighterFunction: function( hc ) {
hc.addColorForUsers( '#ff7', [
mw.config.get( 'wgUserName' ),
'Example',
'127.0.0.1',
'Jimbo Wales'
] );
hc.wrapComments();
hc.addMenuItem();
}
};
- On line 3,
#ff7
is the CSS color code for the highlight color to use for comments by a set of users. - You can replace lines 4–7 with a list of usernames to highlight in that color. The code shown above highlights comments from User:Example, User:127.0.0.1, and User:Jimbo Wales in addition to your own comments. Each line (except for the last) must end in a comma, and a backslash must come before any quotation mark in a username. Omit line 4 to not highlight your own comments; omit lines 5–7 to only highlight your own comments.
- Repeat lines 3–8 to highlight additional users in a different color, changing the color and usernames as described above. All sets of users must come before line 9.
- Omit line 9 (
hc.wrapComments();
) to make the script only highlight comments when you choose the "Highlight" tab or menu item. - Omit line 10 (
hc.addMenuItem();
) to hide the "Unhighlight" tab or menu item, which only makes sense if line 9 is present.
Any configuration setting that begins with "HighlightCommentsJs" (or any CSS rule beginning with ".mycomment") is for an old version of the script; you can safely remove it.
Adding new features
For security reasons, only Wikipedia administrators (and I) can edit the script's source code. You can copy this script into your user space and make changes there. If you believe other users could benefit from your improvements, including any translations of the script into other languages, please show them to me (e.g. as a diff) on my talk page and propose their addition to the master copy. I prefer that all changes conform to the MediaWiki coding conventions, and if possible, produce readable diffs.
Discussion
Ask questions or propose changes on my talk page or on the talk page of these instructions.