This script adds various classes to the link elements based on various characteristics:
You can then add CSS rules to apply various visible changes to the different types of links. A number of default rules are available in User:Anomie/linkclassifier.css.
To use the script, add the following to your skin-specific Javascript file.
importScript('User:Anomie/linkclassifier.js'); // Linkback: [[User:Anomie/linkclassifier.js]]
importStylesheet('User:Anomie/linkclassifier.css'); // Linkback: [[User:Anomie/linkclassifier.css]]
Note that this script has only been extensively tested on Monobook.
If you want to adjust the list of categories, a hook is provided for that purpose:
mw.hook( 'LinkClassifier' ).add( function ( linkClassifier ) {
linkClassifier.cats['my-code'] = [ 'Category:Foo', 'Category:Bar' ].sort();
} );
importScript('User:Anomie/linkclassifier.js'); // Linkback: [[User:Anomie/linkclassifier.js]]
importStylesheet('User:Anomie/linkclassifier.css'); // Linkback: [[User:Anomie/linkclassifier.css]]
If you want it to be run on demand (i.e. by clicking a button next to "unwatch"), include it something like this:
LinkClassifierOnDemand=true;
importScript('User:Anomie/linkclassifier.js'); // Linkback: [[User:Anomie/linkclassifier.js]]
importStylesheet('User:Anomie/linkclassifier.css'); // Linkback: [[User:Anomie/linkclassifier.css]]
$.when( mw.loader.using( 'mediawiki.util' ), $.ready ).then( function() {
var el = mw.util.addPortletLink('p-cactions', '', 'Link Classifier');
$(el).on('click', function(e) {
LinkClassifier.onDemand();
e.preventDefault();
} );
} );
In either case, the line for linkclassifier.css may be omitted, if you would rather add custom CSS rules to your skin-specific CSS file.
Please note that the line for linkclassifier.css does not go in your skin.css, it goes in your skin.js along with the other lines. Alternatively, you can copy the contents of User:Anomie/linkclassifier.css into your skin.css and customize the rules however you would like.
With the default rules, you should see the following types of links:
If you want to create your own styles, the following list of colors may or may not be helpful:
Normal | Visited |
---|---|
bf0000 | bf3e3e |
cc6700 | cc8843 |
bfbf00 | bfbf3e |
00bf00 | 3ebf3e |
00bfbf | 3ebfbf |
0033cc | 4365cc |
6000bf | 7f3ebf |
bf00bf | bf3ebf |
bf0066 | bf3e83 |