User:DannyS712 test/commons.js

// Install with: // // or with //  // // If forking this script, please note my contributions / give me credit // $(function { var View_Commons_config = {	name: 'View Commons.js',	version: 1.0,	debug: false };

mw.loader.using( 'mediawiki.util', function {    $(document).ready( function  { var page = mw.config.get('wgCanonicalNamespace'); if (page && page == "File") { var current = window.location.href; var target = current.replace(/en.wikipedia/i, 'commons.wikimedia'); if (View_Commons_config.debug) console.log ( target ); mw.util.addPortletLink ( 'p-cactions', target, 'View on commons', 'ca-commons-link', 'View this page on commons'); }   } ); } ); }); //