User:Hytsnbr10519/common.js

$( function {	'use strict';	var title = mw.config.get( 'wgTitle' );	var namespace = mw.config.get( 'wgCanonicalNamespace' );	var specialPagename = mw.config.get( 'wgCanonicalSpecialPageName' );	var uploadAutoFill = mw.config.get( 'wgUploadAutoFill' );	var filledFilename = $( '#wpDestFile' ).val;	var urlParamas = location.search;

// Only run on pages that pagename is only alphanumeric characters if ( !/^[\x01-\x7E]+$/.test( title ) && !specialPagename ) return; var jaTitle = $('li.interlanguage-link.interwiki-ja > a').prop('title'); if(jaTitle){ title = jaTitle.replace('日本語: ', ''); }

var encodedTitle = encodeURIComponent( title ); var resultPagename = uploadAutoFill === false && /^[\x01-\x7E]+$/.test( filledFilename ) ? 'File:' + filledFilename : specialPagename ? namespace + ':' + specialPagename : encodedTitle;

var html = genLinkHtml( resultPagename, '対応する日本語版ページに移動', '日本語版' );

if ( urlParamas ) { var prefix = 'index.php?title='; var suffix = paramsList || ''; var resultPagenameWithParams = prefix + resultPagename + suffix; html += genLinkHtml( resultPagenameWithParams, '正確に対応する日本語版ページに移動', '日本語版 (A)' ); }

$( '#left-navigation ul' ).append( html );

function paramsList { var paramsPos = urlParamas.indexOf( '&' ); var params = urlParamas.slice( paramsPos );

if ( paramsPos === -1 ) { return; } else { return params; }	}

function genLinkHtml( pagename, title, label ) { return [ '', ' ',					'', label, '', ' ',			'' ].join( '' ); } } );