User:MrJaroslavik/metawiki.js

// BUTTONS IN SIDEBAR $.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function {	pathoschild.TemplateScript.add([ // DONE { name: 'Done', template: ':\x7b\x7bdone}},--\x7E\x7E\x7E\x7E', position: 'after', editSummary: '+done', forNamespaces: ['0', '1', '2', '3', '4', '5', '9', '11', '15'] }, // NOT DONE { name: 'Not Done', template: ':\x7b\x7bnot done}},--\x7E\x7E\x7E\x7E', position: 'after', editSummary: '+not done', forNamespaces: ['0', '1', '2', '3', '4', '5', '9', '11', '15'] }, // DOING { name: 'Doing', template: ':\x7b\x7bdoing}},--\x7E\x7E\x7E\x7E', position: 'after', editSummary: '+doing', forNamespaces: ['0', '1', '2', '3', '4', '5', '9', '11', '15'] }, // CATEGORY { name: 'Category', template: '[[Category:]]', position: 'cursor', editSummary: '+', forNamespaces: 'template' }, // DOCUMENTATION SUBPAGE { name: 'Doc Subpage', template: '\x7b\x7bDocumentation subpage}}\n<<>>\n\n== Usage ==\n{| class="wikitable"\n!Template !! Result\n|-\n|\x7b\x7btlx|xxx}} || \x7b\x7bxxx}}\n|-\n|\x7b\x7btlx|xxx}} || \x7b\x7bxxx}}\n|}\n\n== See also ==\n<<>>', position: 'cursor', editSummary: '+', forNamespaces: 'template' },	]); });

$(document).ready(function {	if (mw.config.get('wgCanonicalSpecialPageName') !== 'Block') return;	document.getElementsByName("wpAutoBlock")[0].checked = true; });

$(document).ready(function {	if (mw.config.get('wgCanonicalSpecialPageName') !== 'GlobalBlock') return;	document.getElementsByName("wpAnonOnly")[0].checked = true;	document.getElementsByName("wpAlsoLocal")[0].checked = true; });

$(document).ready(function {	if (mw.config.get('wgCanonicalSpecialPageName') !== 'MultiLock') return;	document.getElementById('wpReasonList').value = 'spam-only account';	document.getElementById('wpActionLock').value = 'lock';	document.getElementsByName("markasbot")[0].checked = true; });

// global locks /* Forked from https://meta.wikimedia.org/w/index.php?title=MediaWiki:Gadget-CentralAuthInterlinkFixer.js&oldid=17316358 /** * Fix links like User:Example@somewiki on Special:Log and Special:Recentchanges * @author VasilievVV, 2008-2010 * @author Kalan, 2008 * @author Splarka, 2008 * @author Krinkle, 2012 */ /*global mediaWiki, jQuery */ /*jshint browser:true */ (function (mw, $) {	'use strict';	function host(id) {		var miraheze;		if (id === 'testwiki') {			return 'publictestwiki.org';		}		miraheze= /^(conduct|cvt|staff)wiki$/;		if (miraheze.test(id)) {			return id.replace(/ /g, '-').replace(/_/g, '-').replace(/wiki$/, '.miraheze.org');		}		return false;	}

function fixCrosswikiLinks { $('body li a').each(function {			var bits, wiki, user, hostName,				$el = $(this),				txt = $el.text;			if (txt.indexOf('@') !== -1 && txt.indexOf('/') === -1 && /^User\:/i.test(txt)) {				bits = txt.split('@');				user = bits.shift.replace(/^\s*User:(.+)\s*$/g, '$1');				wiki = bits.join('@');				if (wiki === 'global') {					$el.attr('href', mw.config.get('wgScript') + '?title=Special:CentralAuth&target=' + encodeURIComponent(user));				} else {					hostName = host(wiki);					if (hostName) {						$el.attr('href', '//' + hostName + '/wiki/User:' + encodeURIComponent(user));					}				}				if (wiki !== 'metawiki') {					$el.removeClass('new external').addClass('extiw');				}				$el.attr('title', txt);			}		}); }

if (mw.config.get('wgCanonicalSpecialPageName') === 'Log' || mw.config.get('wgCanonicalSpecialPageName') === 'Recentchanges' || mw.config.get('wgCanonicalSpecialPageName') === 'MultiLock' || mw.config.get('wgCanonicalSpecialPageName') === 'CentralAuth') { mw.hook('wikipage.content').add(fixCrosswikiLinks); } }(mediaWiki, jQuery));