MediaWiki:Gadget-CropTool.js

Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// CropTool code begins, see [[Commons:CropTool]] for details
'use strict';
var title = mw.config.get('wgTitle');
if (mw.config.get('wgNamespaceNumber') === 6 &&
	mw.config.get('wgIsArticle') &&
	/(PNG|GIF|JPE?G|DJVU|PDF|TIF?F|WEBP)$/i.test(title) &&
	document.getElementById('file')) {
	$(function () {
		try {
			title = new mw.Uri('https://croptool.toolforge.org/')
				.extend({
					title: title,
					page: new mw.Uri().query.page,
					site: mw.config.get('wgDBname') !== 'commonswiki' ? mw.config.get('wgServer').replace(/^\/\//, '') : undefined
				});
		} catch ( e ) {
			return;
		}
		mw.util.addPortletLink(
			'p-tb',
			title.toString(),
			'⌗ CropTool',
			't-crop',
			'Crop this image');
	});
}