Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
 
/*
<pre> <nowiki>
Note: After saving, you have to bypass your browser's cache to see the changes.
To do this in Firefox/Mozilla/Safari: hold down Shift while clicking Reload, 
or press Ctrl-Shift-R). 
If you use Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
 
</nowiki> </pre>
==AzaToth's reversion tools ==
<pre> <nowiki> */
// importScript('User:AzaToth/twinkle.js');
 
/*
</nowiki> </pre>
==Lupin's anti-vandal tools ==
<pre> <nowiki> */
 
 
// Script from [[User:Lupin/recent2.js]]
importScript( 'User:Lupin/recent2.js');



importScript('User:Chicocvenancio/HelpDeskTBLinks.js');

/*==Tool to delete all non-current revisions of the image and remove the "rescaled" tag from the description page ==*/
importScript("User:Drilnoth/delresized.js");
// <nowiki>
// PermissionOTRS.js
// Originally from https://commons.wikimedia.org/wiki/MediaWiki:Gadget-PermissionOTRS.js
//
// Adds OTRS permission template via the API. Other templates such as
// {{OTRS pending}} will be removed.
//
// Maintainer: [[DieBuche]]
// Licensed under the terms of the MIT license
// Authors: Bryan Tong Minh, [[:de:User:DerHexer]], [[User:Guandalug]], [[User:DieBuche]]
// Modified by Legoktm for use on [[:w:en:]]
 
/*global mediaWiki:false, jQuery:false, prompt:false, alert:false */
/*jshint curly:false */
(function($, mw) {
'use strict';
if (mw.config.get('wgNamespaceNumber') !== 6) return;
 
var PermissionOTRS = window.PermissionOTRS = {
	usersignature: "{{subst:" + "REVISIONUSER}}",
	prompt: function () {
		this.ticket = prompt('Ticket link or Number:');
		this.ticket = $.trim(this.ticket);
		if (this.ticket) this.getPage(this, this.addPermission);
	},
	getPage: null,
	cleanUp: null,
	savePage: null,
	addPermission: function (result) {
		var pages = result.query.pages;
		for (var id in pages) {
		if (pages.hasOwnProperty(id)) {
			var page = pages[id];
			this.edittoken = page.edittoken;
			this.content = page.revisions[0]['*'];
			this.timestamp = page.revisions[0].timestamp;
 
			//Check whether numerical
			var type;
			if (this.ticket.match(/^\d*$/)) {
				type = "id";
			} else {
				type = "ticket";
			}
			var template = '{{PermissionOTRS|' + type + '=' + this.ticket + "|" + this.usersignature + "}}";
 
			var text = this.content;
			var permTester = /\|Permission\s*\=/i;
 
			if (!permTester.test(text)) {
				return alert('No suitable place found to insert template!');
			}
 
			text = this.cleanUp(text);
 
			var replacedlicence = text.match(/\|Permission\s*\=([^\n]*)(\n)/);
			if (replacedlicence && replacedlicence[1] && replacedlicence[2]) {
				if ($.trim(replacedlicence[1]) !== "") {
					replacedlicence = replacedlicence[2] + replacedlicence[1];
					text += "\r\n" + replacedlicence;
				}
			}
			text = text.replace(/\|Permission(\s*)\=[^\n]*/i, "|Permission$1= " + template);
 
			this.content = text;
			this.savePage('Adding [[WP:OTRS|OTRS]] permission using [[User:Legoktm/PermissionOTRS.js|PermissionOTRS.js]]');
		}
		}
	}
};
 
var OTRSreceived = window.OTRSreceived = {
	prompt: function () {
		this.ticket = prompt('Ticket link or Number:');
		this.ticket = $.trim(this.ticket);
		if (this.ticket) this.getPage(this, this.addPermission);
	},
	getPage: null,
	cleanUp: null,
	savePage: null,
	// Rillke: I will never understand why doing so complicated. Just use {{subst:#time ...}} and you even get the server(UTC)-time.
	formatDate: function (fmt, date) {
		var pad0 = function (s) {
			s = "" + s;
			return (s.length > 1 ? s : "0" + s);
		}; // zero-pad to two digits
		if (!date) date = new Date();
		fmt = fmt.replace(/YYYY/g, date.getUTCFullYear());
		fmt = fmt.replace(/MM/g, pad0(date.getUTCMonth() + 1));
		fmt = fmt.replace(/DD/g, pad0(date.getUTCDate()));
		fmt = fmt.replace(/MON/g, mw.config.get('wgMonthNames')[date.getUTCMonth()+1]);
		fmt = fmt.replace(/DAY/g, date.getUTCDate());
		return fmt;
	},
	addPermission: function (result) {
		var pages = result.query.pages;
		for (var id in pages) {
		if (pages.hasOwnProperty(id)) {
			var page = pages[id];
			this.edittoken = page.edittoken;
			this.content = page.revisions[0]['*'];
			this.timestamp = page.revisions[0].timestamp;
 
			//Check whether numerical
			var type;
			if (this.ticket.match(/^\d*$/)) {
				type = "id";
			} else {
				type = "ticket";
			}
 
			var template = '{{OTRS received|' + type + '=' + this.ticket + this.formatDate("|year=YYYY|month=MON|day=DAY}}");
 
			var text = this.content;
			var permTester = /\|Permission\s*\=/i;
 
			if (!permTester.test(text)) {
				return alert('No suitable place found to insert template!');
			}
 
			text = this.cleanUp(text);
 
			var replacedlicence = text.match(/\|Permission\s*\=([^\n]*)(\n)/);
			if (replacedlicence && replacedlicence[1] && replacedlicence[2]) {
				if ($.trim(replacedlicence[1]) !== "") {
					replacedlicence = replacedlicence[2] + replacedlicence[1];
					text += "\r\n" + replacedlicence;
				}
			}
			text = text.replace(/\|Permission(\s*)\=[^\n]*/i, "|Permission$1= " + template);
 
			this.content = text;
			this.savePage('[[WP:OTRS|OTRS]] email received but permission not yet confirmed');
		}
		}
	}
};
 
OTRSreceived.getPage = PermissionOTRS.getPage = function (thisarg, cb) {
	$.getJSON(mw.config.get('wgScriptPath') + '/api.php', {
		action: "query",
		format: "json",
		prop: "info|revisions",
		intoken: "edit",
		rvprop: "content|timestamp",
		titles: mw.config.get('wgPageName')
	}, function(r) {cb.apply(thisarg, [r]);});
};
 
OTRSreceived.cleanUp = PermissionOTRS.cleanUp = function(text) {
	//text = text.replace(/\=\= Summary \=\=/g, '== {{int:filedesc}} ==');
	//text = text.replace(/\=\= Licensing \=\=/g, '== {{int:license-header}} ==');
 
	text = text.replace(/\{\{OTRS[ _\-][Pp]ending[^\}\n]*\}\}/g, '');
	text = text.replace(/\{\{no[ _]license[^\}\n]*\}\}/g, '');
	text = text.replace(/\{\{no[ _]permission[^\}\n]*\}\}/g, '');
	text = text.replace(/\{\{no[ _]OTRS[ _]permission[^\}\n]*\}\}/g, '');
	text = text.replace(/\{\{OTRS[ _][Rr]eceived[^\}\n]*\}\}/g, '');
	text = text.replace(/\{\{delete[^\n]*\(CE[S]?T\)\s*/g, '');
	text = text.replace(/\{\{delete[^\}\n]*\}\}\b/g, '');
	text = text.replace(/\{\{di-no[ _]permission[^\}\n]*\}\}\b/g, ''); //Added by Legoktm
	return text;
};
 
OTRSreceived.savePage = PermissionOTRS.savePage = function (summary) {
	var params = {
		action: 'edit',
		summary: summary,
		watchlist: 'preferences',
		title: mw.config.get('wgPageName'),
		token: this.edittoken,
		text: this.content,
		format:'json'
	};
	$.ajax({
		url: mw.config.get('wgScriptPath') + '/api.php',
		cache: false,
		dataType: 'json',
		data: params,
		basetimestamp: this.timestamp,
		type: 'POST',
		success: function () {
			window.location.reload();
		}
	});
};
 
 
$.when( mw.loader.using(['mediawiki.util']), $.ready ).done( function () {
	mw.util.addPortletLink('p-tb', 'javascript:void(PermissionOTRS.prompt())', 'PermissionOTRS');
	mw.util.addPortletLink('p-tb', 'javascript:void(OTRSreceived.prompt())', 'OTRS received');
});
 
}(jQuery, mediaWiki));
// </nowiki>
mw.loader.load('//en.wikipedia.org/w/index.php?title=User%3AB%2Frescaledsidebar.js&action=raw&ctype=text/javascript'); // [[User:B/rescaledsidebar.js]]