User:Kku/Scripts/SpTitle.js

$(document).ready(function {

console.log("SpTitle.js");

if(mw.config.get("wgCanonicalNamespace") == "") {			var subjectName; var smallstyle="font-size:x-small;"; var pageName = mw.config.get("wgPageName"); if(pageName.charAt(pageName.length - 1) == ")")			{				subjectName = pageName.substring(0, pageName.lastIndexOf("(") - 1); }			else {				subjectName = pageName; }			var spacer= document.createElement("span"); spacer.innerHTML=" - "; spacer.style.cssText=smallstyle; // https://stackoverflow.com/questions/5927012/javascript-createelement-style-problem var searchNodeSp = document.createElement("a"); searchNodeSp.href = "http://www.startpage.com/do/search?query=" + encodeURIComponent(subjectName.replace(/_/g, " ")); //+ "+-wikipedia.org"; searchNodeSp.target = "_blank"; //			searchNodeSp.innerHTML = " Search SP "; searchNodeSp.innerHTML = "Search SP"; searchNodeSp.style.cssText=smallstyle; var searchNodeGs = document.createElement("a"); searchNodeGs.href = "https://scholar.google.de/scholar?hl=de&q=" + encodeURIComponent(subjectName) + "+-wikipedia.org"; searchNodeGs.target = "_blank"; searchNodeGs.innerHTML = "GS"; searchNodeGs.style.cssText=smallstyle;

var fh=document.getElementById("firstHeading"); fh.appendChild(spacer); fh.appendChild(searchNodeSp); fh.appendChild(spacer.cloneNode(true));//https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode fh.appendChild(searchNodeGs); } /*      else { //console.log("Browsing in " + mw.config.get( 'wgCanonicalNamespace' ) + " namespace so SpTitle.js will not do much."); return; }*/ });