Jump to content

User:Titodutta/scripts/SearchHelper.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Titodutta (talk | contribs) at 16:13, 29 January 2019 (Add). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/*
The script adds a few options beside article
Main script by Writ and may be seen at https://en.wikipedia.org/wiki/User:Writ_Keeper/Scripts/googleTitle.js
*/$(document).ready(function()
{
		if(mw.config.get("wgCanonicalNamespace") == "")
		{
			var subjectName;
			var pageName = mw.config.get("wgPageName");
			if(pageName.charAt(pageName.length - 1) == ")")
			{
				subjectName = pageName.substring(0, pageName.lastIndexOf("(") - 1);
			}
			else
			{
				subjectName = pageName;
			}
            var newNode = " <a href='https://www.google.com/search?tbm=isch&q=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "' target='_blank'><span style='font-size:x-small;'>Google images</span></a>"
			$("#firstHeading").append(newNode);
			var newNode = " <a href='http://edwardbetts.com/find_link/" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "' target='_blank'><span style='font-size:x-small;'>Find link</span></a>"
			$("#firstHeading").append(newNode);

		}
});