Jump to content

User:SD0001/SearchHelper.js

From Wikipedia, the free encyclopedia
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") == "" || mw.config.get("wgCanonicalNamespace") == "Draft")
		{
			var subjectName;
			var pageName = mw.config.get("wgTitle");
			if(pageName.charAt(pageName.length - 1) == ")")
			{
				subjectName = pageName.substring(0, pageName.lastIndexOf("(") - 1);
			}
			else
			{
				subjectName = pageName;
			}

			var newNode = " <a href='https://www.google.com/custom?hl=en&cx=007734830908295939403%3Agalkqgoksq0&cof=FORID%3A13%3BAH%3Aleft%3BCX%3AWikipedia%2520Reference%2520Search&q=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "' target='_blank'><span style='font-size:x-small;'>WRS</span></a>"; /*WRS from User:Sam Sailor/Scripts/WRStitle.js*/
			$("#firstHeading").append(newNode);

			var newNode = " <a href='http://www.google.com/search?q=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "+-wikipedia.org' target='_blank'><span style='font-size:x-small;'>Google search</span></a>"
						$("#firstHeading").append(newNode);

		    var newNode = " <a href='https://news.google.com/search?q=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "+-wikipedia.org' target='_blank'><span style='font-size:x-small;'>Google News</span></a>"
						$("#firstHeading").append(newNode);

			var newNode = " <a href='https://www.google.com/search?tbm=bks&q=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "+-wikipedia.org' target='_blank'><span style='font-size:x-small;'>Google Books</span></a>"
						$("#firstHeading").append(newNode);

            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='https://search.yahoo.com/search?p=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "' target='_blank'><span style='font-size:x-small;'>Yahoo</span></a>"
            			$("#firstHeading").append(newNode);

            var newNode = " <a href='https://duckduckgo.com/?q=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "' target='_blank'><span style='font-size:x-small;'>DuckDuckGo</span></a>"
            			$("#firstHeading").append(newNode);

            var newNode = " <a href='https://www.youtube.com/results?search_query=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "' target='_blank'><span style='font-size:x-small;'>YouTube</span></a>"
            			$("#firstHeading").append(newNode);

			var newNode = " <a href='https://commons.wikimedia.org/w/index.php?search=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "' target='_blank'><span style='font-size:x-small;'>Commons</span></a>"
            			$("#firstHeading").append(newNode);

			var newNode = " <a href='http://www.flickr.com/search/?l=commderiv&q=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "' target='_blank'><span style='font-size:x-small;'>Flickr (CC)</span></a>"
            			$("#firstHeading").append(newNode);

			var newNode = " <a href='https://www.imdb.com/find?q=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "' target='_blank'><span style='font-size:x-small;'>IMDb</span></a>"
						$("#firstHeading").append(newNode);

			var newNode = " <a href='https://www.jstor.org/action/doBasicSearch?Query=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "' target='_blank'><span style='font-size:x-small;'>JSTOR</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);

		    var newNode = " <a href='https://www.google.com/custom?hl=en&cx=014196815420355252912:fownxmjrhle&cof=FORID%3A13%3BAH%3Aleft%3BCX%3AWikipedia%2520Reference%2520Search&q=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "' target='_blank'><span style='font-size:x-small;'>Indian newspapers</span></a>";
			$("#firstHeading").append(newNode);

		}
});
if ( $('#t-wikibase').length ){
	console.log('Exist');
	link = $('li#t-wikibase a:first').attr('href');
	console.log( link );
}

$(document).ready(function()
{
		if(mw.config.get("wgCanonicalNamespace") == "" && $('#t-wikibase').length )
		{
			console.log('Exist');
			link = $('li#t-wikibase a:first').attr('href');

			var newNode = "<a href='" + link + "' target='_blank'><span style='font-size:x-small;'> Wikidata</span></a>";
			$("#firstHeading").append(newNode);
		}
});