User:Iamojo/iare.js

/*	Adds a toolbox link to load Reference Explorer of the current page.

Install by adding: importScript('User:iamojo/iare.js'); // User:iamojo/iare.js to your Special:MyPage/common.js.

mw.loader.using('mediawiki.util', function {	if (mw.config.get('wgNamespaceNumber') < 0) {		return;	}

var pageUrl = 'https://' + mw.config.get('wgServerName') + mw.config.get('wgArticlePath').replace('$1', mw.config.get("wgPageName")) var url = 'https://archive.org/services/context/iare/?url=' + pageUrl // may need to endode url parameter vvalue here... var link = mw.util.addPortletLink(		'p-tb', // portletId - p-tb is "portlet toolbox"		url,	 // href		'Open Reference Explorer',  // text display		'pt-iare', // unique id of list item		'Open Reference Explorer for this article'	);

$( link ).click( function ( event ) {           event.preventDefault;        	var iareLink = $(this).find("a")[0].href            window.open(iareLink);		    return false;        } ); });