User:Ahecht/Scripts/FileExporter.js

/* * * This gadget adds a link from Wikipedia images to the FileImporter tool on * Wikimedia Commons. * * Based on: https://commons.wikimedia.org/wiki/MediaWiki:Gadget-CropTool.js * * Installation: * * Add the following line to Special:MyPage/common.js or meta:Special:MyPage/global.js to install: *   mw.loader.load( "//en.wikipedia.org/w/index.php?title=User:Ahecht/Scripts/FileExporter.js&action=raw&ctype=text/javascript" ); // Linkback: en:User:Ahecht/Scripts/FileExporter.js * */

(function (mw, $) { "use strict";

if ( mw.config.get('wgNamespaceNumber') !== 6 || mw.config.get('wgAction') !== 'view' ) return;

$(function {

var currentUri = new mw.Uri, exportUri = new mw.Uri('//commons.wikimedia.org/wiki/Special:ImportFile');

exportUri.extend({		clientUrl: currentUri,		importSource: 'FileExporter',	});

mw.util.addPortletLink(		'p-views',		exportUri.toString,		'Export to Commons',		'f-export',		'Export file to Wikimedia Commons'); });

})(mediaWiki, jQuery);