User:SD0001/SearchHelper.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:SD0001/SearchHelper. |
/*
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);
}
});