User:NguoiDungKhongDinhDanh/logSwap.js

// For attribution: User:Amorymeltzer/logSwap.js

$(function {	if (mw.config.get('wgCanonicalSpecialPageName') !== 'Log') return;	mw.loader.using(['mediawiki.util', 'oojs-ui-core', 'oojs-ui-widgets'], function { var rsbutton = new OO.ui.ButtonInputWidget({label: 'Swap roles', useInputTag: true}); rsbutton.$element.children('input').click(function(event) {			event.preventDefault;			var $user = $('#mw-input-user').children(':first-child'),				$page = $('#mw-input-page').children(':first-child'),				oldUser = mw.Title.newFromText('User:' + $user.val),				oldPage = mw.Title.newFromText($page.val);			oldPage && oldPage.namespace === 2 && ( $page.val('') && $user.val(oldPage.getMain) );			oldUser && oldUser.getMain && ( $page.val(mw.config.get('wgFormattedNamespaces')[2] + ':' + oldUser.getMain) && $user.val('') );		});		$('.mw-htmlform-submit-buttons').append(rsbutton.$element); }); });