User:Grunny/simplewikitab.js

From Simple English Wikipedia, the free encyclopedia

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/**
 * Adds a tab to link to the page with the same title on the Simple English Wikipedia
 * @author Grunny
 */
$( function () {
	var simplewikiUrlPath = 'http://simple.wikipedia.org/wiki/';
	if( mw.config.get( 'wgServer' ).indexOf( 'https://' ) === 0 ) {
		simplewikiUrlPath = mw.config.get( 'wgServer' ) + '/wikipedia/simple/wiki/';
	}
	if( mw.config.get( 'skin' ) === 'vector' ) {
		//Could just use p-views in the addPortletLink for vector, but it looks weird after the watch star
		$( '#p-views > ul > li#ca-history' ).after( '<li id="ca-simplewiki-link"><span><a href="' + simplewikiUrlPath + encodeURIComponent( mw.config.get( 'wgPageName' ) )
			+ '" title="View same page on the Simple English Wikipedia">SimpleWiki</a></span></li>' );
	} else {
		mw.util.addPortletLink( 'p-cactions', simplewikiUrlPath + encodeURIComponent( mw.config.get( 'wgPageName' ) ),
			"simplewiki", "ca-simplewiki-link", "View same page on the Simple English Wikipedia" );
	}
} );