User:Alexrmski/fandomdesktop.js

mw.loader.getScript( 'https://ark.gamepedia.com/index.php?title=User:alexrmski/patrolRevs.js&action=raw&ctype=text/javascript' );

$(document).ready(function {

var mwNamespaceId = mw.config.get('wgNamespaceNumber'); var mwPageName = mw.config.get('wgPageName'); var mwAction = mw.config.get('wgAction'); var $navRight = $('#right-navigation'); var $mwEditBox = $('#wpTextbox1'); var $mwReasonBox = $('#wpSummary'); var $myTools = $('.wikia-bar .tools .mytools.menu'); var $dropdownIcon = $('.mytools.menu > .wds-icon.wds-icon-tiny.arrow-icon');

window.UserTools = {       selectors: {           leaveRedirect: 'input[type=checkbox][name=wpLeaveRedirect][checked=checked]', },       namespaces: mw.config.get('wgNamespaceIds'),

redirect: function (dest) {           return '#RE' + 'DIRECT ' + dest; },

category: function (name) {           return '[' + '[Cat' + 'egory:' + name + ']]'; },

file: function (name) {           return '[' + '[Fi' + 'le:' + name + ']]'; },

// suppress redirects by default when moving a page moveSuppressRedirect: function {           if (document.body.classList.contains('mw-special-Movepage')) { document.querySelector(Ut.selectors.leaveRedirect).checked = false; }       },

suppressCategoryRedirects: function(categoryName) {           if (mwPageName === categoryName) { var $links = document.querySelectorAll('#mw-category-media > ul > li .gallerytext > a'); for (var i = 0; i < $links.length; i++) { var $link = $links[i]; var newUrl = $link.getAttribute('href') + "?redirect=no"; $link.setAttribute('href', newUrl); }           }        },

onlyEditing: function(callback) {           if (mwAction === 'edit') { callback; }       },

onlyUploading: function(callback) {           if (mwPageName === 'Special:Upload' || document.body.classList.contains('mw-special-Upload')) { callback; }       },        onlyInNamespace: function(id, callback) {       	if (mwNamespaceId == id) {       		callback; }       },

setUploadLicense: function(key) {           $('#wpLicense').val(key); },

setUploadDescription: function(text) {           $('#wpUploadDescription').val(text); },

buildActionSet: function(name) {           var $menuContents = $(''); var $dropdown = $('') .append($dropdownIcon) .append($('')                           		.text(name)) .append($menuContents) .mouseover(function                            {                            	$menuContents.css({ display: 'block' });                            }) .mouseout(function                            {                            	$menuContents.css({ display: 'none' });                            }); $dropdown.insertBefore($myTools); var wrapper = { action: function(name, callback) {                   var $item = $('') .append($('')                                       .text(name)) .click(callback); $menuContents.append($item); return wrapper; },               inNamespace: function(id) {               	if (mwNamespaceId == id) {               		return wrapper; }               	return { action: function(name, callback) { }, inNamespace: function(id) { }, };               },            };            return wrapper; },

};   window.Ut = window.UserTools;

Ut.moveSuppressRedirect; Ut.suppressCategoryRedirects('Category:PL_image_redirects'); Ut.suppressCategoryRedirects('Category:ES_image_redirects');

Ut.onlyEditing(function   {    	function craftImageRedirectFn(category)    	{    		function execute    		{                var s = Ut.redirect( Ut.file($mwEditBox.val) ) + '\n';                s += Ut.category(category);                $mwEditBox.val(s);    		}    		return execute;    	}        Ut.buildActionSet('Preset')            .action('Image Redirect (pl)', craftImageRedirectFn('PL image redirects'))            .action('Image Redirect (es)', craftImageRedirectFn('ES image redirects'))            .action('JPG -> PNG', function {               var s = Ut.redirect(                    Ut.file('{' + '{subst:#replace:{' + '{subst:PAGENAME' + '}}|jpg|png' + '}}')                ); $mwEditBox.val(s); })           .inNamespace(Ut.namespaces.file)	            .action('Bad file name', function {               	var s = $mwEditBox.val + '\n'; s += Ut.category('Files with bad names'); $mwEditBox.val(s); $mwReasonBox.val('Needs to be renamed'); });   });

Ut.onlyUploading(function   {        Ut.buildActionSet('Preset')            .action('Spawning Map', function {               Ut.setUploadLicense('Copyright self'); Ut.setUploadDescription(Ut.category('SVG spawning maps')); })           .action('Dino Color Region', function {               Ut.setUploadLicense('Copyright Game'); Ut.setUploadDescription(Ut.category('Dino paint regions')); })           .action('Skin Icon', function {               Ut.setUploadLicense('Copyright Game'); Ut.setUploadDescription(Ut.category('Skin icons')); })           .action('Event Item Icon', function {               Ut.setUploadLicense('Copyright Game'); Ut.setUploadDescription(Ut.category('Event item icons')); })           .action('Chibi Icon', function {               Ut.setUploadLicense('Copyright Game'); Ut.setUploadDescription(Ut.category('Chibi-pet icons')); });   });

});