User:Anomie/watchlist-change-style-selector.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | This user script seems to have a documentation page at User:Anomie/watchlist-change-style-selector and an accompanying .css page at User:Anomie/watchlist-change-style-selector.css. |
if(mw.config.get('wgPageName') == 'Special:Watchlist') mw.loader.using('jQuery.cookie', function($){
$(document).ready(function(){
var x = $('#mw-watchlist-resetbutton');
if(!x) return;
// Needed until [[bugzilla:36788]] gets fixed
$('strong.mw-watched').parent('li').addClass('mw-watched');
$('strong.mw-watched').parent('table.mw-enhanced-rc').addClass('mw-watched');
// List of classes that can be applied
var classes = {
'wlswitch-00-none' : 'No indicator',
'wlswitch-01-bold' : 'Bold (MediaWiki default)',
'wlswitch-02-stars' : 'Green stars',
'wlswitch-03-boldstars' : 'Green stars and Bold',
'wlswitch-04-italics' : 'Italics',
'wlswitch-05-C' : 'Small "c" ("changed")',
'wlswitch-06-underline' : 'Subtle underscore',
'wlswitch-07-colorchange' : 'Color change',
'wlswitch-08-enhancedcolors' : 'Enhanced link colors',
'wlswitch-09-faded' : 'Faded old changes',
'wlswitch-10-highlight' : 'Highlight',
};
// Insert our selector after the "reset" button
var classlist=[];
for(var k in classes) classlist.push(k);
classlist.sort();
var classstring=classlist.join(' ');
var body = $(document.body);
var setClass=function(){
body.removeClass(classstring);
var v = $(this).val();
body.addClass(v);
$.cookie('wlswitch-selected', v, { expires:365 });
};
var current = $.cookie('wlswitch-selected');
var s = document.createElement('SELECT');
for(var i = 0; i < classlist.length; i++) {
var k = classlist[i];
s.options[i] = new Option(classes[k], k);
if(k == current) s.selectedIndex = i;
}
$(s).change(setClass);
setClass.call(this);
x.after($('<p>Watchlist change style: </p>').append(s));
});
});