User:Anomie/watchlist-change-style-selector.js

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($(' Watchlist change style: ').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($(' Unviewed changes style: ').append(s)); }); });