Jump to content

User:Haza-w.debug/title.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Haza-w.debug (talk | contribs) at 16:32, 11 September 2006 (Testing new system of recognition.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
function correctTitle() {
  if (document.getElementById('bodyContent').getElementsByTagName('a')[2].href.indexOf('/wiki/Wikipedia:Naming_conventions_%28technical_restrictions%29#Lower_case_first_letter')>-1 && document.title.indexOf('Template:')<0) {
    var contentDiv = document.getElementById('content'),
      bodyContentDiv = document.getElementById('bodyContent'),
      tLowercase = document.getElementById('bodyContent').getElementsByTagName('dl')[0],
      articleHead = contentDiv.getElementsByTagName('h1')[0],
      title1 = articleHead.innerHTML.substr(0,1).toLowerCase(),
      titleR = articleHead.innerHTML.slice(1);
    articleHead.innerHTML = title1 + titleR;
    bodyContentDiv.removeChild(tLowercase);
    document.title = title1 + titleR + " - Wikipedia, the free encyclopedia";
  }
}

if (window.addEventListener) window.addEventListener('load',correctTitle,false);
else if (window.attachEvent) window.attachEvent('onload',correctTitle);