User:Wikidudeman/quicknav.js

// See Talk page for instructions

if (wgNamespaceNumber >= 0) addOnloadHook(function {

var pCactions = document.getElementById('p-cactions'); var tabs = pCactions.getElementsByTagName('ul')[0]; var caMain = pCactions.getElementsByTagName('li')[0]; var menu2 = pCactions.getElementsByTagName('li')[1]; var caTalk = document.getElementById('ca-talk'); var caEdit = document.getElementById('ca-edit'); if (!caEdit) { caEdit = document.getElementById('ca-viewsource'); } var caHistory = document.getElementById('ca-history');

// Insert new menu after first entry na = document.createElement("a"); na.appendChild(document.createTextNode('pagenav')); na.href = "#"; var mn = document.createElement("ul"); li = document.createElement("li") li.appendChild(na); li.appendChild(mn); li.className = 'tabmenu'; li.id = 'ca-quicknav'; tabs.insertBefore(li,menu2);

// Hide menus if (caEdit) caEdit.style.display = 'none'; if (caTalk) caTalk.style.display = 'none'; if (caHistory) caHistory.style.display = 'none';

// Retrieve URLs var hrefmain = caMain.firstChild.getAttribute('href', 2); var hreftalk = caTalk.firstChild.getAttribute('href', 2);

// Add menu items mw.util.addPortletLink('ca-quicknav', hrefmain, 'view'); mw.util.addPortletLink('ca-quicknav', hrefmain + '?action=edit', 'edit'); mw.util.addPortletLink('ca-quicknav', hrefmain + '?action=history', 'history'); mw.util.addPortletLink('ca-quicknav', hreftalk, 'view discussion'); mw.util.addPortletLink('ca-quicknav', hreftalk + '?action=edit', 'edit discussion'); mw.util.addPortletLink('ca-quicknav', hreftalk + '?action=history', 'discussion history');

});