FANDOM


HighlightUsers is a more customizable version of Highlight and Admins & Bureaucrats Highlight. It will automatically change the color of links to certain groups or users to the specified color. By default, only links to User:X will be colored, but this can be changed (see below). This is easier than using CSS, as it doesn't require a constantly updated list of users to color a group, but it is slower because it uses AJAX.

Installation

If installing wiki-wide, place on MediaWiki:Common.js. For personal use, place on your Special:Mypage/wikia.js (/monobook.js for Monobook).

highlight = {
    selectAll: false,
    ...,
    users: {
        ...
    }
};
importArticles({
    type: 'script',
    articles: [
        'u:dev:HighlightUsers/code.js'
    ]
});
importArticles — Best Practices for installing JavaScript on FANDOM
The importArticles statement is designed to combine multiple HTTP requests into a single data transfer, allowing multiple scripts to load and execute faster. If you've been installing several different scripts, your JavaScript file has probably accumulated unnecessary import statements. Click "Expand" to learn how to efficiently batch import scripts to speed up performance and make your code look cleaner. One other approach is by using the MediaWiki:ImportJS.
If your JavaScript file has several lines of code that say importScript, importScriptPage, or importArticles, you may be able to combine them! By batch importing a collection of scripts with a single import, your JavaScript code will load faster and look cleaner. Consider the example below. On the left is an example of what your JavaScript file might currently look like. On the right is how you could improve that code.
Multiple imports — messy and slow One import — clean and efficient
importScriptPage('AjaxRC/code.js','dev');
 
importScript('MediaWiki:localScript.js');
 
importArticle({
  type: 'script',
  article: 'u:dev:FloatingToc/code.js'
});
 
importScriptPage('page1.js', 'wikiname');
 
importScriptPage('page2.js', 'wikiname');
importArticles({
    type: 'script',
    articles: [
        'u:dev:AjaxRC/code.js',
        'MediaWiki:localScript.js',
        'u:dev:FloatingToc/code.js',
        'u:wikiname:page1.js',
        'u:wikiname:page2.js'
    ]
});
Note: In this example, pay close attention to the placement of commas and other punctuation. For people who aren't familiar with programming (and even those who are!), a common mistake when writing code is to accidentally delete, forget, or misplace critical symbols like commas or quotation marks. This can cause a syntax error that breaks the code. Carefully follow the convention shown here when using importArticles.
But there's much more to importArticles than just this! For more examples and advanced usage, see the help page at Help:Including additional JavaScript and CSS.


Customization

Change the first line to selectAll: true; to change the color of all links to that user rather than only User: links. (Currently only links with a colon before the username will work, and will not work if there is anything after the username. Let me know if you want the option to affect more links.)

For groups, replace the first ... with lines following a pattern like this:

    sysop: 'purple',
    bot: '#00FF00',

For coloring individual users, replace the ... after users in the code above with lines following a pattern like this:

    users: {
        user1: '#000000',
        'other user': '#FFFFFF'
    }

All links affected by the script will have the class highlight-users-script. This can be used in CSS files to further customize the links; for example, the following will bold selected links:

.highlight-users-script {
    font-weight: bold;
}

Examples

Correct punctuation is important. Any user or group name with a space must have quotes around it. Group names must be what is defined in the system; you can find the name of a group by looking at the URL for the list of that group on Special:ListGroupRights. This is what a filled-out example could look like:

highlight = {
    selectAll: false,
    sysop: '#0000FF',
    bot: 'white',
    users: {
        Asdf: 'red',
        'Someone else': 'green'
    }
};

Without any individual users, and increased link selection:

highlight = {
    selectAll: true,
    sysop: 'purple',
    'other group': '#FF0000',
    users: {
 
    }
};

Remove any ... from lines you aren't using.

Notes

The last specification that matches a user will determine the color of that user. For example, if your wiki has bots with sysop rights, you should put the bot group color after the sysop group so that bots will get the bot color. Users should be specified last so that anything else is overridden.

Please feel free to contact me with any suggestions, questions, bug reports, etc. I'd love to make this script as good as possible.

This script has not been tested on Monobook, but should theoretically work the same.

Start a Discussion Discussions about HighlightUsers

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.