User:Will130/common.js

mw.loader.getScript( 'https://ark.fandom.com/index.php?title=User:alexrmski/patrolRevs.js&action=raw&ctype=text/javascript' ); mw.loader.getScript('https://dev.fandom.com/load.php?mode=articles&articles=MediaWiki:ArticlesAsResources.js&only=scripts').then(function {	importArticles({ type: 'script', articles: [ 'u:c:User:Will130/global.js' ]}); });

var img = document.createElement("img"); img.src = "https://static.wikia.nocookie.net/ucp-internal-test-starter-commons/images/4/49/Flag_gb.svg/revision/latest?cb=20200818142916"; img.width = 30; var src = document.getElementById("editpage-copywarn"); src.appendChild(img);

var img2 = document.createElement("img"); img2.src = "https://static.wikia.nocookie.net/ucp-internal-test-starter-commons/images/1/1e/Flag_us.svg/revision/latest?cb=20200818142636"; img2.width = 30; var src = document.getElementById("editpage-copywarn"); src.appendChild(img2);

/* Stolen from User:Alexrmski/fandomdesktop.js */ $(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 > span.wds-dropdown__toggle > svg.wds-icon.wds-icon-tiny.wds-dropdown__toggle-chevron'); var $mwDeleteReasonList = $('#wpDeleteReasonList'); var $myToolsDropdown = $('#my-tools-menu');

var SPAM_ARTICLE_REASON = 'Spam article'; var QUICK_ACCESS_LABEL = '⚡⚡⚡';

window.Ut = {       selectors: {           leaveRedirect: 'input[type=checkbox][name=wpLeaveRedirect][checked=checked]', },       actions: {           edit: 'edit', delete: 'delete', upload: -1, },       namespaces: mw.config.get('wgNamespaceIds'),

make: {           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); }           }        },

test: function(info) {           var result = true;

if (info.namespace) { if (Array.isArray(info.namespace)) { for (var index = 0; index < info.namespace.length; index++) {           			if (mwNamespaceId == info.namespace[index]) { result = result && true; break; }           		}            	} else { result = result && mwNamespaceId == info.namespace; }           }

if (info.action && result) { if (info.action == Ut.actions.upload) { result = result && (mwPageName === 'Special:Upload' || document.body.classList.contains('mw-special-Upload')); } else { result = result && (mwAction === info.action); }           }

return result; },

conditional: function(test, callback) {           if (Ut.test(test)) { callback; }       },

builder: function(test) {           if (Ut.test(test)) { var wrapper = { actionSet: function(name) { return Ut.buildActionSet(name) } };           }

var stub = { actionSet: function { return stub }, action: function { return stub }, inNamespace: function { return stub },

};           return stub; },

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

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

buildActionSet: function(name) {           var $menuContents = $(''); var $dropdownContents = $('') .append($menuContents); var $dropdown = $('') .append($('')                           		.text(name)                                    .prepend($dropdownIcon)) .append($dropdownContents) .mouseover(function                            {                            	$dropdownContents.css({ display: 'block' });                            }) .mouseout(function                            {                            	$dropdownContents.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) { }, };               },            };            return wrapper; },       extendMyTools: function(label, uri) {       	$myToolsDropdown.append($(' ')        							.append($('') .attr('href', mw.config.get('wgScriptPath') + '/wiki/' + uri) .text(label) ));       },

};

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

Ut.conditional({ namespace: Ut.namespaces.file, action: Ut.actions.edit }, function   {    	function craftImageRedirectFn(category)    	{    		function execute    		{                var s = Ut.make.redirect( Ut.make.file($mwEditBox.val) ) + '\n';                s += Ut.make.category(category);                $mwEditBox.val(s);    		}    		return execute;    	}        Ut.buildActionSet(QUICK_ACCESS_LABEL)            .action('Image Redirect (pl)', craftImageRedirectFn('PL image redirects'))            .action('Image Redirect (es)', craftImageRedirectFn('ES image redirects'))            .action('JPG -> PNG', function {               var s = Ut.make.redirect(                    Ut.make.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.make.category('Files with bad names'); $mwEditBox.val(s); $mwReasonBox.val('Needs to be renamed'); });   });

Ut.conditional({ action: Ut.actions.upload }, function   {        function craftUploadTupleSetterFn(license, category)        {            return function            {                Ut.setUploadLicense(license);                Ut.setUploadDescription(Ut.make.category(category));            };        }

Ut.buildActionSet(QUICK_ACCESS_LABEL) .action('Spawning Map',        craftUploadTupleSetterFn('Copyright self', 'SVG spawning maps')) .action('Dino Color Region',   craftUploadTupleSetterFn('Copyright Game', 'Dino paint regions')) .action('Skin Icon',           craftUploadTupleSetterFn('Copyright Game', 'Skin icons')) .action('Event Item Icon',     craftUploadTupleSetterFn('Copyright Game', 'Event item icons')) .action('Chibi Icon',          craftUploadTupleSetterFn('Copyright Game', 'Chibi-pet icons')); });   Ut.conditional({ namespace: Ut.namespaces.main, action: Ut.actions.delete }, function {       function craftReasonSetterFn(key) {           return function { $mwDeleteReasonList.value = key; }; }

Ut.buildActionSet(QUICK_ACCESS_LABEL) // quicker than the awful custom dropdowns. .action('Spam', craftReasonSetterFn(SPAM_ARTICLE_REASON)); });   Ut.conditional({ namespace: [ Ut.namespaces.widget, Ut.namespaces.mediawiki ] }, function {   	Ut.extendMyTools('Change content model', 'Special:ChangeContentModel/' + mw.config.get('wgPageName')); });

});