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('mediawiki.cookie', function(){
$(document).ready(function(){
var x = $('#mw-watchlist-resetbutton');
if(!x || !x.length) x = $('.mw-rcfilters-head');
if(!x || !x.length) return;
// Create selector with list of classes to apply
var s = document.createElement('SELECT');
s.options[s.options.length] = new Option('No indicator', 'wlswitch-none');
s.options[s.options.length] = new Option('Bold (MediaWiki default)', 'wlswitch-bold');
s.options[s.options.length] = new Option('Green stars', 'wlswitch-stars');
s.options[s.options.length] = new Option('Stars and bold', 'wlswitch-starsbold');
s.options[s.options.length] = new Option('Italic', 'wlswitch-italic');
s.options[s.options.length] = new Option('Subtle underscore', 'wlswitch-underline');
s.options[s.options.length] = new Option('Color change', 'wlswitch-colorchange');
s.options[s.options.length] = new Option('Small \'c\' ("changed")', 'wlswitch-small-c');
s.options[s.options.length] = new Option('Highlight', 'wlswitch-highlight');
s.options[s.options.length] = new Option('Faded old changes', 'wlswitch-faded');
s.options[s.options.length] = new Option('Green bullet', 'wlswitch-bullet');
var current = mw.cookie.get('wlswitch-selected', '');
if(current) $(s).val(current);
// Event handler to change the classes
var classlist=[];
for(var i = 0; i < s.options.length; i++) classlist.push(s.options[i].value);
var classlist=classlist.join(' ');
var body = $(document.body);
var setClass=function(){
body.removeClass(classlist);
var v = $(this).val();
body.addClass(v);
mw.cookie.set('wlswitch-selected', v, { expires:365 * 86400, path:'/', prefix:'' });
};
$(s).change(setClass);
setClass.call(s);
x.after($('<p>Watchlist change style: </p>').append(s));
});
});
if(mw.config.get('wgAction') == 'history') mw.loader.using('mediawiki.cookie', function(){
$(document).ready(function(){
var x = $('.mw-history-legend');
if(!x || !x.length) return;
// Create selector with list of classes to apply
var s = document.createElement('SELECT');
s.options[s.options.length] = new Option('No indicator', 'histswitch-none');
s.options[s.options.length] = new Option('Default green tag (MediaWiki default)', 'histswitch-default');
s.options[s.options.length] = new Option('Bright green tag', 'histswitch-bright-tag');
s.options[s.options.length] = new Option('Dull green tag (as on Commons)', 'histswitch-commons');
s.options[s.options.length] = new Option('Green text tag', 'histswitch-greentext');
s.options[s.options.length] = new Option('Bold', 'histswitch-bold');
s.options[s.options.length] = new Option('Green stars', 'histswitch-stars');
s.options[s.options.length] = new Option('Stars and bold', 'histswitch-starsbold');
s.options[s.options.length] = new Option('Italic', 'histswitch-italic');
s.options[s.options.length] = new Option('Subtle underscore', 'histswitch-underline');
s.options[s.options.length] = new Option('Color change links', 'histswitch-colorchange');
s.options[s.options.length] = new Option('Small \'c\' ("changed")', 'histswitch-small-c');
s.options[s.options.length] = new Option('Highlight', 'histswitch-highlight');
s.options[s.options.length] = new Option('Faded old changes', 'histswitch-faded');
s.options[s.options.length] = new Option('Green bullet', 'histswitch-bullet');
var current = mw.cookie.get('histswitch-selected', '');
if(current) $(s).val(current);
// Event handler to change the classes
var classlist=[];
for(var i = 0; i < s.options.length; i++) classlist.push(s.options[i].value);
var classlist=classlist.join(' ');
var body = $(document.body);
var setClass=function(){
body.removeClass(classlist);
var v = $(this).val();
body.addClass(v);
mw.cookie.set('histswitch-selected', v, { expires:365 * 86400, path:'/', prefix:'' });
};
$(s).change(setClass);
setClass.call(s);
x.append($('<p>Unviewed changes style: </p>').append(s));
});
});