User:Mr. Stradivarius/SourceLinks.js

$( document ).ready( function {	'use strict';

var config = mw.config.get( [ 'wgTitle', 'wgNamespaceNumber' ] ); if ( config.wgNamespaceNumber === -1 ) { return; // no links for special pages }

var title = config.wgTitle; if ( config.wgNamespaceNumber !== 0 ) { title = title.replace( /^.*\//, "" ); // subpage name only }

var query = encodeURIComponent('"' + title + '" -Wikipedia' ); var escapedTitle = mw.html.escape( title );

mw.util.addPortletLink(		'p-tb',		'https://www.google.co.uk/search?&q=' + query,		'Web search',		't-googlesearch',		'Search Google for "' + escapedTitle + '"'	); mw.util.addPortletLink(		'p-tb',		'https://www.google.co.uk/?#q=' + query + '&tbm=nws',		'News search',		't-googlenewssearch',		'Search Google News for "' + escapedTitle + '"'	); mw.util.addPortletLink(		'p-tb',		'https://www.google.co.uk/search?q=' + query + ' -inpublisher:icon&btnG=Search+Books&tbm=bks&tbo=1',		'Books search',		't-googlebookssearch',		'Search Google Books for "' + escapedTitle + '"'	); mw.util.addPortletLink(		'p-tb',		'https://scholar.google.co.uk/scholar?&q=' + query,		'Scholar search',		't-googlescholarsearch',		'Search Google Scholar for "' + escapedTitle + '"'	); } );