User:EstherLoer/distinguish title.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// This script turns the name of the "File:" name space grey and adds a gap between it and the file name.

var firstHeading = document.getElementById("firstHeading");

	// to select all name spaces, use: RLCONF.wgNamespaceNumber > 0
if (RLCONF.wgNamespaceNumber == 6 && RLCONF.wgAction == "view") {
	// generate new title
	firstHeading.innerHTML = 
    '<span style="color:grey;margin-right:1em;">'
  	+ firstHeading.innerHTML.substring(0,firstHeading.innerHTML.search(":")+1)
  	+ '</span>'+firstHeading.innerHTML.substring(firstHeading.innerHTML.search(":")+1);
}

// [[Category:User scripts|distinguish_title]]