User:TheTVExpert/scriptDocumentationTabs.js

$(document).ready(function { if(mw.config.get('wgCanonicalNamespace')==='User' && mw.config.get('wgAction') !== 'history' && !document.getElementById("wikiPreview")) { var page = mw.config.get('wgPageName'); var js = page.substr(page.length - 3); if(js==".js") {	page = page.slice(0,-3);	new mw.Api.get( { action: "query", titles: [ page ], } ).then( function( ret ) { $.each( ret.query.pages, function {        if ( this.missing !== "" ) {	var list = document.createElement("LI");	var link = document.createElement("A");	link.innerHTML = "Documentation";	link.href = "/wiki/" + page;	link.title = "View documentation";	list.appendChild(link);	var talk = document.getElementById("ca-talk");	talk.parentNode.insertBefore(list, talk.nextSibling);         }     } ); }, function( error ) { } ); } else {	page = page + ".js";	new mw.Api.get( { action: "query", titles: [ page ], } ).then( function( ret ) { $.each( ret.query.pages, function {        if ( this.missing !== "" ) {         	var list = document.createElement("LI");			var link = document.createElement("A");			link.innerHTML = "Script";            link.href = "/wiki/" + page;            link.title = "View script";            list.appendChild(link);			var talk = document.getElementById("ca-talk");			talk.parentNode.insertBefore(list, talk.nextSibling);         }     } ); }, function( error ) { } ); } } });