User:Darklama/myskin.js

// replace page title and subheadings with one unified and easy to use link navigation.

function page_title { var page_content = document.getElementById("column-content"); var headings = page_content.getElementsByTagName("h1"); var subpg = document.getElementById("contentSub"); var subpages; if (subpg) { subpg = subpg.getElementsByTagName("span"); for (var i = 0; i < subpg.length; i++) { if (!hasClass(subpg[i], "subpages")) continue; subpages = subpg[i]; break; } }  for (var i = 0; i < headings.length; i++) { // check for page name and replace it   if (!hasClass(headings[i], "firstHeading") && !hasClass(headings[i], "pagetitle")) continue; if (subpages) { subpages.setAttribute("id", "pagetitle"); subpages.removeAttribute("class"); headings[i].parentNode.replaceChild(subpages, headings[i]); subpages.removeChild(subpages.firstChild); for (var i = 0, node; node = subpages.childNodes.item(i); i++) { if (node.nodeType == Node.TEXT_NODE && node.data == " | ") { node.data = " → "; }     }      var pages = wgPageName.split("/"), title; title = document.createTextNode(" → "); subpages.appendChild(title); title = document.createElement('b').appendChild(document.createTextNode(pages[pages.length-1].replace(/_/g, " "))).parentNode; subpages.appendChild(title); } else { var pagetitle = document.createElement('div'), pages = wgPageName.split("/"), title; pagetitle.setAttribute("id", "pagetitle"); if (pages.length == 1) { title = document.createElement('b').appendChild(document.createTextNode(pages[0].replace(/_/g, " "))).parentNode; pagetitle.appendChild(title); } else { title = document.createElement('a').appendChild(document.createTextNode(pages[0].replace(/_/g, " "))).parentNode; title.href = wgArticlePath.replace("$1", pages[0]); pagetitle.appendChild(title); }     for (var j = 1; j < pages.length; j++) { title = document.createTextNode(" → "); pagetitle.appendChild(title); if (pages.length == j+1) { title = document.createElement('b').appendChild(document.createTextNode(pages[j].replace(/_/g, " "))).parentNode; pagetitle.appendChild(title); } else { title = document.createElement('a').appendChild(document.createTextNode(pages[j].replace(/_/g, " "))).parentNode; title.href = wgArticlePath.replace("$1", pages.slice(0, j+1).join("/")); pagetitle.appendChild(title); }     }      headings[i].parentNode.replaceChild(pagetitle, headings[i]); break; } } }

addLoadEvent(page_title);

import_script('User:Darklama/test.js');