User:Bradv/SearchLinks.js

(function ( $, mw ) {

var ns = mw.config.get('wgCanonicalNamespace');

if (ns === "Special")

return; // no links for special pages

mw.loader.using(["mediawiki.util"]).then(function () {

var title = mw.config.get('wgTitle');

if (ns !== "")

title = title.replace(/^.*\//, ""); // subpage name only

var query = encodeURIComponent(title);

mw.util.addPortletLink('p-tb',

'https://www.google.com/search?as_eq=wikipedia&q=%22'+query+'%22&num=50',

'Google',

't-googlesearch',

'Search Google for "'+title+'"', 'G');

mw.util.addPortletLink('p-tb',

'https://www.google.com/search?tbm=nws&q=%22'+query+'%22+-wikipedia',

'news',

't-googlenewssearch',

'Search Google News for "'+title+'"');

mw.util.addPortletLink('p-tb',

'https://www.google.com/search?&q=%22'+query+'%22+site:news.google.com/newspapers&source=newspapers',

'newspapers',

't-googlenewspapersearch',

'Search newspapers for "'+title+'"');

mw.util.addPortletLink('p-tb',

'https://www.google.com/search?tbs=bks:1&q=%22'+query+'%22+-wikipedia',

'books',

't-googlebookssearch',

'Search Google Books for "'+title+'"');

mw.util.addPortletLink('p-tb',

'https://scholar.google.com/scholar?q=%22'+query+'%22',

'scholar',

't-googlescholarsearch',

'Search Google Scholar for "'+title+'"');

mw.util.addPortletLink('p-tb',

'https://www.jstor.org/action/doBasicSearch?Query=%22'+query+'%22&acc=on&wc=on',

'JSTOR',

't-jstor',

'Search JSTOR for "'+title+'"');

});

} (jQuery, mediaWiki ));

/*

$(function () {

if (wgCanonicalNamespace == "Special")

return; // no links for special pages

var title = wgTitle;

if (wgCanonicalNamespace !== "")

title = title.replace(/^.*\//, ""); // subpage name only

var query = encodeURIComponent(title);

mw.util.addPortletLink('p-tb', 'https://www.google.com/search?as_eq=wikipedia&q=%22'+query+'%22&num=50',

'Google', 't-googlesearch', 'Search Google for "'+title+'"', 'G');

mw.util.addPortletLink('p-tb', 'https://www.google.com/search?tbm=nws&q=%22'+query+'%22+-wikipedia',

'news', 't-googlenewssearch', 'Search Google News for "'+title+'"');

mw.util.addPortletLink('p-tb', 'https://www.google.com/search?&q=%22'+query+'%22+site:news.google.com/newspapers&source=newspapers',

'newspapers', 't-googlenewspapersearch', 'Search newspapers for "'+title+'"');

mw.util.addPortletLink('p-tb', 'https://www.google.com/search?tbs=bks:1&q=%22'+query+'%22+-wikipedia',

'books', 't-googlebookssearch', 'Search Google Books for "'+title+'"');

mw.util.addPortletLink('p-tb', 'https://scholar.google.com/scholar?q=%22'+query+'%22',

'scholar', 't-googlescholarsearch', 'Search Google Scholar for "'+title+'"');

mw.util.addPortletLink('p-tb', 'https://www.jstor.org/action/doBasicSearch?Query=%22'+query+'%22&acc=on&wc=on',

'JSTOR', 't-jstor', 'Search JSTOR for "'+title+'"');

});

  • //*

https://www.google.com/search?as_eq=wikipedia&q=%22'+query+'%22&num=50

https://www.google.com/search?tbm=nws&q=%22'+query+'%22+-wikipedia

https://www.google.com/search?&q=%22'+query+'%22+site:news.google.com/newspapers&source=newspapers

https://www.google.com/search?tbs=bks:1&q=%22'+query+'%22+-wikipedia

https://scholar.google.com/scholar?q=%22'+query+'%22

https://www.jstor.org/action/doBasicSearch?Query=%22'+query+'%22&acc=on&wc=on

  • /